You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Cross-Crate Search Schema Bug Fix (RESOLVED)**: Fixed critical schema mismatch where hardcoded incomplete tool schema was replaced with centralized `get_tool_schema()` helper using complete definitions from `mcp_tools_config.py`, enabling full cross-crate search functionality via MCP clients
310
311
311
312
**Tool Migration Status**
312
313
All tools successfully migrated and cleaned up:
313
-
1.`search_items` - Documentation search with embedding similarity
314
+
1.`search_items` - Documentation search with embedding similarity**[Enhanced with cross-crate search support]**
3.`get_crate_summary` - Crate overview and metadata
316
317
4.`compare_versions` - Version difference analysis
@@ -325,6 +326,61 @@ All tools successfully migrated and cleaned up:
325
326
326
327
**Tool Name Cleanup**: Removed duplicate camelCase tool names (`getDocumentationDetail`, `extractUsagePatterns`, `generateLearningPath`) in favor of consistent snake_case Python conventions following Python naming standards.
327
328
329
+
#### Cross-Crate Search MCP Integration Fix
330
+
331
+
**Critical Bug Resolution**: Fixed schema mismatch that prevented cross-crate search functionality via MCP interface while maintaining full REST API compatibility.
332
+
333
+
**Root Cause Analysis**:
334
+
- MCP SDK server hardcoded incomplete `search_items` schema instead of using centralized `MCP_TOOLS_CONFIG` definitions
335
+
-`crates` parameter was missing from MCP tool schema, limiting clients to single-crate searches only
336
+
- Schema inconsistency between MCP interface and REST API functionality
- ✅ Same RRF aggregation and deduplication as REST API implementation
382
+
- ✅ Zero breaking changes for existing MCP client integrations
383
+
328
384
### MCP Resources Implementation
329
385
330
386
The MCP SDK server provides complete resource endpoint support as defined in the MCP protocol:
@@ -2977,6 +3033,17 @@ Three new MCP tools provide external access to WorkflowService capabilities:
2977
3033
2978
3034
## Cross-Crate Search Architecture
2979
3035
3036
+
### MCP Interface Integration (Bug Fix Resolved)
3037
+
3038
+
The cross-crate search functionality is now fully accessible via MCP clients through the resolved schema mismatch bug fix. This critical fix enables MCP clients to perform multi-crate searches with the same RRF aggregation and performance characteristics as the REST API.
3039
+
3040
+
**Key Components**:
3041
+
-**Schema Alignment**: `get_tool_schema()` helper function ensures schema consistency between MCP SDK server and centralized configuration
3042
+
-**Parameter Support**: Full support for `crates` parameter (array type, max 5 items) exposed to MCP clients
3043
+
-**Backward Compatibility**: Single-crate search via `crate_name` parameter maintains exact functionality
3044
+
-**Parameter Precedence**: `crates` parameter overrides `crate_name` when both are provided
3045
+
-**Validation Pipeline**: Comprehensive crate name validation with configurable limits via `DOCSRS_MAX_CRATES` environment variable
3046
+
2980
3047
```mermaid
2981
3048
graph TD
2982
3049
subgraph "Cross-Crate Search Components"
@@ -2985,6 +3052,12 @@ graph TD
2985
3052
RESULT_AGGREGATOR[ResultAggregator<br/>cross-crate result merging<br/>relevance scoring<br/>deduplication]
**Root Cause**: The MCP SDK server hardcoded an incomplete tool schema for `search_items` instead of using the complete schema definitions from `mcp_tools_config.py`, preventing MCP clients from accessing cross-crate search functionality.
3089
+
3090
+
**Technical Resolution**:
3091
+
1.**Schema Helper Function**: Added `get_tool_schema()` helper function with defensive copying
3092
+
2.**Centralized Configuration**: Eliminated hardcoded schema in favor of `MCP_TOOLS_CONFIG` definitions
3093
+
3.**Parameter Exposure**: `crates` parameter now properly exposed to MCP clients as array type
3094
+
4.**Validation Enhancement**: Implemented robust parameter validation with Union[List[str], str, None] support
-**Structured Responses**: Machine-parsable error codes for parameter validation failures
3121
+
-**Comprehensive Validation**: Crate name format, length, and quantity validation
3122
+
-**Clear Messaging**: Explicit error messages for parameter precedence and requirements
3123
+
-**Graceful Degradation**: Maintains backward compatibility for all existing single-crate searches
3124
+
3125
+
**Performance Impact**:
3126
+
-**Zero Overhead**: Schema helper adds <1ms overhead during tool registration
3127
+
-**Same Performance**: Cross-crate search maintains identical RRF aggregation performance as REST API
3128
+
-**5-Crate Limit**: Configurable via `DOCSRS_MAX_CRATES` environment variable for resource management
3129
+
-**Efficient Routing**: Single conditional determines search path with minimal computational cost
3130
+
3009
3131
## Pattern Extraction Workflow
3010
3132
3011
3133
```mermaid
@@ -4396,6 +4518,7 @@ Inconsistent parameter type declarations between `mcp_tools_config.py` (mixed in
4396
4518
- MCP tools configuration defined parameters as `"type": "integer"`, `"type": "boolean"`, `"type": "number"`
4397
4519
- MCP SDK server implementation expected all parameters as strings for broad client compatibility
4398
4520
- Field validators existed with `mode='before'` for proper string-to-type conversion
4521
+
-**Cross-Crate Search Impact**: This same pattern prevented `crates` parameter exposure, resolved by implementing `get_tool_schema()` helper that uses centralized definitions with defensive copying
Copy file name to clipboardExpand all lines: UsefulInformation.json
+33Lines changed: 33 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -4176,6 +4176,39 @@
4176
4176
"codeExample": "def _build_module_tree(self, modules: List[Dict[str, Any]]) -> ModuleTreeNode:\n \"\"\"Transform flat module list to hierarchical tree structure\"\"\"\n if not modules:\n return ModuleTreeNode(name=\"empty\", path=\"\", children=[])\n \n # Build tree from flat list\n tree_builder = TreeBuilder()\n for module in modules:\n tree_builder.add_module(module)\n \n return tree_builder.build_tree()\n\n# Usage in service method:\nmodules = await self.database.get_module_list(crate_name, version)\ntree = self._build_module_tree(modules) # Transform before return\nreturn GetModuleTreeResponse(tree=tree)",
4177
4177
"debuggingTechnique": "Test with 'uv run docsrs-mcp' in development mode and verify endpoint returns hierarchical ModuleTreeNode structure, not flat list",
4178
4178
"architecturalImprovement": "This fix establishes proper separation of concerns where each layer has clear responsibilities and data flows correctly through the transformation pipeline"
4179
+
},
4180
+
{
4181
+
"error": "Cross-Crate Search Cannot Search Across Multiple Crates",
4182
+
"rootCause": "MCP SDK server used hardcoded incomplete schema instead of complete schema from mcp_tools_config.py. The hardcoded schema lacked proper cross-crate search parameters (crates array support), preventing MCP clients from accessing full cross-crate search functionality.",
4183
+
"solution": "Implemented schema alignment by creating centralized get_tool_schema() function that dynamically retrieves complete schemas from mcp_tools_config.py with defensive copying. Added robust parameter validation supporting both array and comma-separated string formats for crates parameter. Established parameter precedence logic (crates overrides crate_name) with comprehensive error handling.",
4184
+
"context": "MCP clients couldn't perform cross-crate searches due to schema mismatch between hardcoded MCP SDK schemas and actual tool configurations. Cross-crate functionality existed in backend but was inaccessible via MCP interface.",
4185
+
"lesson": "Always use centralized schema definitions instead of hardcoding schemas in multiple locations. MCP clients require flexible parameter input formats (arrays + strings) for optimal compatibility. Schema objects need defensive copying to prevent mutations during server operations.",
4186
+
"pattern": "Use centralized schema management with get_tool_schema() pattern for consistent schema exposure across different server modes (MCP SDK, REST). Implement robust union type parameter validation to handle diverse MCP client input formats.",
"codeExample": "# Centralized schema retrieval with defensive copying\ndef get_tool_schema(tool_name: str) -> dict:\n for tool_config in MCP_TOOLS_CONFIG:\n if tool_config[\"name\"] == tool_name:\n return copy.deepcopy(tool_config[\"input_schema\"])\n raise ValueError(f\"Tool {tool_name} not found in config\")\n\n# Schema registration with dynamic schema\ntypes.Tool(\n name=\"search_items\",\n description=\"Search for items in crate documentation with advanced modes\",\n inputSchema=get_tool_schema(\"search_items\"),\n)\n\n# Robust parameter validation for union types\nif isinstance(crates, list):\n crates_list = [c.strip().lower() for c in crates if c and c.strip()]\nelif isinstance(crates, str) and crates.strip():\n crates_list = [c.strip().lower() for c in crates.split(\",\") if c.strip()]\nelse:\n crates_list = []",
4192
+
"debuggingTechnique": "Test both MCP SDK mode (uv run docsrs-mcp) and REST mode (uv run docsrs-mcp --mode rest) to verify schema consistency. Use MCP client restart after schema changes to see updated tool schemas. Test with various parameter formats: arrays, comma-separated strings, and mixed inputs.",
0 commit comments