|
| 1 | +# Fine-Tuning the MCP Server for Integrators |
| 2 | + |
| 3 | +This document outlines the enhancements made to optimize the MCP server for integrators and developers building with Juicebox. |
| 4 | + |
| 5 | +## Key Features |
| 6 | + |
| 7 | +### 1. Automatic v5 Filtering for Building Queries |
| 8 | + |
| 9 | +**Query Intent Detection**: The server automatically detects building/integration queries and filters to v5 documentation. |
| 10 | + |
| 11 | +**Trigger Keywords:** |
| 12 | +- `build`, `integrate`, `integration`, `deploy`, `launch` |
| 13 | +- `setup`, `configure`, `implement`, `develop` |
| 14 | +- `code`, `api`, `contract`, `hook` |
| 15 | +- `example`, `tutorial`, `how to`, `getting started` |
| 16 | + |
| 17 | +**Example:** |
| 18 | +```bash |
| 19 | +# Automatically filters to v5 |
| 20 | +curl -X POST https://docs.juicebox.money/api/mcp/search \ |
| 21 | + -d '{"query": "how to deploy a project"}' |
| 22 | + |
| 23 | +# Explicitly requests v5 |
| 24 | +curl -X POST https://docs.juicebox.money/api/mcp/search \ |
| 25 | + -d '{"query": "deploy project", "version": "v5"}' |
| 26 | +``` |
| 27 | + |
| 28 | +### 2. Enhanced Metadata Extraction |
| 29 | + |
| 30 | +Each document is now indexed with: |
| 31 | +- **Document Type**: `build`, `api`, `learn`, `example` |
| 32 | +- **Tags**: Automatic tagging based on content (e.g., `integration`, `hook`, `tutorial`) |
| 33 | +- **Integrator Relevance Score**: 0-10 scale prioritizing integrator-relevant content |
| 34 | + |
| 35 | +**Relevance Scoring:** |
| 36 | +- `dev/v5/build/` → 10 (highest priority) |
| 37 | +- `dev/v5/build/examples/` → 9 |
| 38 | +- `dev/v5/api/` → 8 |
| 39 | +- `dev/v5/` → 5 |
| 40 | +- Other docs → 0 |
| 41 | + |
| 42 | +### 3. Improved Search Ranking |
| 43 | + |
| 44 | +**Search Weights:** |
| 45 | +- Title: 35% (was 40%) |
| 46 | +- Description: 25% (was 30%) |
| 47 | +- Content: 15% (was 20%) |
| 48 | +- Headings: 10% (unchanged) |
| 49 | +- **Tags: 15%** (new - boosts tagged content) |
| 50 | + |
| 51 | +**Re-ranking for Building Queries:** |
| 52 | +- Results are re-ranked by `integratorRelevance` score |
| 53 | +- Build guides and examples are prioritized |
| 54 | +- API documentation gets higher ranking |
| 55 | + |
| 56 | +### 4. Smart Query Routing |
| 57 | + |
| 58 | +The server intelligently routes queries: |
| 59 | + |
| 60 | +| Query Type | Auto-Filter | Priority Boost | |
| 61 | +|------------|-------------|----------------| |
| 62 | +| Building/Integration | v5 only | High (build guides, examples) | |
| 63 | +| API Reference | All versions | Medium (API docs) | |
| 64 | +| Concepts/Learning | All versions | Low (learn docs) | |
| 65 | +| General | All | None | |
| 66 | + |
| 67 | +## Additional Fine-Tuning Suggestions |
| 68 | + |
| 69 | +### 1. Add Code Example Extraction |
| 70 | + |
| 71 | +Extract and index code blocks separately for better code search: |
| 72 | + |
| 73 | +```javascript |
| 74 | +// Extract code blocks |
| 75 | +const codeBlocks = []; |
| 76 | +const codeRegex = /```[\s\S]*?```/g; |
| 77 | +// Index code separately with higher weight for code queries |
| 78 | +``` |
| 79 | + |
| 80 | +### 2. Add Contract Address Indexing |
| 81 | + |
| 82 | +Create a separate index for contract addresses and deployment info: |
| 83 | + |
| 84 | +```javascript |
| 85 | +// Special handling for addresses.md |
| 86 | +if (relativePath.includes("addresses")) { |
| 87 | + // Extract contract names and addresses |
| 88 | + // Make them searchable separately |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +### 3. Add Related Documents |
| 93 | + |
| 94 | +Link related documents in the index: |
| 95 | + |
| 96 | +```javascript |
| 97 | +// Extract "See also" links |
| 98 | +// Link related API docs, examples, and guides |
| 99 | +relatedDocs: extractRelatedLinks(content) |
| 100 | +``` |
| 101 | + |
| 102 | +### 4. Query Expansion |
| 103 | + |
| 104 | +Expand common queries to include synonyms: |
| 105 | + |
| 106 | +```javascript |
| 107 | +const queryExpansions = { |
| 108 | + "deploy": ["launch", "create", "setup"], |
| 109 | + "hook": ["extension", "custom", "plugin"], |
| 110 | + "ruleset": ["funding cycle", "configuration"], |
| 111 | +}; |
| 112 | +``` |
| 113 | + |
| 114 | +### 5. Context-Aware Responses |
| 115 | + |
| 116 | +Return contextual information with results: |
| 117 | + |
| 118 | +```javascript |
| 119 | +// Include related concepts |
| 120 | +// Suggest next steps |
| 121 | +// Highlight code examples |
| 122 | +``` |
| 123 | + |
| 124 | +### 6. Version Comparison Tool |
| 125 | + |
| 126 | +Add a tool to compare differences between versions: |
| 127 | + |
| 128 | +```javascript |
| 129 | +{ |
| 130 | + name: "compare_versions", |
| 131 | + description: "Compare documentation or features between v3, v4, and v5" |
| 132 | +} |
| 133 | +``` |
| 134 | + |
| 135 | +### 7. API Endpoint Discovery |
| 136 | + |
| 137 | +Help integrators find the right API endpoints: |
| 138 | + |
| 139 | +```javascript |
| 140 | +{ |
| 141 | + name: "find_api_endpoint", |
| 142 | + description: "Find API endpoints for a specific task (e.g., 'deploy project', 'add hook')" |
| 143 | +} |
| 144 | +``` |
| 145 | + |
| 146 | +### 8. Code Snippet Extraction |
| 147 | + |
| 148 | +Extract and index code snippets separately: |
| 149 | + |
| 150 | +```javascript |
| 151 | +// Index code examples with language tags |
| 152 | +// Make them searchable with syntax highlighting context |
| 153 | +``` |
| 154 | + |
| 155 | +### 9. Common Patterns Library |
| 156 | + |
| 157 | +Index common integration patterns: |
| 158 | + |
| 159 | +```javascript |
| 160 | +// Tag common patterns: "multisig", "governance", "payments", etc. |
| 161 | +// Create pattern-based search |
| 162 | +``` |
| 163 | + |
| 164 | +### 10. Error Message Mapping |
| 165 | + |
| 166 | +Map common errors to documentation: |
| 167 | + |
| 168 | +```javascript |
| 169 | +// Index error messages and link to troubleshooting docs |
| 170 | +// Help integrators debug issues faster |
| 171 | +``` |
| 172 | + |
| 173 | +## Current Implementation |
| 174 | + |
| 175 | +✅ **Implemented:** |
| 176 | +- Automatic v5 filtering for building queries |
| 177 | +- Enhanced metadata (docType, tags, integratorRelevance) |
| 178 | +- Improved search weights with tag support |
| 179 | +- Re-ranking for integrator-relevant content |
| 180 | + |
| 181 | +🔄 **Recommended Next Steps:** |
| 182 | +1. Extract and index code blocks separately |
| 183 | +2. Add contract address special handling |
| 184 | +3. Implement query expansion |
| 185 | +4. Add related documents linking |
| 186 | +5. Create pattern-based search |
| 187 | + |
| 188 | +## Testing |
| 189 | + |
| 190 | +Test the improvements: |
| 191 | + |
| 192 | +```bash |
| 193 | +# Building query (auto-filters to v5) |
| 194 | +curl -X POST https://docs.juicebox.money/api/mcp/search \ |
| 195 | + -d '{"query": "how to deploy a project"}' |
| 196 | + |
| 197 | +# Should return only v5 docs, prioritized by integrator relevance |
| 198 | +``` |
0 commit comments