@debugmcp/mcp-debugger
Version:
Run-time step-through debugging for LLM agents.
116 lines (90 loc) • 3.57 kB
Markdown
# Task 4.4: Mock Adapter Language Registration Fix - Summary
## 🎯 Objective
Fix the language registration for the mock adapter to ensure it uses `'mock'` as its language identifier, not `'javascript'`. This prevents conflicts with future language adapters and clarifies that the mock adapter is for testing purposes only.
## ✅ What Was Fixed
### 1. **Server Language Metadata** (`src/server.ts`)
Changed the hardcoded case in `getLanguageMetadata()`:
```typescript
// Before:
case 'javascript':
return {
id: 'javascript',
displayName: 'JavaScript (Mock)',
...
};
// After:
case 'mock':
return {
id: 'mock',
displayName: 'Mock',
...
};
```
### 2. **Server Test Mock** (`tests/core/unit/server/server.test.ts`)
Updated the mock to return correct supported languages:
```typescript
// Before:
getSupportedLanguages: vi.fn().mockReturnValue(['python', 'javascript']),
// After:
getSupportedLanguages: vi.fn().mockReturnValue(['python', 'mock']),
```
### 3. **Session Store Test** (`tests/core/unit/session/session-store.test.ts`)
Updated error handling test to use a clearly invalid language:
```typescript
// Before:
language: 'javascript' as DebugLanguage
// After:
language: 'unsupported' as DebugLanguage
```
## ✅ What Was Already Correct
1. **DebugLanguage Enum** (`src/session/models.ts`)
- Already had `MOCK = 'mock'` defined
2. **Mock Adapter Registration** (`src/container/dependencies.ts`)
- Already registered with `DebugLanguage.MOCK`
3. **Mock Adapter Implementation** (`src/adapters/mock/mock-debug-adapter.ts`)
- Already reported `readonly language = DebugLanguage.MOCK`
## 🔍 Verification Results
Running `list_supported_languages` now correctly returns:
```json
{
"languages": [
{
"id": "python",
"displayName": "Python",
"version": "1.0.0",
"requiresExecutable": true,
"defaultExecutable": "python"
},
{
"id": "mock",
"displayName": "Mock",
"version": "1.0.0",
"requiresExecutable": false
}
]
}
```
## 🚫 Impact on Future JavaScript Support
- No references to `'javascript'` remain in the codebase related to the mock adapter
- A real JavaScript adapter can be implemented without conflicts
- Clear separation between test infrastructure (mock) and real language adapters
## 📊 Test Results
The changes have been verified to:
1. ✅ Correctly report supported languages as `['python', 'mock']`
2. ✅ Allow creation of sessions with language `'mock'`
3. ✅ Reject creation of sessions with language `'javascript'` (as expected)
4. ✅ Maintain all existing test functionality
## 🔧 Technical Details
### Files Modified:
1. `src/server.ts` - Updated language metadata switch case
2. `tests/core/unit/server/server.test.ts` - Fixed mock setup
3. `tests/core/unit/session/session-store.test.ts` - Updated test for clarity
### No Breaking Changes:
- Existing Python functionality unchanged
- Mock adapter continues to work for all tests
- No API changes for consumers
## 📝 Notes
- The session store test was using `'javascript'` to test error handling for unsupported languages. This was changed to `'unsupported'` to make the test's intent clearer.
- The test file import paths in `server.test.ts` were also corrected from relative paths like `../../src/` to `../../../../src/` to match the new test structure.
## ✅ Task Complete
The mock adapter is now properly registered and identified as `'mock'` throughout the codebase, preventing any conflicts with future JavaScript adapter implementations.