|
1 | 1 | { |
2 | 2 | "projectName": "docsrs-mcp", |
3 | | - "lastUpdated": "2025-08-13", |
| 3 | + "lastUpdated": "2025-08-15", |
4 | 4 | "purpose": "Track errors, solutions, and lessons learned during development", |
5 | 5 | "categories": { |
6 | 6 | "errorSolutions": { |
|
1606 | 1606 | "debuggingTechnique": "Test with both Claude Code MCP client and REST API to identify client-specific validation differences", |
1607 | 1607 | "bestPractice": "Design MCP schemas for the most restrictive client (Claude Code) and handle complexity in server-side validators. Field validators can handle the complexity that schemas can't.", |
1608 | 1608 | "impact": "Enables full compatibility with Claude Code MCP client while maintaining type safety and validation through Pydantic" |
| 1609 | + }, |
| 1610 | + { |
| 1611 | + "error": "Module structure search results contaminated with internal/dependency modules", |
| 1612 | + "rootCause": "Search results include internal implementation details like std::, core::, deps:: modules that are not relevant to user queries about crate API structure", |
| 1613 | + "solution": "Implement post-processing filters to remove internal and dependency modules from search results. Filter patterns: ['::__', '_internal', 'deps::', 'std::', 'core::'] to focus on public API modules only", |
| 1614 | + "context": "Module structure queries returning too much noise from internal Rust standard library and dependency modules", |
| 1615 | + "lesson": "Search results need post-processing to remove irrelevant internal modules and focus on user-relevant public API surface", |
| 1616 | + "pattern": "Apply filtering patterns after search but before returning results to users", |
| 1617 | + "dateEncountered": "2025-08-13", |
| 1618 | + "relatedFiles": ["src/docsrs_mcp/search.py", "src/docsrs_mcp/filters.py"], |
| 1619 | + "codeExample": "# Filter internal modules from results\nfiltered_modules = [\n module for module in modules \n if not any(pattern in module.path for pattern in \n ['::__', '_internal', 'deps::', 'std::', 'core::'])\n]", |
| 1620 | + "debuggingTechnique": "Compare raw search results with filtered results to verify internal modules are properly excluded", |
| 1621 | + "impact": "Improves search result quality by focusing on relevant public API modules instead of internal implementation details" |
1609 | 1622 | } |
1610 | 1623 | ] |
1611 | 1624 | }, |
|
2387 | 2400 | "booleanPattern": "String to boolean conversion with comprehensive value recognition (true/false, 1/0, yes/no, on/off, t/y)", |
2388 | 2401 | "errorHandling": "Provide sensible defaults for invalid inputs rather than strict validation failures" |
2389 | 2402 | } |
| 2403 | + }, |
| 2404 | + { |
| 2405 | + "error": "MCP client validation compatibility issues with anyOf schema patterns", |
| 2406 | + "rootCause": "Claude Code MCP client cannot handle anyOf JSON schema patterns, causing 'Input validation error: not valid under any of the given schemas' failures despite correct implementation", |
| 2407 | + "solution": "Replace all anyOf patterns with simple string-only schema types in MCP manifest. Use Pydantic field validators with mode='before' for comprehensive type coercion from strings to proper types (int, float, bool). All numeric and boolean parameters now use string type in schema with validation handling the conversion", |
| 2408 | + "context": "MCP parameter validation failing across all tools despite implementing proper anyOf schema patterns for type flexibility", |
| 2409 | + "implementation": [ |
| 2410 | + "Changed all numeric parameters to 'type': 'string' in MCP manifest schema generation", |
| 2411 | + "Changed all boolean parameters to 'type': 'string' in MCP manifest schema generation", |
| 2412 | + "Enhanced field validators to handle string-to-int, string-to-float, and string-to-bool conversion", |
| 2413 | + "Added module filtering in get_crate_summary to reduce noise from internal implementation details", |
| 2414 | + "Maintained all existing validation logic and bounds checking in Pydantic validators" |
| 2415 | + ], |
| 2416 | + "pattern": "Use string-only schemas in MCP manifests combined with robust Pydantic field validators for type coercion. This pattern works around MCP client schema limitations while maintaining server-side type safety", |
| 2417 | + "dateEncountered": "2025-08-15", |
| 2418 | + "relatedFiles": ["src/docsrs_mcp/app.py", "src/docsrs_mcp/models.py"], |
| 2419 | + "codeExample": "# Schema generation - use string only\n\"k\": {\n \"type\": \"string\",\n \"description\": \"Number of results (integer between 1-100)\"\n}\n\n# Field validator handles conversion\n@field_validator('k', mode='before')\n@classmethod\ndef coerce_k(cls, v):\n return coerce_to_int_with_bounds(v, min_val=1, max_val=100)", |
| 2420 | + "lesson": "MCP clients may have stricter schema validation than servers expect. Always test with actual MCP clients, not just REST endpoints. Use simple schema types with complex validation logic rather than complex schemas with simple validation", |
| 2421 | + "preventionPattern": "For MCP compatibility: simple schemas + complex validators > complex schemas + simple validators" |
2390 | 2422 | } |
2391 | 2423 | ] |
2392 | 2424 | }, |
|
2758 | 2790 | "issue": "uvloop not compatible with Windows", |
2759 | 2791 | "impact": "Performance degradation on Windows", |
2760 | 2792 | "workaround": "Fallback to standard asyncio event loop on Windows" |
| 2793 | + }, |
| 2794 | + "claudeCodeMcpCompatibility": { |
| 2795 | + "issue": "Claude Code does NOT support anyOf patterns in MCP schemas unlike Claude Desktop", |
| 2796 | + "impact": "Parameter validation fails when schemas use anyOf patterns for type flexibility", |
| 2797 | + "workaround": "Use string-only parameter types in MCP manifest with Pydantic field validators for coercion", |
| 2798 | + "details": { |
| 2799 | + "root_cause": "Claude Code implements stricter JSON Schema validation that rejects anyOf patterns entirely", |
| 2800 | + "solution_pattern": "Define parameters as type: 'string' in manifest, use @field_validator(mode='before') for type conversion", |
| 2801 | + "affected_tools": "All MCP tools with numeric or boolean parameters that need type flexibility" |
| 2802 | + } |
| 2803 | + }, |
| 2804 | + "versionComparisonErrors": { |
| 2805 | + "issue": "PointerToNowhere errors in version comparison _map_item_type function", |
| 2806 | + "impact": "Version comparison tools fail with null reference errors", |
| 2807 | + "workaround": "Add defensive null checking before accessing item type properties", |
| 2808 | + "details": { |
| 2809 | + "root_cause": "Missing null checks when processing version comparison items", |
| 2810 | + "solution_pattern": "Check if item exists and has required properties before mapping types" |
| 2811 | + } |
| 2812 | + }, |
| 2813 | + "preIngestionValidation": { |
| 2814 | + "issue": "Pre-ingestion tool parameters lack proper anyOf patterns causing HTTP 422 errors", |
| 2815 | + "impact": "Tool parameter validation fails when parameters sent as strings instead of expected types", |
| 2816 | + "workaround": "Update tool schemas to use string types with validators, not anyOf patterns for Claude Code compatibility", |
| 2817 | + "details": { |
| 2818 | + "root_cause": "Claude Code strict schema validation incompatible with anyOf type patterns", |
| 2819 | + "solution_pattern": "Use consistent string-type parameters with runtime type coercion in validators" |
| 2820 | + } |
| 2821 | + }, |
| 2822 | + "moduleStructureNoise": { |
| 2823 | + "issue": "Module structure results include internal/dependency modules creating noise", |
| 2824 | + "impact": "Search results contaminated with irrelevant internal implementation details", |
| 2825 | + "workaround": "Filter internal and dependency modules from search results to focus on public API", |
| 2826 | + "details": { |
| 2827 | + "filter_patterns": ["::__", "_internal", "deps::", "std::", "core::"], |
| 2828 | + "solution_pattern": "Apply post-processing filters to remove non-user-relevant modules from results" |
| 2829 | + } |
2761 | 2830 | } |
2762 | 2831 | }, |
2763 | 2832 | "debuggingTips": { |
|
2770 | 2839 | "Use inline enum definitions instead of $ref for simple value constraints in MCP schemas", |
2771 | 2840 | "Monitor internal progress tracking and expose through health endpoints for user visibility", |
2772 | 2841 | "Test file validation with various case combinations to identify platform-specific issues", |
2773 | | - "Always implement case-insensitive comparison for configuration file validation" |
| 2842 | + "Always implement case-insensitive comparison for configuration file validation", |
| 2843 | + "CRITICAL: Claude Code does NOT support anyOf patterns - use string-only types with validators", |
| 2844 | + "Test tools with both Claude Code and Claude Desktop to identify client-specific compatibility issues", |
| 2845 | + "Add defensive null checking in version comparison functions to prevent PointerToNowhere errors", |
| 2846 | + "Filter internal/dependency modules from search results using pattern matching", |
| 2847 | + "For Claude Code compatibility: avoid anyOf, use string parameters with @field_validator coercion" |
2774 | 2848 | ], |
2775 | 2849 | "vectorSearch": [ |
2776 | 2850 | "Check embedding dimensions match (384 for BAAI/bge-small-en-v1.5)", |
|
0 commit comments