@debugmcp/shared
v0.17.0
Published
Shared interfaces, types, and utilities for MCP Debugger
Maintainers
Readme
@debugmcp/shared
Shared interfaces, types, and base classes for the MCP Debugger monorepo.
Overview
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.
Installation
npm install @debugmcp/sharedWhat's Included
Interfaces
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
Types
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
Base Classes
AdapterFactory- Abstract base class for adapter factories
Enumerations
DebugLanguage- Supported debug languages (Python, Mock, etc.)AdapterState- Adapter lifecycle statesSessionState- Session statesAdapterErrorCode- Error codes for adapter operations
Usage Examples
Implementing a Debug Adapter
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<void> {
// Initialization logic
}
// ... implement other required methods
}Creating an Adapter Factory
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
};
}
}Using Session Types
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
}
}Development
Building
npm run buildTesting
npm testType Checking
npm run type-checkArchitecture
This package follows a clear separation of concerns:
- Interfaces - Define contracts that implementations must follow
- Types - Define data structures and type aliases
- Base Classes - Provide common functionality for implementations
- Enumerations - Define constant values and states
Migration Guide
If you're migrating from the monolithic structure to use this shared package:
Update your imports:
// Before import { IDebugAdapter } from '../adapters/debug-adapter-interface.js'; // After import { IDebugAdapter } from '@debugmcp/shared';Remove local interface definitions that are now in shared
Update your
tsconfig.jsonto reference the shared packageEnsure your package.json includes
@debugmcp/sharedas a dependency
Contributing
When adding new shared types or interfaces:
- Place interfaces in
src/interfaces/ - Place types in
src/models/ - Place base classes in
src/factories/ - Update
src/index.tsto export new additions - Document the additions in this README
- Add tests if applicable
License
MIT - See LICENSE file in the repository root