Skip to main content
Glama

MCP Code Expert System

by tomsiwik
vibeLog.md4.59 kB
# MCP Code Expert System - Implementation Status ## Current State Overview The MCP Code Expert System is now structurally sound with a clear separation of concerns and proper encapsulation following the MCP protocol implementation patterns. We've successfully addressed the parameter structure issues. ## What's Working 1. **Tool Registration**: The system properly registers tools with the MCP protocol - Expert tools (`ask_martin` and `ask_bob`) are properly registered - Knowledge graph tools (`read_graph`, `search_nodes`, `open_nodes`) are properly registered 2. **Expert Encapsulation**: Each expert is properly encapsulated in its own module - Experts define their own `input_schema` following JSON Schema format - Experts implement the standardized `ExpertInterface` protocol - Common models are shared through the `experts` package 3. **MCP Protocol Compatibility**: The server implementation follows MCP protocol standards - Using `inputSchema` property instead of `parameters` for tools - Correct initialization options for the MCP server - Proper handling of SSE transport 4. **Communication Flow**: The server receives requests and routes them to the appropriate experts - Tool calls are correctly routed to the corresponding expert implementation - Arguments are properly parsed into `CodeReviewRequest` objects ## Issues Encountered 1. **Pydantic Validation Errors**: When processing Ollama responses ``` Error handling tool call ask_bob: 4 validation errors for CodeReviewResponse review Input should be a valid string [type=string_type, input_value={'cleanCodePrinciples': {...eparation of concerns.'}, input_type=dict] For further information visit https://errors.pydantic.dev/2.10/v/string_type suggestions.0 Input should be a valid string [type=string_type, input_value={'method': 'calculateTota...ction being performed.'}, input_type=dict] For further information visit https://errors.pydantic.dev/2.10/v/string_type suggestions.1 Input should be a valid string [type=string_type, input_value={'method': 'checkout', 'i...ke code more readable.'}, input_type=dict] For further information visit https://errors.pydantic.dev/2.10/v/string_type suggestions.2 Input should be a valid string [type=string_type, input_value={'method': 'addItem', 'im...ing added to the cart.'}, input_type=dict] For further information visit https://errors.pydantic.dev/2.10/v/string_type ``` 2. **Format Mismatch**: Ollama seems to be returning JSON objects where we expect strings - The `review` field is a dictionary object instead of a string - The `suggestions` list contains dictionary objects instead of strings - This causes Pydantic validation to fail when creating the `CodeReviewResponse` 3. **Response Handling**: We need to adapt our Ollama response processing - The `ollama_service.py` needs to be updated to handle this JSON format - The current response parsing doesn't match what Ollama is actually returning ## Data Flow Analysis 1. **Request Flow**: - Client calls `ask_bob` with JavaScript code - Server routes to the correct expert via `experts_by_tool` - Request is validated and converted to `CodeReviewRequest` - Request is passed to the expert's `review_code` method 2. **Processing Flow**: - `RobertCMartinExpert.review_code` calls `ollama_service.get_robert_c_martin_review` - Ollama service returns a result with the review, suggestions, and rating - Expert tries to create a `CodeReviewResponse` with this data - Validation fails because the format doesn't match expectations 3. **Response Format Expected**: ```python CodeReviewResponse( review="string review text", suggestions=["suggestion 1", "suggestion 2"], rating=3 ) ``` 4. **Response Format Received**: ```python { "review": {"cleanCodePrinciples": {...}}, "suggestions": [ {"method": "calculateTotal", ...}, {"method": "checkout", ...}, {"method": "addItem", ...} ], "rating": 3 } ``` ## Next Steps 1. **Update Response Parsing**: Modify the Ollama service to correctly parse the JSON responses 2. **Add Error Handling**: Improve error handling in the expert implementations 3. **Format Conversion**: Add logic to convert dictionary objects to strings if needed 4. **Testing**: Create more thorough tests for different edge cases This snapshot represents the current state of the implementation as of the latest debugging session.

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tomsiwik/mcp-experts'

If you have feedback or need assistance with the MCP directory API, please join our Discord server