Shared interfaces, types, and utilities for MCP Debugger
npm install @debugmcp/sharedShared interfaces, types, and base classes for the MCP Debugger monorepo.
This package contains all the shared contracts and types that are used across the MCP Debugger ecosystem. By centralizing these definitions, we ensure consistency and enable better type safety across all packages.
``bash`
npm install @debugmcp/shared
#### Debug Adapter Interfaces
- IDebugAdapter - Core interface for all debug adapter implementationsAdapterState
- - Enumeration of adapter statesAdapterCapabilities
- - DAP capabilities structureAdapterConfig
- - Configuration for adapter instancesAdapterCommand
- - Command structure for launching adapters
#### External Dependencies
- IFileSystem - File system operations interfaceIProcessManager
- - Process management interfaceINetworkManager
- - Network operations interfaceILogger
- - Logging interfaceIEnvironment
- - Environment information interfaceIProxyManager
- - Debug proxy management interface
#### Adapter Registry
- IAdapterFactory - Factory interface for creating adaptersIAdapterRegistry
- - Registry for managing adapter factoriesAdapterDependencies
- - Dependencies required by adaptersAdapterMetadata
- - Metadata about adapter implementations
#### Session Types
- SessionState - Debug session statesSessionLifecycleState
- - Session lifecycle statesExecutionState
- - Execution states (running, paused, etc.)DebugSessionInfo
- - Public session informationBreakpoint
- - Breakpoint structureVariable
- - Variable informationStackFrame
- - Stack frame information
#### Configuration Types
- GenericLaunchConfig - Base launch configurationLanguageSpecificLaunchConfig
- - Language-specific launch configsDebugFeature
- - Enumeration of debug features
- AdapterFactory - Abstract base class for adapter factories
- DebugLanguage - Supported debug languages (Python, Mock, etc.)AdapterState
- - Adapter lifecycle statesSessionState
- - Session statesAdapterErrorCode
- - Error codes for adapter operations
`typescript
import {
IDebugAdapter,
AdapterState,
DebugLanguage,
AdapterDependencies
} from '@debugmcp/shared';
export class MyDebugAdapter implements IDebugAdapter {
readonly language = DebugLanguage.PYTHON;
readonly name = 'My Python Adapter';
constructor(dependencies: AdapterDependencies) {
// Initialize with dependencies
}
async initialize(): Promise
// Initialization logic
}
// ... implement other required methods
}
`
`typescript
import {
AdapterFactory,
IDebugAdapter,
AdapterDependencies,
AdapterMetadata,
DebugLanguage
} from '@debugmcp/shared';
export class MyAdapterFactory extends AdapterFactory {
createAdapter(dependencies: AdapterDependencies): IDebugAdapter {
return new MyDebugAdapter(dependencies);
}
getMetadata(): AdapterMetadata {
return {
language: DebugLanguage.PYTHON,
displayName: 'Python',
version: '1.0.0',
// ... other metadata
};
}
}
`
`typescript
import {
SessionState,
DebugSessionInfo,
Breakpoint
} from '@debugmcp/shared';
function handleSessionState(session: DebugSessionInfo) {
switch (session.state) {
case SessionState.RUNNING:
console.log('Session is running');
break;
case SessionState.PAUSED:
console.log('Session is paused');
break;
// ... handle other states
}
}
`
`bash`
npm run build
`bash`
npm test
`bash`
npm run type-check
This package follows a clear separation of concerns:
1. Interfaces - Define contracts that implementations must follow
2. Types - Define data structures and type aliases
3. Base Classes - Provide common functionality for implementations
4. Enumerations - Define constant values and states
If you're migrating from the monolithic structure to use this shared package:
1. Update your imports:
`typescript`
// Before
import { IDebugAdapter } from '../adapters/debug-adapter-interface.js';
// After
import { IDebugAdapter } from '@debugmcp/shared';
2. Remove local interface definitions that are now in shared
3. Update your tsconfig.json to reference the shared package@debugmcp/shared
4. Ensure your package.json includes as a dependency
When adding new shared types or interfaces:
1. Place interfaces in src/interfaces/src/models/
2. Place types in src/factories/
3. Place base classes in src/index.ts` to export new additions
4. Update
5. Document the additions in this README
6. Add tests if applicable
MIT - See LICENSE file in the repository root