mcpjam_search_mcp_spec
Search and retrieve specific sections of the MCP specification document, such as 'Tools', 'Resources', or 'Authorization', to access detailed protocol information for development and implementation.
Instructions
Search the MCP specification document for relevant content
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Select a specific section of the MCP specification to retrieve. |
Implementation Reference
- src/index.ts:141-169 (handler)The execute function implements the core logic of the mcpjam_search_mcp_spec tool. It loads the document index, finds the matching section by exact name from args.query, and returns the content as JSON.execute: async (args) => { const fuse = loadAndIndexDocument(); try { if (!fuse) { throw new UserError("Search index not initialized. Please try again."); } // Find exact section match const matchingChunk = documentChunks.find( (chunk) => chunk.section === args.query ); if (!matchingChunk) { return `No section found with the name "${args.query}".`; } return JSON.stringify( { content: matchingChunk.content, }, null, 2 ); } catch (error) { return `Search error: ${ error instanceof Error ? error.message : "Unknown error" }`; } },
- src/index.ts:99-140 (schema)Zod schema defining the input parameters for the tool, specifically an enum of MCP spec section names.parameters: z.object({ query: z .enum([ "Introduction", "Core components", "Connection lifecycle", "Elicitation", "Prompts", "Resources", "Roots", "Sampling", "Tools", "Transports", "Debugging", "Follow logs in real-time", "For Client Developers", "For Server Developers", "Architecture", "Authorization", "Lifecycle", "Security Best Practices", "Transports", "Cancellation", "Ping", "Progress", "Elicitation", "Roots", "Sampling", "Specification", "Overview", "Prompts", "Resources", "Tools", "Completion", "Logging", "Pagination", "Versioning", ]) .describe( "Select a specific section of the MCP specification to retrieve." ), }),
- src/index.ts:96-170 (registration)Registration of the mcpjam_search_mcp_spec tool using FastMCP's addTool method, including name, description, parameters schema, and execute handler.server.addTool({ name: "mcpjam_search_mcp_spec", description: "Search the MCP specification document for relevant content", parameters: z.object({ query: z .enum([ "Introduction", "Core components", "Connection lifecycle", "Elicitation", "Prompts", "Resources", "Roots", "Sampling", "Tools", "Transports", "Debugging", "Follow logs in real-time", "For Client Developers", "For Server Developers", "Architecture", "Authorization", "Lifecycle", "Security Best Practices", "Transports", "Cancellation", "Ping", "Progress", "Elicitation", "Roots", "Sampling", "Specification", "Overview", "Prompts", "Resources", "Tools", "Completion", "Logging", "Pagination", "Versioning", ]) .describe( "Select a specific section of the MCP specification to retrieve." ), }), execute: async (args) => { const fuse = loadAndIndexDocument(); try { if (!fuse) { throw new UserError("Search index not initialized. Please try again."); } // Find exact section match const matchingChunk = documentChunks.find( (chunk) => chunk.section === args.query ); if (!matchingChunk) { return `No section found with the name "${args.query}".`; } return JSON.stringify( { content: matchingChunk.content, }, null, 2 ); } catch (error) { return `Search error: ${ error instanceof Error ? error.message : "Unknown error" }`; } }, });
- src/index.ts:27-94 (helper)Helper function that loads the MCP spec document from llms-full.md, parses it into chunks by sections (H1 headers), indexes with Fuse.js for search, and populates the global documentChunks array.function loadAndIndexDocument(): Fuse<(typeof documentChunks)[0]> | undefined { try { const docPath = join(__dirname, "../src/lib/llms-full.md"); const content = readFileSync(docPath, "utf-8"); const lines = content.split("\n"); let currentSection = "Overview"; let chunkId = 0; let chunkContent = ""; let chunkStartLine = 1; for (let i = 0; i < lines.length; i++) { const line = lines[i]; if (line.match(/^# /)) { if (chunkContent.trim()) { documentChunks.push({ id: chunkId, content: chunkContent.trim(), section: currentSection, line: chunkStartLine, }); chunkId++; } currentSection = line.replace(/^#+\s*/, ""); chunkContent = line + "\n"; chunkStartLine = i + 1; } else { chunkContent += line + "\n"; // Create chunks of reasonable size (~500 lines) if (chunkContent.split("\n").length > 500) { documentChunks.push({ id: chunkId, content: chunkContent.trim(), section: currentSection, line: chunkStartLine, }); chunkId++; chunkContent = ""; chunkStartLine = i + 1; } } } // Add final chunk if (chunkContent.trim()) { documentChunks.push({ id: chunkId, content: chunkContent.trim(), section: currentSection, line: chunkStartLine, }); } // Initialize Fuse.js search fuse = new Fuse(documentChunks, { keys: ["content", "section"], threshold: 0.3, includeScore: true, }); return fuse; } catch (error) { console.error("Failed to load document:", error); } }