docusaurus-plugin-mcp-server 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/search/flexsearch-indexer.ts","../../src/mcp/tools/docs-search.ts","../../src/mcp/tools/docs-get-page.ts","../../src/processing/heading-extractor.ts","../../src/mcp/tools/docs-get-section.ts","../../src/mcp/server.ts","../../src/cli/verify.ts"],"names":["FlexSearch","results","lines","McpServer","z","fs","StreamableHTTPServerTransport","WebStandardStreamableHTTPServerTransport","path"],"mappings":";;;;;;;;;;;;;;;;;AAUA,IAAM,aAAA,GAAgB;AAAA,EACpB,KAAA,EAAO,CAAA;AAAA,EACP,QAAA,EAAU,CAAA;AAAA,EACV,WAAA,EAAa,GAAA;AAAA,EACb,OAAA,EAAS;AACX,CAAA;AAMA,SAAS,eAAe,IAAA,EAAsB;AAE5C,EAAA,IAAI,IAAA,CAAK,MAAA,IAAU,CAAA,EAAG,OAAO,IAAA;AAE7B,EAAA,OACE,KAEG,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA,CAElB,QAAQ,OAAA,EAAS,GAAG,CAAA,CACpB,OAAA,CAAQ,SAAS,GAAG,CAAA,CAEpB,QAAQ,eAAA,EAAiB,IAAI,EAE7B,OAAA,CAAQ,eAAA,EAAiB,IAAI,CAAA,CAE7B,QAAQ,KAAA,EAAO,EAAE,EAEjB,OAAA,CAAQ,OAAA,EAAS,EAAE,CAAA,CAEnB,OAAA,CAAQ,OAAA,EAAS,EAAE,EAEnB,OAAA,CAAQ,MAAA,EAAQ,GAAG,CAAA,CAEnB,OAAA,CAAQ,YAAY,IAAI,CAAA;AAE/B;AAWO,SAAS,iBAAA,GAAwC;AACtD,EAAA,OAAO,IAAIA,4BAAW,QAAA,CAAsC;AAAA;AAAA;AAAA,IAG1D,QAAA,EAAU,MAAA;AAAA;AAAA,IAGV,KAAA,EAAO,GAAA;AAAA;AAAA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EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAChB;AAEA,IAAA,EAAK,CAAE,KAAA,CAAM,CAAC,KAAA,KAAU;AACtB,EAAA,OAAA,CAAQ,KAAA,CAAM,qBAAqB,KAAK,CAAA;AACxC,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAChB,CAAC,CAAA","file":"verify.js","sourcesContent":["import FlexSearch from 'flexsearch';\nimport type { ProcessedDoc, SearchResult } from '../types/index.js';\nimport type { IndexableDocument } from './types.js';\n\nexport type FlexSearchDocument = FlexSearch.Document<IndexableDocument, string[]>;\n\n/**\n * Field weights for search ranking\n * Higher values = more importance\n */\nconst FIELD_WEIGHTS = {\n title: 3.0,\n headings: 2.0,\n description: 1.5,\n content: 1.0,\n} as const;\n\n/**\n * Simple English stemmer\n * Handles common suffixes for better matching\n */\nfunction englishStemmer(word: string): string {\n // Only process words longer than 3 characters\n if (word.length <= 3) return word;\n\n return (\n word\n // -ing endings\n .replace(/ing$/, '')\n // -tion, -sion endings -> t, s\n .replace(/tion$/, 't')\n .replace(/sion$/, 's')\n // -ed endings (careful with short words)\n .replace(/([^aeiou])ed$/, '$1')\n // -es endings\n .replace(/([^aeiou])es$/, '$1')\n // -ly endings\n .replace(/ly$/, '')\n // -ment endings\n .replace(/ment$/, '')\n // -ness endings\n .replace(/ness$/, '')\n // -ies -> y\n .replace(/ies$/, 'y')\n // -s endings (simple plural)\n .replace(/([^s])s$/, '$1')\n );\n}\n\n/**\n * Create a FlexSearch document index with enhanced configuration\n *\n * Features:\n * - Full substring matching (finds \"auth\" in \"authentication\")\n * - English stemming (finds \"authenticate\" when searching \"authentication\")\n * - Context-aware scoring for phrase matching\n * - Optimized resolution for relevance ranking\n */\nexport function createSearchIndex(): FlexSearchDocument {\n return new FlexSearch.Document<IndexableDocument, string[]>({\n // Use 'full' tokenization for substring matching\n // This allows \"auth\" to match \"authentication\"\n tokenize: 'full',\n\n // Enable caching for faster repeated queries\n cache: 100,\n\n // Higher resolution = more granular ranking (1-9)\n resolution: 9,\n\n // Enable context for phrase/proximity matching\n context: {\n resolution: 2,\n depth: 2,\n bidirectional: true,\n },\n\n // Apply stemming to normalize word forms\n encode: (str: string) => {\n // Normalize to lowercase and split into words\n const words = str.toLowerCase().split(/[\\s\\-_.,;:!?'\"()[\\]{}]+/);\n // Apply stemmer to each word\n return words.filter(Boolean).map(englishStemmer);\n },\n\n // Document schema\n document: {\n id: 'id',\n // Index these fields for searching\n index: ['title', 'content', 'headings', 'description'],\n // Store these fields in results (for enriched queries)\n store: ['title', 'description'],\n },\n });\n}\n\n/**\n * Add a document to the search index\n */\nexport function addDocumentToIndex(index: FlexSearchDocument, doc: ProcessedDoc): void {\n const indexable: IndexableDocument = {\n id: doc.route,\n title: doc.title,\n content: doc.markdown,\n headings: doc.headings.map((h) => h.text).join(' '),\n description: doc.description,\n };\n\n index.add(indexable);\n}\n\n/**\n * Build the search index from processed documents\n */\nexport function buildSearchIndex(docs: ProcessedDoc[]): FlexSearchDocument {\n const index = createSearchIndex();\n\n for (const doc of docs) {\n addDocumentToIndex(index, doc);\n }\n\n return index;\n}\n\n/**\n * Search the index and return results with weighted ranking\n *\n * Ranking combines:\n * - Field importance (title > headings > description > content)\n * - Position in results (earlier = more relevant)\n */\nexport function searchIndex(\n index: FlexSearchDocument,\n docs: Record<string, ProcessedDoc>,\n query: string,\n options: { limit?: number } = {}\n): SearchResult[] {\n const { limit = 5 } = options;\n\n // Search across all fields\n const rawResults = index.search(query, {\n limit: limit * 3, // Get extra results for better ranking after weighting\n enrich: true,\n });\n\n // Aggregate scores across fields with weighting\n const docScores = new Map<string, number>();\n\n for (const fieldResult of rawResults) {\n // Determine which field this result is from\n const field = fieldResult.field as keyof typeof FIELD_WEIGHTS;\n const fieldWeight = FIELD_WEIGHTS[field] ?? 1.0;\n\n // With enrich: true, results are objects with id property\n const results = fieldResult.result as unknown as Array<{ id: string } | string>;\n\n for (let i = 0; i < results.length; i++) {\n const item = results[i];\n if (!item) continue;\n\n const docId = typeof item === 'string' ? item : item.id;\n\n // Position-based score (earlier = higher)\n const positionScore = (results.length - i) / results.length;\n\n // Apply field weight to position score\n const weightedScore = positionScore * fieldWeight;\n\n // Combine with existing score (additive for multi-field matches)\n const existingScore = docScores.get(docId) ?? 0;\n docScores.set(docId, existingScore + weightedScore);\n }\n }\n\n // Build results array\n const results: SearchResult[] = [];\n\n for (const [docId, score] of docScores) {\n const doc = docs[docId];\n if (!doc) continue;\n\n results.push({\n route: doc.route,\n title: doc.title,\n score,\n snippet: generateSnippet(doc.markdown, query),\n matchingHeadings: findMatchingHeadings(doc, query),\n });\n }\n\n // Sort by score (highest first) and limit\n results.sort((a, b) => b.score - a.score);\n return results.slice(0, limit);\n}\n\n/**\n * Generate a snippet from the markdown content around the query terms\n */\nexport function generateSnippet(markdown: string, query: string): string {\n const maxLength = 200;\n const queryTerms = query.toLowerCase().split(/\\s+/).filter(Boolean);\n\n if (queryTerms.length === 0) {\n return markdown.slice(0, maxLength) + (markdown.length > maxLength ? '...' : '');\n }\n\n const lowerMarkdown = markdown.toLowerCase();\n let bestIndex = -1;\n let bestTerm = '';\n\n // Also try stemmed versions of query terms\n const allTerms = [...queryTerms, ...queryTerms.map(englishStemmer)];\n\n for (const term of allTerms) {\n const index = lowerMarkdown.indexOf(term);\n if (index !== -1 && (bestIndex === -1 || index < bestIndex)) {\n bestIndex = index;\n bestTerm = term;\n }\n }\n\n if (bestIndex === -1) {\n // No term found, return beginning of document\n return markdown.slice(0, maxLength) + (markdown.length > maxLength ? '...' : '');\n }\n\n const snippetStart = Math.max(0, bestIndex - 50);\n const snippetEnd = Math.min(markdown.length, bestIndex + bestTerm.length + 150);\n\n let snippet = markdown.slice(snippetStart, snippetEnd);\n\n snippet = snippet\n // Remove markdown headings\n .replace(/^#{1,6}\\s+/gm, '')\n // Remove markdown links but keep text\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, '$1')\n // Remove markdown images\n .replace(/!\\[([^\\]]*)\\]\\([^)]+\\)/g, '')\n // Remove code block markers\n .replace(/```[a-z]*\\n?/g, '')\n // Remove inline code backticks\n .replace(/`([^`]+)`/g, '$1')\n // Clean up whitespace\n .replace(/\\s+/g, ' ')\n .trim();\n\n const prefix = snippetStart > 0 ? '...' : '';\n const suffix = snippetEnd < markdown.length ? '...' : '';\n\n return prefix + snippet + suffix;\n}\n\n/**\n * Find headings that match the query (including stemmed forms)\n */\nfunction findMatchingHeadings(doc: ProcessedDoc, query: string): string[] {\n const queryTerms = query.toLowerCase().split(/\\s+/).filter(Boolean);\n // Include stemmed versions for better matching\n const allTerms = [...queryTerms, ...queryTerms.map(englishStemmer)];\n const matching: string[] = [];\n\n for (const heading of doc.headings) {\n const headingLower = heading.text.toLowerCase();\n const headingStemmed = headingLower.split(/\\s+/).map(englishStemmer).join(' ');\n\n // Check if any query term matches the heading or its stemmed form\n if (\n allTerms.some(\n (term) => headingLower.includes(term) || headingStemmed.includes(englishStemmer(term))\n )\n ) {\n matching.push(heading.text);\n }\n }\n\n return matching.slice(0, 3); // Limit to 3 matching headings\n}\n\n/**\n * Export the search index to a serializable format\n */\nexport async function exportSearchIndex(index: FlexSearchDocument): Promise<unknown> {\n const exportData: Record<string, unknown> = {};\n\n await index.export((key, data) => {\n exportData[key as string] = data;\n });\n\n return exportData;\n}\n\n/**\n * Import a search index from serialized data\n */\nexport async function importSearchIndex(\n data: Record<string, unknown>\n): Promise<FlexSearchDocument> {\n const index = createSearchIndex();\n\n for (const [key, value] of Object.entries(data)) {\n // FlexSearch's import expects the data in a specific format\n await (index as unknown as { import: (key: string, data: unknown) => Promise<void> }).import(\n key,\n value\n );\n }\n\n return index;\n}\n","import type { ProcessedDoc, SearchResult, DocsSearchParams } from '../../types/index.js';\nimport { searchIndex, type FlexSearchDocument } from '../../search/flexsearch-indexer.js';\n\n/**\n * Tool definition for docs_search\n */\nexport const docsSearchTool = {\n name: 'docs_search',\n description:\n 'Search across developer documentation. Returns ranked results with snippets and matching headings.',\n inputSchema: {\n type: 'object' as const,\n properties: {\n query: {\n type: 'string',\n description: 'Search query string',\n },\n limit: {\n type: 'number',\n description: 'Maximum number of results to return (default: 5, max: 20)',\n default: 5,\n },\n },\n required: ['query'],\n },\n};\n\n/**\n * Execute the docs_search tool\n */\nexport function executeDocsSearch(\n params: DocsSearchParams,\n index: FlexSearchDocument,\n docs: Record<string, ProcessedDoc>\n): SearchResult[] {\n const { query, limit = 5 } = params;\n\n // Validate parameters\n if (!query || typeof query !== 'string' || query.trim().length === 0) {\n throw new Error('Query parameter is required and must be a non-empty string');\n }\n\n const effectiveLimit = Math.min(Math.max(1, limit), 20);\n\n // Search the index\n const results = searchIndex(index, docs, query.trim(), {\n limit: effectiveLimit,\n });\n\n return results;\n}\n\n/**\n * Format search results for MCP response\n */\nexport function formatSearchResults(results: SearchResult[], baseUrl?: string): string {\n if (results.length === 0) {\n return 'No matching documents found.';\n }\n\n const lines: string[] = [`Found ${results.length} result(s):\\n`];\n\n for (let i = 0; i < results.length; i++) {\n const result = results[i];\n if (!result) continue;\n\n lines.push(`${i + 1}. **${result.title}**`);\n\n // Include full URL if baseUrl is provided\n if (baseUrl) {\n const fullUrl = `${baseUrl.replace(/\\/$/, '')}${result.route}`;\n lines.push(` URL: ${fullUrl}`);\n }\n\n lines.push(` Route: ${result.route}`);\n\n if (result.matchingHeadings && result.matchingHeadings.length > 0) {\n lines.push(` Matching sections: ${result.matchingHeadings.join(', ')}`);\n }\n\n lines.push(` ${result.snippet}`);\n lines.push('');\n }\n\n return lines.join('\\n');\n}\n","import type { ProcessedDoc, DocsGetPageParams } from '../../types/index.js';\n\n/**\n * Tool definition for docs_get_page\n */\nexport const docsGetPageTool = {\n name: 'docs_get_page',\n description:\n 'Retrieve the full content of a documentation page as markdown. Use this after searching to get complete page content.',\n inputSchema: {\n type: 'object' as const,\n properties: {\n route: {\n type: 'string',\n description: 'The route path of the page (e.g., /docs/getting-started)',\n },\n },\n required: ['route'],\n },\n};\n\n/**\n * Execute the docs_get_page tool\n */\nexport function executeDocsGetPage(\n params: DocsGetPageParams,\n docs: Record<string, ProcessedDoc>\n): ProcessedDoc | null {\n const { route } = params;\n\n // Validate parameters\n if (!route || typeof route !== 'string') {\n throw new Error('Route parameter is required and must be a string');\n }\n\n // Normalize route (ensure leading slash, remove trailing slash)\n let normalizedRoute = route.trim();\n if (!normalizedRoute.startsWith('/')) {\n normalizedRoute = '/' + normalizedRoute;\n }\n if (normalizedRoute.length > 1 && normalizedRoute.endsWith('/')) {\n normalizedRoute = normalizedRoute.slice(0, -1);\n }\n\n // Look up the document\n const doc = docs[normalizedRoute];\n\n if (!doc) {\n // Try without leading slash\n const altRoute = normalizedRoute.slice(1);\n if (docs[altRoute]) {\n return docs[altRoute] ?? null;\n }\n return null;\n }\n\n return doc;\n}\n\n/**\n * Format page content for MCP response\n */\nexport function formatPageContent(doc: ProcessedDoc | null, baseUrl?: string): string {\n if (!doc) {\n return 'Page not found. Please check the route path and try again.';\n }\n\n const lines: string[] = [];\n\n // Header\n lines.push(`# ${doc.title}`);\n lines.push('');\n\n // Metadata\n if (doc.description) {\n lines.push(`> ${doc.description}`);\n lines.push('');\n }\n\n // Include full URL if baseUrl is provided\n if (baseUrl) {\n const fullUrl = `${baseUrl.replace(/\\/$/, '')}${doc.route}`;\n lines.push(`**URL:** ${fullUrl}`);\n }\n\n lines.push(`**Route:** ${doc.route}`);\n lines.push('');\n\n // Table of contents (if there are headings)\n if (doc.headings.length > 0) {\n lines.push('## Contents');\n lines.push('');\n for (const heading of doc.headings) {\n if (heading.level <= 3) {\n const indent = ' '.repeat(heading.level - 1);\n lines.push(`${indent}- [${heading.text}](#${heading.id})`);\n }\n }\n lines.push('');\n lines.push('---');\n lines.push('');\n }\n\n // Main content\n lines.push(doc.markdown);\n\n return lines.join('\\n');\n}\n","import type { DocHeading } from '../types/index.js';\n\n/**\n * Extract headings from markdown content with their positions\n */\nexport function extractHeadingsFromMarkdown(markdown: string): DocHeading[] {\n const headings: DocHeading[] = [];\n const lines = markdown.split('\\n');\n let currentOffset = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i] ?? '';\n const headingMatch = line.match(/^(#{1,6})\\s+(.+?)(?:\\s+\\{#([^}]+)\\})?$/);\n\n if (headingMatch) {\n const hashes = headingMatch[1] ?? '';\n const level = hashes.length;\n let text = headingMatch[2] ?? '';\n let id = headingMatch[3] ?? '';\n\n // If no explicit ID, generate one from text (Docusaurus style)\n if (!id) {\n id = generateHeadingId(text);\n }\n\n // Clean up text (remove any remaining markdown formatting)\n text = text.replace(/\\*\\*([^*]+)\\*\\*/g, '$1'); // Remove bold\n text = text.replace(/_([^_]+)_/g, '$1'); // Remove italic\n text = text.replace(/`([^`]+)`/g, '$1'); // Remove code\n\n headings.push({\n level,\n text: text.trim(),\n id,\n startOffset: currentOffset,\n endOffset: -1, // Will be calculated below\n });\n }\n\n currentOffset += line.length + 1; // +1 for newline\n }\n\n // Calculate end offsets (each heading ends where the next same-or-higher level heading starts)\n for (let i = 0; i < headings.length; i++) {\n const current = headings[i];\n if (!current) continue;\n\n let endOffset = markdown.length;\n\n // Find the next heading at the same or higher level\n for (let j = i + 1; j < headings.length; j++) {\n const next = headings[j];\n if (next && next.level <= current.level) {\n endOffset = next.startOffset;\n break;\n }\n }\n\n current.endOffset = endOffset;\n }\n\n return headings;\n}\n\n/**\n * Generate a URL-safe heading ID (Docusaurus style)\n */\nexport function generateHeadingId(text: string): string {\n return (\n text\n .toLowerCase()\n // Remove any non-alphanumeric characters except spaces and hyphens\n .replace(/[^\\w\\s-]/g, '')\n // Replace spaces with hyphens\n .replace(/\\s+/g, '-')\n // Remove consecutive hyphens\n .replace(/-+/g, '-')\n // Remove leading/trailing hyphens\n .replace(/^-|-$/g, '')\n );\n}\n\n/**\n * Extract a specific section from markdown by heading ID\n */\nexport function extractSection(\n markdown: string,\n headingId: string,\n headings: DocHeading[]\n): string | null {\n const heading = headings.find((h) => h.id === headingId);\n\n if (!heading) {\n return null;\n }\n\n return markdown.slice(heading.startOffset, heading.endOffset).trim();\n}\n","import type { ProcessedDoc, DocsGetSectionParams } from '../../types/index.js';\nimport { extractSection } from '../../processing/heading-extractor.js';\n\n/**\n * Tool definition for docs_get_section\n */\nexport const docsGetSectionTool = {\n name: 'docs_get_section',\n description:\n 'Retrieve a specific section of a documentation page by heading ID. Use this to get focused content from a larger page.',\n inputSchema: {\n type: 'object' as const,\n properties: {\n route: {\n type: 'string',\n description: 'The route path of the page (e.g., /docs/getting-started)',\n },\n headingId: {\n type: 'string',\n description: 'The ID of the heading to retrieve (e.g., authentication)',\n },\n },\n required: ['route', 'headingId'],\n },\n};\n\n/**\n * Result of executing docs_get_section\n */\nexport interface SectionResult {\n /** The section content as markdown */\n content: string | null;\n /** The document the section belongs to */\n doc: ProcessedDoc | null;\n /** The heading text */\n headingText: string | null;\n /** Available headings in the document */\n availableHeadings: Array<{ id: string; text: string; level: number }>;\n}\n\n/**\n * Execute the docs_get_section tool\n */\nexport function executeDocsGetSection(\n params: DocsGetSectionParams,\n docs: Record<string, ProcessedDoc>\n): SectionResult {\n const { route, headingId } = params;\n\n // Validate parameters\n if (!route || typeof route !== 'string') {\n throw new Error('Route parameter is required and must be a string');\n }\n if (!headingId || typeof headingId !== 'string') {\n throw new Error('HeadingId parameter is required and must be a string');\n }\n\n // Normalize route\n let normalizedRoute = route.trim();\n if (!normalizedRoute.startsWith('/')) {\n normalizedRoute = '/' + normalizedRoute;\n }\n if (normalizedRoute.length > 1 && normalizedRoute.endsWith('/')) {\n normalizedRoute = normalizedRoute.slice(0, -1);\n }\n\n // Look up the document\n const doc = docs[normalizedRoute];\n\n if (!doc) {\n return {\n content: null,\n doc: null,\n headingText: null,\n availableHeadings: [],\n };\n }\n\n // Get available headings\n const availableHeadings = doc.headings.map((h) => ({\n id: h.id,\n text: h.text,\n level: h.level,\n }));\n\n // Find the heading\n const heading = doc.headings.find((h) => h.id === headingId.trim());\n\n if (!heading) {\n return {\n content: null,\n doc,\n headingText: null,\n availableHeadings,\n };\n }\n\n // Extract the section content\n const content = extractSection(doc.markdown, headingId.trim(), doc.headings);\n\n return {\n content,\n doc,\n headingText: heading.text,\n availableHeadings,\n };\n}\n\n/**\n * Format section content for MCP response\n */\nexport function formatSectionContent(\n result: SectionResult,\n headingId: string,\n baseUrl?: string\n): string {\n if (!result.doc) {\n return 'Page not found. Please check the route path and try again.';\n }\n\n if (!result.content) {\n const lines = [`Section \"${headingId}\" not found in this document.`, '', 'Available sections:'];\n\n for (const heading of result.availableHeadings) {\n const indent = ' '.repeat(heading.level - 1);\n lines.push(`${indent}- ${heading.text} (id: ${heading.id})`);\n }\n\n return lines.join('\\n');\n }\n\n const lines: string[] = [];\n\n // Build URL with anchor if baseUrl is provided\n const fullUrl = baseUrl ? `${baseUrl.replace(/\\/$/, '')}${result.doc.route}#${headingId}` : null;\n\n // Header\n lines.push(`# ${result.headingText}`);\n if (fullUrl) {\n lines.push(`> From: ${result.doc.title} - ${fullUrl}`);\n } else {\n lines.push(`> From: ${result.doc.title} (${result.doc.route})`);\n }\n lines.push('');\n lines.push('---');\n lines.push('');\n\n // Section content\n lines.push(result.content);\n\n return lines.join('\\n');\n}\n","import fs from 'fs-extra';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\nimport { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';\nimport { z } from 'zod';\nimport type { IncomingMessage, ServerResponse } from 'node:http';\nimport type {\n ProcessedDoc,\n McpServerConfig,\n McpServerFileConfig,\n McpServerDataConfig,\n} from '../types/index.js';\nimport { importSearchIndex, type FlexSearchDocument } from '../search/flexsearch-indexer.js';\nimport { executeDocsSearch, formatSearchResults } from './tools/docs-search.js';\nimport { executeDocsGetPage, formatPageContent } from './tools/docs-get-page.js';\nimport { executeDocsGetSection, formatSectionContent } from './tools/docs-get-section.js';\n\n/**\n * Type guard to check if config uses file-based loading\n */\nfunction isFileConfig(config: McpServerConfig): config is McpServerFileConfig {\n return 'docsPath' in config && 'indexPath' in config;\n}\n\n/**\n * Type guard to check if config uses pre-loaded data\n */\nfunction isDataConfig(config: McpServerConfig): config is McpServerDataConfig {\n return 'docs' in config && 'searchIndexData' in config;\n}\n\n/**\n * MCP Server for documentation\n *\n * This class provides the MCP server implementation that can be used\n * with any HTTP framework (Express, Vercel, Cloudflare Workers, etc.)\n *\n * Supports two modes:\n * - File-based: Load docs and search index from filesystem (Node.js)\n * - Pre-loaded: Accept docs and search index data directly (Workers)\n *\n * Uses the official MCP SDK for proper protocol handling.\n */\nexport class McpDocsServer {\n private config: McpServerConfig;\n private docs: Record<string, ProcessedDoc> | null = null;\n private searchIndex: FlexSearchDocument | null = null;\n private mcpServer: McpServer;\n private initialized = false;\n\n constructor(config: McpServerConfig) {\n this.config = config;\n\n // Create MCP server using the high-level API\n this.mcpServer = new McpServer(\n {\n name: config.name,\n version: config.version ?? '1.0.0',\n },\n {\n capabilities: {\n tools: {},\n },\n }\n );\n\n this.registerTools();\n }\n\n /**\n * Register all MCP tools using the SDK's registerTool API\n */\n private registerTools(): void {\n // docs_search - Search across documentation\n this.mcpServer.registerTool(\n 'docs_search',\n {\n description:\n 'Search the documentation for relevant pages. Returns matching documents with snippets and relevance scores. Use this to find information across all documentation.',\n inputSchema: {\n query: z.string().min(1).describe('The search query string'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(20)\n .optional()\n .default(5)\n .describe('Maximum number of results to return (1-20, default: 5)'),\n },\n },\n async ({ query, limit }) => {\n await this.initialize();\n\n if (!this.docs || !this.searchIndex) {\n return {\n content: [{ type: 'text' as const, text: 'Server not initialized. Please try again.' }],\n isError: true,\n };\n }\n\n const results = executeDocsSearch({ query, limit }, this.searchIndex, this.docs);\n return {\n content: [\n { type: 'text' as const, text: formatSearchResults(results, this.config.baseUrl) },\n ],\n };\n }\n );\n\n // docs_get_page - Retrieve full page content\n this.mcpServer.registerTool(\n 'docs_get_page',\n {\n description:\n 'Retrieve the complete content of a documentation page as markdown. Use this when you need the full content of a specific page.',\n inputSchema: {\n route: z\n .string()\n .min(1)\n .describe('The page route path (e.g., \"/docs/getting-started\" or \"/api/reference\")'),\n },\n },\n async ({ route }) => {\n await this.initialize();\n\n if (!this.docs) {\n return {\n content: [{ type: 'text' as const, text: 'Server not initialized. Please try again.' }],\n isError: true,\n };\n }\n\n const doc = executeDocsGetPage({ route }, this.docs);\n return {\n content: [{ type: 'text' as const, text: formatPageContent(doc, this.config.baseUrl) }],\n };\n }\n );\n\n // docs_get_section - Retrieve a specific section\n this.mcpServer.registerTool(\n 'docs_get_section',\n {\n description:\n 'Retrieve a specific section from a documentation page by its heading ID. Use this when you need only a portion of a page rather than the entire content.',\n inputSchema: {\n route: z.string().min(1).describe('The page route path'),\n headingId: z\n .string()\n .min(1)\n .describe(\n 'The heading ID of the section to extract (e.g., \"installation\", \"api-reference\")'\n ),\n },\n },\n async ({ route, headingId }) => {\n await this.initialize();\n\n if (!this.docs) {\n return {\n content: [{ type: 'text' as const, text: 'Server not initialized. Please try again.' }],\n isError: true,\n };\n }\n\n const result = executeDocsGetSection({ route, headingId }, this.docs);\n return {\n content: [\n {\n type: 'text' as const,\n text: formatSectionContent(result, headingId, this.config.baseUrl),\n },\n ],\n };\n }\n );\n }\n\n /**\n * Load docs and search index\n *\n * For file-based config: reads from disk\n * For data config: uses pre-loaded data directly\n */\n async initialize(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n try {\n if (isDataConfig(this.config)) {\n // Pre-loaded data mode (Cloudflare Workers, etc.)\n this.docs = this.config.docs;\n this.searchIndex = await importSearchIndex(this.config.searchIndexData);\n } else if (isFileConfig(this.config)) {\n // File-based mode (Node.js)\n if (await fs.pathExists(this.config.docsPath)) {\n this.docs = await fs.readJson(this.config.docsPath);\n } else {\n throw new Error(`Docs file not found: ${this.config.docsPath}`);\n }\n\n if (await fs.pathExists(this.config.indexPath)) {\n const indexData = await fs.readJson(this.config.indexPath);\n this.searchIndex = await importSearchIndex(indexData);\n } else {\n throw new Error(`Search index not found: ${this.config.indexPath}`);\n }\n } else {\n throw new Error('Invalid server config: must provide either file paths or pre-loaded data');\n }\n\n this.initialized = true;\n } catch (error) {\n console.error('[MCP] Failed to initialize:', error);\n throw error;\n }\n }\n\n /**\n * Handle an HTTP request using the MCP SDK's transport\n *\n * This method is designed for serverless environments (Vercel, Netlify).\n * It creates a stateless transport instance and processes the request.\n *\n * @param req - Node.js IncomingMessage or compatible request object\n * @param res - Node.js ServerResponse or compatible response object\n * @param parsedBody - Optional pre-parsed request body\n */\n async handleHttpRequest(\n req: IncomingMessage,\n res: ServerResponse,\n parsedBody?: unknown\n ): Promise<void> {\n await this.initialize();\n\n // Create a stateless transport for this request\n // enableJsonResponse: true means we get simple JSON responses instead of SSE\n const transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: undefined, // Stateless mode - no session tracking\n enableJsonResponse: true, // Return JSON instead of SSE streams\n });\n\n // Connect the server to this transport\n await this.mcpServer.connect(transport);\n\n try {\n // Let the transport handle the request\n await transport.handleRequest(req, res, parsedBody);\n } finally {\n // Clean up the transport after request\n await transport.close();\n }\n }\n\n /**\n * Handle a Web Standard Request (Cloudflare Workers, Deno, Bun)\n *\n * This method is designed for Web Standard environments that use\n * the Fetch API Request/Response pattern.\n *\n * @param request - Web Standard Request object\n * @returns Web Standard Response object\n */\n async handleWebRequest(request: Request): Promise<Response> {\n await this.initialize();\n\n // Create a stateless transport for Web Standards\n const transport = new WebStandardStreamableHTTPServerTransport({\n sessionIdGenerator: undefined, // Stateless mode\n enableJsonResponse: true,\n });\n\n // Connect the server to this transport\n await this.mcpServer.connect(transport);\n\n try {\n // Let the transport handle the request and return the response\n return await transport.handleRequest(request);\n } finally {\n // Clean up the transport after request\n await transport.close();\n }\n }\n\n /**\n * Get server status information\n *\n * Useful for health checks and debugging\n */\n async getStatus(): Promise<{\n name: string;\n version: string;\n initialized: boolean;\n docCount: number;\n baseUrl?: string;\n }> {\n return {\n name: this.config.name,\n version: this.config.version ?? '1.0.0',\n initialized: this.initialized,\n docCount: this.docs ? Object.keys(this.docs).length : 0,\n baseUrl: this.config.baseUrl,\n };\n }\n\n /**\n * Get the underlying McpServer instance\n *\n * Useful for advanced use cases like custom transports\n */\n getMcpServer(): McpServer {\n return this.mcpServer;\n }\n}\n","#!/usr/bin/env node\n/**\n * MCP Verification CLI\n *\n * Verifies that the MCP build output is valid and the server works correctly.\n *\n * Usage:\n * npx docusaurus-mcp-verify [buildDir]\n *\n * Options:\n * buildDir Path to Docusaurus build output (default: ./build)\n */\n\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { McpDocsServer } from '../mcp/server.js';\n\ninterface VerifyResult {\n success: boolean;\n docsFound: number;\n errors: string[];\n warnings: string[];\n}\n\n/**\n * Verify the MCP build output\n */\nasync function verifyBuild(buildDir: string): Promise<VerifyResult> {\n const result: VerifyResult = {\n success: true,\n docsFound: 0,\n errors: [],\n warnings: [],\n };\n\n const mcpDir = path.join(buildDir, 'mcp');\n\n // Check if MCP directory exists\n if (!(await fs.pathExists(mcpDir))) {\n result.errors.push(`MCP directory not found: ${mcpDir}`);\n result.errors.push('Did you run \"npm run build\" with the MCP plugin configured?');\n result.success = false;\n return result;\n }\n\n // Check required files\n const requiredFiles = ['docs.json', 'search-index.json', 'manifest.json'];\n\n for (const file of requiredFiles) {\n const filePath = path.join(mcpDir, file);\n if (!(await fs.pathExists(filePath))) {\n result.errors.push(`Required file missing: ${filePath}`);\n result.success = false;\n }\n }\n\n if (!result.success) {\n return result;\n }\n\n // Validate docs.json\n try {\n const docsPath = path.join(mcpDir, 'docs.json');\n const docs = await fs.readJson(docsPath);\n\n if (typeof docs !== 'object' || docs === null) {\n result.errors.push('docs.json is not a valid object');\n result.success = false;\n } else {\n result.docsFound = Object.keys(docs).length;\n\n if (result.docsFound === 0) {\n result.warnings.push('docs.json contains no documents');\n }\n\n // Validate document structure\n for (const [route, doc] of Object.entries(docs)) {\n const d = doc as Record<string, unknown>;\n if (!d.title || typeof d.title !== 'string') {\n result.warnings.push(`Document ${route} is missing a title`);\n }\n if (!d.markdown || typeof d.markdown !== 'string') {\n result.warnings.push(`Document ${route} is missing markdown content`);\n }\n }\n }\n } catch (error) {\n result.errors.push(`Failed to parse docs.json: ${(error as Error).message}`);\n result.success = false;\n }\n\n // Validate search-index.json\n try {\n const indexPath = path.join(mcpDir, 'search-index.json');\n const indexData = await fs.readJson(indexPath);\n\n if (typeof indexData !== 'object' || indexData === null) {\n result.errors.push('search-index.json is not a valid object');\n result.success = false;\n }\n } catch (error) {\n result.errors.push(`Failed to parse search-index.json: ${(error as Error).message}`);\n result.success = false;\n }\n\n // Validate manifest.json\n try {\n const manifestPath = path.join(mcpDir, 'manifest.json');\n const manifest = await fs.readJson(manifestPath);\n\n if (!manifest.name || typeof manifest.name !== 'string') {\n result.warnings.push('manifest.json is missing server name');\n }\n if (!manifest.version || typeof manifest.version !== 'string') {\n result.warnings.push('manifest.json is missing server version');\n }\n } catch (error) {\n result.errors.push(`Failed to parse manifest.json: ${(error as Error).message}`);\n result.success = false;\n }\n\n return result;\n}\n\n/**\n * Test the MCP server with the build output\n */\nasync function testServer(buildDir: string): Promise<{ success: boolean; message: string }> {\n const mcpDir = path.join(buildDir, 'mcp');\n const docsPath = path.join(mcpDir, 'docs.json');\n const indexPath = path.join(mcpDir, 'search-index.json');\n const manifestPath = path.join(mcpDir, 'manifest.json');\n\n try {\n const manifest = await fs.readJson(manifestPath);\n const docs = await fs.readJson(docsPath);\n const searchIndexData = await fs.readJson(indexPath);\n\n const server = new McpDocsServer({\n name: manifest.name || 'test-docs',\n version: manifest.version || '1.0.0',\n docs,\n searchIndexData,\n });\n\n await server.initialize();\n const status = await server.getStatus();\n\n if (!status.initialized) {\n return { success: false, message: 'Server failed to initialize' };\n }\n\n if (status.docCount === 0) {\n return { success: false, message: 'Server has no documents loaded' };\n }\n\n return {\n success: true,\n message: `Server initialized with ${status.docCount} documents`,\n };\n } catch (error) {\n return {\n success: false,\n message: `Server test failed: ${(error as Error).message}`,\n };\n }\n}\n\n/**\n * Main CLI entry point\n */\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n const buildDir = args[0] || './build';\n\n console.log('');\n console.log('🔍 MCP Build Verification');\n console.log('='.repeat(50));\n console.log(`Build directory: ${path.resolve(buildDir)}`);\n console.log('');\n\n // Verify build output\n console.log('📁 Checking build output...');\n const verifyResult = await verifyBuild(buildDir);\n\n if (verifyResult.errors.length > 0) {\n console.log('');\n console.log('❌ Errors:');\n for (const error of verifyResult.errors) {\n console.log(` • ${error}`);\n }\n }\n\n if (verifyResult.warnings.length > 0) {\n console.log('');\n console.log('⚠️ Warnings:');\n for (const warning of verifyResult.warnings) {\n console.log(` • ${warning}`);\n }\n }\n\n if (!verifyResult.success) {\n console.log('');\n console.log('❌ Build verification failed');\n process.exit(1);\n }\n\n console.log(` ✓ Found ${verifyResult.docsFound} documents`);\n console.log(' ✓ All required files present');\n console.log(' ✓ File structure valid');\n\n // Test server\n console.log('');\n console.log('🚀 Testing MCP server...');\n const serverResult = await testServer(buildDir);\n\n if (!serverResult.success) {\n console.log(` ❌ ${serverResult.message}`);\n console.log('');\n console.log('❌ Server test failed');\n process.exit(1);\n }\n\n console.log(` ✓ ${serverResult.message}`);\n\n console.log('');\n console.log('✅ All checks passed!');\n console.log('');\n console.log('Next steps:');\n console.log(' 1. Deploy your site to a hosting provider');\n console.log(' 2. Configure MCP endpoint (see README for platform guides)');\n console.log(' 3. Connect your AI tools to the MCP server');\n console.log('');\n\n process.exit(0);\n}\n\nmain().catch((error) => {\n console.error('Unexpected error:', error);\n process.exit(1);\n});\n"]}
1
+ {"version":3,"sources":["../../src/search/flexsearch-indexer.ts","../../src/providers/search/flexsearch-provider.ts","../../src/providers/loader.ts","../../src/mcp/tools/docs-search.ts","../../src/mcp/tools/docs-get-page.ts","../../src/processing/heading-extractor.ts","../../src/mcp/tools/docs-get-section.ts","../../src/mcp/server.ts","../../src/cli/verify.ts"],"names":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CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AAEA,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,UAAA,EAAQ,YAAA,CAAa,OAAO,CAAA,CAAE,CAAA;AAE1C,EAAA,OAAA,CAAQ,IAAI,EAAE,CAAA;AACd,EAAA,OAAA,CAAQ,IAAI,2BAAsB,CAAA;AAClC,EAAA,OAAA,CAAQ,IAAI,EAAE,CAAA;AACd,EAAA,OAAA,CAAQ,IAAI,aAAa,CAAA;AACzB,EAAA,OAAA,CAAQ,IAAI,6CAA6C,CAAA;AACzD,EAAA,OAAA,CAAQ,IAAI,8DAA8D,CAAA;AAC1E,EAAA,OAAA,CAAQ,IAAI,8CAA8C,CAAA;AAC1D,EAAA,OAAA,CAAQ,IAAI,EAAE,CAAA;AAEd,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAChB;AAEA,IAAA,EAAK,CAAE,KAAA,CAAM,CAAC,KAAA,KAAU;AACtB,EAAA,OAAA,CAAQ,KAAA,CAAM,qBAAqB,KAAK,CAAA;AACxC,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAChB,CAAC,CAAA","file":"verify.js","sourcesContent":["import FlexSearch from 'flexsearch';\nimport type { ProcessedDoc, SearchResult } from '../types/index.js';\nimport type { IndexableDocument } from './types.js';\n\nexport type FlexSearchDocument = FlexSearch.Document<IndexableDocument, string[]>;\n\n/**\n * Field weights for search ranking\n * Higher values = more importance\n */\nconst FIELD_WEIGHTS = {\n title: 3.0,\n headings: 2.0,\n description: 1.5,\n content: 1.0,\n} as const;\n\n/**\n * Simple English stemmer\n * Handles common suffixes for better matching\n */\nfunction englishStemmer(word: string): string {\n // Only process words longer than 3 characters\n if (word.length <= 3) return word;\n\n return (\n word\n // -ing endings\n .replace(/ing$/, '')\n // -tion, -sion endings -> t, s\n .replace(/tion$/, 't')\n .replace(/sion$/, 's')\n // -ed endings (careful with short words)\n .replace(/([^aeiou])ed$/, '$1')\n // -es endings\n .replace(/([^aeiou])es$/, '$1')\n // -ly endings\n .replace(/ly$/, '')\n // -ment endings\n .replace(/ment$/, '')\n // -ness endings\n .replace(/ness$/, '')\n // -ies -> y\n .replace(/ies$/, 'y')\n // -s endings (simple plural)\n .replace(/([^s])s$/, '$1')\n );\n}\n\n/**\n * Create a FlexSearch document index with enhanced configuration\n *\n * Features:\n * - Full substring matching (finds \"auth\" in \"authentication\")\n * - English stemming (finds \"authenticate\" when searching \"authentication\")\n * - Context-aware scoring for phrase matching\n * - Optimized resolution for relevance ranking\n */\nexport function createSearchIndex(): FlexSearchDocument {\n return new FlexSearch.Document<IndexableDocument, string[]>({\n // Use 'full' tokenization for substring matching\n // This allows \"auth\" to match \"authentication\"\n tokenize: 'full',\n\n // Enable caching for faster repeated queries\n cache: 100,\n\n // Higher resolution = more granular ranking (1-9)\n resolution: 9,\n\n // Enable context for phrase/proximity matching\n context: {\n resolution: 2,\n depth: 2,\n bidirectional: true,\n },\n\n // Apply stemming to normalize word forms\n encode: (str: string) => {\n // Normalize to lowercase and split into words\n const words = str.toLowerCase().split(/[\\s\\-_.,;:!?'\"()[\\]{}]+/);\n // Apply stemmer to each word\n return words.filter(Boolean).map(englishStemmer);\n },\n\n // Document schema\n document: {\n id: 'id',\n // Index these fields for searching\n index: ['title', 'content', 'headings', 'description'],\n // Store these fields in results (for enriched queries)\n store: ['title', 'description'],\n },\n });\n}\n\n/**\n * Add a document to the search index\n */\nexport function addDocumentToIndex(index: FlexSearchDocument, doc: ProcessedDoc): void {\n const indexable: IndexableDocument = {\n id: doc.route,\n title: doc.title,\n content: doc.markdown,\n headings: doc.headings.map((h) => h.text).join(' '),\n description: doc.description,\n };\n\n index.add(indexable);\n}\n\n/**\n * Build the search index from processed documents\n */\nexport function buildSearchIndex(docs: ProcessedDoc[]): FlexSearchDocument {\n const index = createSearchIndex();\n\n for (const doc of docs) {\n addDocumentToIndex(index, doc);\n }\n\n return index;\n}\n\n/**\n * Search the index and return results with weighted ranking\n *\n * Ranking combines:\n * - Field importance (title > headings > description > content)\n * - Position in results (earlier = more relevant)\n */\nexport function searchIndex(\n index: FlexSearchDocument,\n docs: Record<string, ProcessedDoc>,\n query: string,\n options: { limit?: number } = {}\n): SearchResult[] {\n const { limit = 5 } = options;\n\n // Search across all fields\n const rawResults = index.search(query, {\n limit: limit * 3, // Get extra results for better ranking after weighting\n enrich: true,\n });\n\n // Aggregate scores across fields with weighting\n const docScores = new Map<string, number>();\n\n for (const fieldResult of rawResults) {\n // Determine which field this result is from\n const field = fieldResult.field as keyof typeof FIELD_WEIGHTS;\n const fieldWeight = FIELD_WEIGHTS[field] ?? 1.0;\n\n // With enrich: true, results are objects with id property\n const results = fieldResult.result as unknown as Array<{ id: string } | string>;\n\n for (let i = 0; i < results.length; i++) {\n const item = results[i];\n if (!item) continue;\n\n const docId = typeof item === 'string' ? item : item.id;\n\n // Position-based score (earlier = higher)\n const positionScore = (results.length - i) / results.length;\n\n // Apply field weight to position score\n const weightedScore = positionScore * fieldWeight;\n\n // Combine with existing score (additive for multi-field matches)\n const existingScore = docScores.get(docId) ?? 0;\n docScores.set(docId, existingScore + weightedScore);\n }\n }\n\n // Build results array\n const results: SearchResult[] = [];\n\n for (const [docId, score] of docScores) {\n const doc = docs[docId];\n if (!doc) continue;\n\n results.push({\n route: doc.route,\n title: doc.title,\n score,\n snippet: generateSnippet(doc.markdown, query),\n matchingHeadings: findMatchingHeadings(doc, query),\n });\n }\n\n // Sort by score (highest first) and limit\n results.sort((a, b) => b.score - a.score);\n return results.slice(0, limit);\n}\n\n/**\n * Generate a snippet from the markdown content around the query terms\n */\nexport function generateSnippet(markdown: string, query: string): string {\n const maxLength = 200;\n const queryTerms = query.toLowerCase().split(/\\s+/).filter(Boolean);\n\n if (queryTerms.length === 0) {\n return markdown.slice(0, maxLength) + (markdown.length > maxLength ? '...' : '');\n }\n\n const lowerMarkdown = markdown.toLowerCase();\n let bestIndex = -1;\n let bestTerm = '';\n\n // Also try stemmed versions of query terms\n const allTerms = [...queryTerms, ...queryTerms.map(englishStemmer)];\n\n for (const term of allTerms) {\n const index = lowerMarkdown.indexOf(term);\n if (index !== -1 && (bestIndex === -1 || index < bestIndex)) {\n bestIndex = index;\n bestTerm = term;\n }\n }\n\n if (bestIndex === -1) {\n // No term found, return beginning of document\n return markdown.slice(0, maxLength) + (markdown.length > maxLength ? '...' : '');\n }\n\n const snippetStart = Math.max(0, bestIndex - 50);\n const snippetEnd = Math.min(markdown.length, bestIndex + bestTerm.length + 150);\n\n let snippet = markdown.slice(snippetStart, snippetEnd);\n\n snippet = snippet\n // Remove markdown headings\n .replace(/^#{1,6}\\s+/gm, '')\n // Remove markdown links but keep text\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, '$1')\n // Remove markdown images\n .replace(/!\\[([^\\]]*)\\]\\([^)]+\\)/g, '')\n // Remove code block markers\n .replace(/```[a-z]*\\n?/g, '')\n // Remove inline code backticks\n .replace(/`([^`]+)`/g, '$1')\n // Clean up whitespace\n .replace(/\\s+/g, ' ')\n .trim();\n\n const prefix = snippetStart > 0 ? '...' : '';\n const suffix = snippetEnd < markdown.length ? '...' : '';\n\n return prefix + snippet + suffix;\n}\n\n/**\n * Find headings that match the query (including stemmed forms)\n */\nfunction findMatchingHeadings(doc: ProcessedDoc, query: string): string[] {\n const queryTerms = query.toLowerCase().split(/\\s+/).filter(Boolean);\n // Include stemmed versions for better matching\n const allTerms = [...queryTerms, ...queryTerms.map(englishStemmer)];\n const matching: string[] = [];\n\n for (const heading of doc.headings) {\n const headingLower = heading.text.toLowerCase();\n const headingStemmed = headingLower.split(/\\s+/).map(englishStemmer).join(' ');\n\n // Check if any query term matches the heading or its stemmed form\n if (\n allTerms.some(\n (term) => headingLower.includes(term) || headingStemmed.includes(englishStemmer(term))\n )\n ) {\n matching.push(heading.text);\n }\n }\n\n return matching.slice(0, 3); // Limit to 3 matching headings\n}\n\n/**\n * Export the search index to a serializable format\n */\nexport async function exportSearchIndex(index: FlexSearchDocument): Promise<unknown> {\n const exportData: Record<string, unknown> = {};\n\n await index.export((key, data) => {\n exportData[key as string] = data;\n });\n\n return exportData;\n}\n\n/**\n * Import a search index from serialized data\n */\nexport async function importSearchIndex(\n data: Record<string, unknown>\n): Promise<FlexSearchDocument> {\n const index = createSearchIndex();\n\n for (const [key, value] of Object.entries(data)) {\n // FlexSearch's import expects the data in a specific format\n await (index as unknown as { import: (key: string, data: unknown) => Promise<void> }).import(\n key,\n value\n );\n }\n\n return index;\n}\n","import fs from 'fs-extra';\nimport type { ProcessedDoc, SearchResult } from '../../types/index.js';\nimport type {\n SearchProvider,\n ProviderContext,\n SearchProviderInitData,\n SearchOptions,\n} from '../types.js';\nimport {\n importSearchIndex,\n searchIndex,\n type FlexSearchDocument,\n} from '../../search/flexsearch-indexer.js';\n\n/**\n * Built-in FlexSearch search provider.\n *\n * This provider uses the local FlexSearch index for search queries.\n * Supports both file-based loading (Node.js) and pre-loaded data (Workers).\n */\nexport class FlexSearchProvider implements SearchProvider {\n readonly name = 'flexsearch';\n\n private docs: Record<string, ProcessedDoc> | null = null;\n private searchIndex: FlexSearchDocument | null = null;\n private ready = false;\n\n async initialize(_context: ProviderContext, initData?: SearchProviderInitData): Promise<void> {\n if (!initData) {\n throw new Error('[FlexSearch] SearchProviderInitData required for FlexSearch provider');\n }\n\n // Pre-loaded data mode (Cloudflare Workers, etc.)\n if (initData.docs && initData.indexData) {\n this.docs = initData.docs;\n this.searchIndex = await importSearchIndex(initData.indexData as Record<string, unknown>);\n this.ready = true;\n return;\n }\n\n // File-based mode (Node.js)\n if (initData.docsPath && initData.indexPath) {\n if (await fs.pathExists(initData.docsPath)) {\n this.docs = await fs.readJson(initData.docsPath);\n } else {\n throw new Error(`[FlexSearch] Docs file not found: ${initData.docsPath}`);\n }\n\n if (await fs.pathExists(initData.indexPath)) {\n const indexData = await fs.readJson(initData.indexPath);\n this.searchIndex = await importSearchIndex(indexData);\n } else {\n throw new Error(`[FlexSearch] Search index not found: ${initData.indexPath}`);\n }\n\n this.ready = true;\n return;\n }\n\n throw new Error(\n '[FlexSearch] Invalid init data: must provide either file paths (docsPath, indexPath) or pre-loaded data (docs, indexData)'\n );\n }\n\n isReady(): boolean {\n return this.ready && this.docs !== null && this.searchIndex !== null;\n }\n\n async search(query: string, options?: SearchOptions): Promise<SearchResult[]> {\n if (!this.isReady() || !this.docs || !this.searchIndex) {\n throw new Error('[FlexSearch] Provider not initialized');\n }\n\n const limit = options?.limit ?? 5;\n return searchIndex(this.searchIndex, this.docs, query, { limit });\n }\n\n async getDocument(route: string): Promise<ProcessedDoc | null> {\n if (!this.docs) {\n throw new Error('[FlexSearch] Provider not initialized');\n }\n\n // Try exact match first\n if (this.docs[route]) {\n return this.docs[route];\n }\n\n // Try with/without leading slash\n const normalizedRoute = route.startsWith('/') ? route : `/${route}`;\n const withoutSlash = route.startsWith('/') ? route.slice(1) : route;\n\n return this.docs[normalizedRoute] ?? this.docs[withoutSlash] ?? null;\n }\n\n async healthCheck(): Promise<{ healthy: boolean; message?: string }> {\n if (!this.isReady()) {\n return { healthy: false, message: 'FlexSearch provider not initialized' };\n }\n\n const docCount = this.docs ? Object.keys(this.docs).length : 0;\n return {\n healthy: true,\n message: `FlexSearch provider ready with ${docCount} documents`,\n };\n }\n\n /**\n * Get all loaded documents (for compatibility with existing server code)\n */\n getDocs(): Record<string, ProcessedDoc> | null {\n return this.docs;\n }\n\n /**\n * Get the FlexSearch index (for compatibility with existing server code)\n */\n getSearchIndex(): FlexSearchDocument | null {\n return this.searchIndex;\n }\n}\n","import type { ContentIndexer, SearchProvider } from './types.js';\nimport { FlexSearchIndexer } from './indexers/flexsearch-indexer.js';\nimport { FlexSearchProvider } from './search/flexsearch-provider.js';\n\n/**\n * Load an indexer by name or module path.\n *\n * @param specifier - Either 'flexsearch' for the built-in indexer, or a module path\n * (relative path like './my-indexer.js' or npm package like '@myorg/indexer')\n * @returns Instantiated ContentIndexer\n *\n * @example\n * ```typescript\n * // Built-in\n * const indexer = await loadIndexer('flexsearch');\n *\n * // Custom relative path\n * const indexer = await loadIndexer('./src/providers/algolia-indexer.js');\n *\n * // Custom npm package\n * const indexer = await loadIndexer('@myorg/custom-indexer');\n * ```\n */\nexport async function loadIndexer(specifier: string): Promise<ContentIndexer> {\n // Built-in FlexSearch indexer\n if (specifier === 'flexsearch') {\n return new FlexSearchIndexer();\n }\n\n try {\n const module = await import(specifier);\n const IndexerClass = module.default;\n\n if (typeof IndexerClass === 'function') {\n // It's a class constructor\n const instance = new IndexerClass();\n\n if (!isContentIndexer(instance)) {\n throw new Error(\n `Invalid indexer module \"${specifier}\": does not implement ContentIndexer interface`\n );\n }\n\n return instance;\n }\n\n if (isContentIndexer(IndexerClass)) {\n return IndexerClass;\n }\n\n throw new Error(\n `Invalid indexer module \"${specifier}\": must export a default class or ContentIndexer instance`\n );\n } catch (error) {\n if (error instanceof Error && error.message.includes('Cannot find module')) {\n throw new Error(`Indexer module not found: \"${specifier}\". Check the path or package name.`);\n }\n throw error;\n }\n}\n\n/**\n * Load a search provider by name or module path.\n *\n * @param specifier - Either 'flexsearch' for the built-in provider, or a module path\n * (relative path like './my-search.js' or npm package like '@myorg/search')\n * @returns Instantiated SearchProvider\n *\n * @example\n * ```typescript\n * // Built-in\n * const provider = await loadSearchProvider('flexsearch');\n *\n * // Custom relative path\n * const provider = await loadSearchProvider('./src/providers/glean-search.js');\n *\n * // Custom npm package\n * const provider = await loadSearchProvider('@myorg/glean-search');\n * ```\n */\nexport async function loadSearchProvider(specifier: string): Promise<SearchProvider> {\n if (specifier === 'flexsearch') {\n return new FlexSearchProvider();\n }\n\n try {\n const module = await import(specifier);\n const ProviderClass = module.default;\n\n if (typeof ProviderClass === 'function') {\n const instance = new ProviderClass();\n\n if (!isSearchProvider(instance)) {\n throw new Error(\n `Invalid search provider module \"${specifier}\": does not implement SearchProvider interface`\n );\n }\n\n return instance;\n }\n\n if (isSearchProvider(ProviderClass)) {\n return ProviderClass;\n }\n\n throw new Error(\n `Invalid search provider module \"${specifier}\": must export a default class or SearchProvider instance`\n );\n } catch (error) {\n if (error instanceof Error && error.message.includes('Cannot find module')) {\n throw new Error(\n `Search provider module not found: \"${specifier}\". Check the path or package name.`\n );\n }\n throw error;\n }\n}\n\n/**\n * Type guard to check if an object implements ContentIndexer\n */\nfunction isContentIndexer(obj: unknown): obj is ContentIndexer {\n if (!obj || typeof obj !== 'object') {\n return false;\n }\n\n const indexer = obj as ContentIndexer;\n return (\n typeof indexer.name === 'string' &&\n typeof indexer.initialize === 'function' &&\n typeof indexer.indexDocuments === 'function' &&\n typeof indexer.finalize === 'function'\n );\n}\n\n/**\n * Type guard to check if an object implements SearchProvider\n */\nfunction isSearchProvider(obj: unknown): obj is SearchProvider {\n if (!obj || typeof obj !== 'object') {\n return false;\n }\n\n const provider = obj as SearchProvider;\n return (\n typeof provider.name === 'string' &&\n typeof provider.initialize === 'function' &&\n typeof provider.isReady === 'function' &&\n typeof provider.search === 'function'\n );\n}\n","import type { ProcessedDoc, SearchResult, DocsSearchParams } from '../../types/index.js';\nimport { searchIndex, type FlexSearchDocument } from '../../search/flexsearch-indexer.js';\n\n/**\n * Tool definition for docs_search\n */\nexport const docsSearchTool = {\n name: 'docs_search',\n description:\n 'Search across developer documentation. Returns ranked results with snippets and matching headings.',\n inputSchema: {\n type: 'object' as const,\n properties: {\n query: {\n type: 'string',\n description: 'Search query string',\n },\n limit: {\n type: 'number',\n description: 'Maximum number of results to return (default: 5, max: 20)',\n default: 5,\n },\n },\n required: ['query'],\n },\n};\n\n/**\n * Execute the docs_search tool\n */\nexport function executeDocsSearch(\n params: DocsSearchParams,\n index: FlexSearchDocument,\n docs: Record<string, ProcessedDoc>\n): SearchResult[] {\n const { query, limit = 5 } = params;\n\n // Validate parameters\n if (!query || typeof query !== 'string' || query.trim().length === 0) {\n throw new Error('Query parameter is required and must be a non-empty string');\n }\n\n const effectiveLimit = Math.min(Math.max(1, limit), 20);\n\n // Search the index\n const results = searchIndex(index, docs, query.trim(), {\n limit: effectiveLimit,\n });\n\n return results;\n}\n\n/**\n * Format search results for MCP response\n */\nexport function formatSearchResults(results: SearchResult[], baseUrl?: string): string {\n if (results.length === 0) {\n return 'No matching documents found.';\n }\n\n const lines: string[] = [`Found ${results.length} result(s):\\n`];\n\n for (let i = 0; i < results.length; i++) {\n const result = results[i];\n if (!result) continue;\n\n lines.push(`${i + 1}. **${result.title}**`);\n\n // Include full URL if baseUrl is provided\n if (baseUrl) {\n const fullUrl = `${baseUrl.replace(/\\/$/, '')}${result.route}`;\n lines.push(` URL: ${fullUrl}`);\n }\n\n lines.push(` Route: ${result.route}`);\n\n if (result.matchingHeadings && result.matchingHeadings.length > 0) {\n lines.push(` Matching sections: ${result.matchingHeadings.join(', ')}`);\n }\n\n lines.push(` ${result.snippet}`);\n lines.push('');\n }\n\n return lines.join('\\n');\n}\n","import type { ProcessedDoc, DocsGetPageParams } from '../../types/index.js';\n\n/**\n * Tool definition for docs_get_page\n */\nexport const docsGetPageTool = {\n name: 'docs_get_page',\n description:\n 'Retrieve the full content of a documentation page as markdown. Use this after searching to get complete page content.',\n inputSchema: {\n type: 'object' as const,\n properties: {\n route: {\n type: 'string',\n description: 'The route path of the page (e.g., /docs/getting-started)',\n },\n },\n required: ['route'],\n },\n};\n\n/**\n * Execute the docs_get_page tool\n */\nexport function executeDocsGetPage(\n params: DocsGetPageParams,\n docs: Record<string, ProcessedDoc>\n): ProcessedDoc | null {\n const { route } = params;\n\n // Validate parameters\n if (!route || typeof route !== 'string') {\n throw new Error('Route parameter is required and must be a string');\n }\n\n // Normalize route (ensure leading slash, remove trailing slash)\n let normalizedRoute = route.trim();\n if (!normalizedRoute.startsWith('/')) {\n normalizedRoute = '/' + normalizedRoute;\n }\n if (normalizedRoute.length > 1 && normalizedRoute.endsWith('/')) {\n normalizedRoute = normalizedRoute.slice(0, -1);\n }\n\n // Look up the document\n const doc = docs[normalizedRoute];\n\n if (!doc) {\n // Try without leading slash\n const altRoute = normalizedRoute.slice(1);\n if (docs[altRoute]) {\n return docs[altRoute] ?? null;\n }\n return null;\n }\n\n return doc;\n}\n\n/**\n * Format page content for MCP response\n */\nexport function formatPageContent(doc: ProcessedDoc | null, baseUrl?: string): string {\n if (!doc) {\n return 'Page not found. Please check the route path and try again.';\n }\n\n const lines: string[] = [];\n\n // Header\n lines.push(`# ${doc.title}`);\n lines.push('');\n\n // Metadata\n if (doc.description) {\n lines.push(`> ${doc.description}`);\n lines.push('');\n }\n\n // Include full URL if baseUrl is provided\n if (baseUrl) {\n const fullUrl = `${baseUrl.replace(/\\/$/, '')}${doc.route}`;\n lines.push(`**URL:** ${fullUrl}`);\n }\n\n lines.push(`**Route:** ${doc.route}`);\n lines.push('');\n\n // Table of contents (if there are headings)\n if (doc.headings.length > 0) {\n lines.push('## Contents');\n lines.push('');\n for (const heading of doc.headings) {\n if (heading.level <= 3) {\n const indent = ' '.repeat(heading.level - 1);\n lines.push(`${indent}- [${heading.text}](#${heading.id})`);\n }\n }\n lines.push('');\n lines.push('---');\n lines.push('');\n }\n\n // Main content\n lines.push(doc.markdown);\n\n return lines.join('\\n');\n}\n","import type { DocHeading } from '../types/index.js';\n\n/**\n * Extract headings from markdown content with their positions\n */\nexport function extractHeadingsFromMarkdown(markdown: string): DocHeading[] {\n const headings: DocHeading[] = [];\n const lines = markdown.split('\\n');\n let currentOffset = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i] ?? '';\n const headingMatch = line.match(/^(#{1,6})\\s+(.+?)(?:\\s+\\{#([^}]+)\\})?$/);\n\n if (headingMatch) {\n const hashes = headingMatch[1] ?? '';\n const level = hashes.length;\n let text = headingMatch[2] ?? '';\n let id = headingMatch[3] ?? '';\n\n // If no explicit ID, generate one from text (Docusaurus style)\n if (!id) {\n id = generateHeadingId(text);\n }\n\n // Clean up text (remove any remaining markdown formatting)\n text = text.replace(/\\*\\*([^*]+)\\*\\*/g, '$1'); // Remove bold\n text = text.replace(/_([^_]+)_/g, '$1'); // Remove italic\n text = text.replace(/`([^`]+)`/g, '$1'); // Remove code\n\n headings.push({\n level,\n text: text.trim(),\n id,\n startOffset: currentOffset,\n endOffset: -1, // Will be calculated below\n });\n }\n\n currentOffset += line.length + 1; // +1 for newline\n }\n\n // Calculate end offsets (each heading ends where the next same-or-higher level heading starts)\n for (let i = 0; i < headings.length; i++) {\n const current = headings[i];\n if (!current) continue;\n\n let endOffset = markdown.length;\n\n // Find the next heading at the same or higher level\n for (let j = i + 1; j < headings.length; j++) {\n const next = headings[j];\n if (next && next.level <= current.level) {\n endOffset = next.startOffset;\n break;\n }\n }\n\n current.endOffset = endOffset;\n }\n\n return headings;\n}\n\n/**\n * Generate a URL-safe heading ID (Docusaurus style)\n */\nexport function generateHeadingId(text: string): string {\n return (\n text\n .toLowerCase()\n // Remove any non-alphanumeric characters except spaces and hyphens\n .replace(/[^\\w\\s-]/g, '')\n // Replace spaces with hyphens\n .replace(/\\s+/g, '-')\n // Remove consecutive hyphens\n .replace(/-+/g, '-')\n // Remove leading/trailing hyphens\n .replace(/^-|-$/g, '')\n );\n}\n\n/**\n * Extract a specific section from markdown by heading ID\n */\nexport function extractSection(\n markdown: string,\n headingId: string,\n headings: DocHeading[]\n): string | null {\n const heading = headings.find((h) => h.id === headingId);\n\n if (!heading) {\n return null;\n }\n\n return markdown.slice(heading.startOffset, heading.endOffset).trim();\n}\n","import type { ProcessedDoc, DocsGetSectionParams } from '../../types/index.js';\nimport { extractSection } from '../../processing/heading-extractor.js';\n\n/**\n * Tool definition for docs_get_section\n */\nexport const docsGetSectionTool = {\n name: 'docs_get_section',\n description:\n 'Retrieve a specific section of a documentation page by heading ID. Use this to get focused content from a larger page.',\n inputSchema: {\n type: 'object' as const,\n properties: {\n route: {\n type: 'string',\n description: 'The route path of the page (e.g., /docs/getting-started)',\n },\n headingId: {\n type: 'string',\n description: 'The ID of the heading to retrieve (e.g., authentication)',\n },\n },\n required: ['route', 'headingId'],\n },\n};\n\n/**\n * Result of executing docs_get_section\n */\nexport interface SectionResult {\n /** The section content as markdown */\n content: string | null;\n /** The document the section belongs to */\n doc: ProcessedDoc | null;\n /** The heading text */\n headingText: string | null;\n /** Available headings in the document */\n availableHeadings: Array<{ id: string; text: string; level: number }>;\n}\n\n/**\n * Execute the docs_get_section tool\n */\nexport function executeDocsGetSection(\n params: DocsGetSectionParams,\n docs: Record<string, ProcessedDoc>\n): SectionResult {\n const { route, headingId } = params;\n\n // Validate parameters\n if (!route || typeof route !== 'string') {\n throw new Error('Route parameter is required and must be a string');\n }\n if (!headingId || typeof headingId !== 'string') {\n throw new Error('HeadingId parameter is required and must be a string');\n }\n\n // Normalize route\n let normalizedRoute = route.trim();\n if (!normalizedRoute.startsWith('/')) {\n normalizedRoute = '/' + normalizedRoute;\n }\n if (normalizedRoute.length > 1 && normalizedRoute.endsWith('/')) {\n normalizedRoute = normalizedRoute.slice(0, -1);\n }\n\n // Look up the document\n const doc = docs[normalizedRoute];\n\n if (!doc) {\n return {\n content: null,\n doc: null,\n headingText: null,\n availableHeadings: [],\n };\n }\n\n // Get available headings\n const availableHeadings = doc.headings.map((h) => ({\n id: h.id,\n text: h.text,\n level: h.level,\n }));\n\n // Find the heading\n const heading = doc.headings.find((h) => h.id === headingId.trim());\n\n if (!heading) {\n return {\n content: null,\n doc,\n headingText: null,\n availableHeadings,\n };\n }\n\n // Extract the section content\n const content = extractSection(doc.markdown, headingId.trim(), doc.headings);\n\n return {\n content,\n doc,\n headingText: heading.text,\n availableHeadings,\n };\n}\n\n/**\n * Format section content for MCP response\n */\nexport function formatSectionContent(\n result: SectionResult,\n headingId: string,\n baseUrl?: string\n): string {\n if (!result.doc) {\n return 'Page not found. Please check the route path and try again.';\n }\n\n if (!result.content) {\n const lines = [`Section \"${headingId}\" not found in this document.`, '', 'Available sections:'];\n\n for (const heading of result.availableHeadings) {\n const indent = ' '.repeat(heading.level - 1);\n lines.push(`${indent}- ${heading.text} (id: ${heading.id})`);\n }\n\n return lines.join('\\n');\n }\n\n const lines: string[] = [];\n\n // Build URL with anchor if baseUrl is provided\n const fullUrl = baseUrl ? `${baseUrl.replace(/\\/$/, '')}${result.doc.route}#${headingId}` : null;\n\n // Header\n lines.push(`# ${result.headingText}`);\n if (fullUrl) {\n lines.push(`> From: ${result.doc.title} - ${fullUrl}`);\n } else {\n lines.push(`> From: ${result.doc.title} (${result.doc.route})`);\n }\n lines.push('');\n lines.push('---');\n lines.push('');\n\n // Section content\n lines.push(result.content);\n\n return lines.join('\\n');\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\nimport { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';\nimport { z } from 'zod';\nimport type { IncomingMessage, ServerResponse } from 'node:http';\nimport type {\n ProcessedDoc,\n McpServerConfig,\n McpServerFileConfig,\n McpServerDataConfig,\n} from '../types/index.js';\nimport { loadSearchProvider } from '../providers/loader.js';\nimport { FlexSearchProvider } from '../providers/search/flexsearch-provider.js';\nimport type {\n SearchProvider,\n ProviderContext,\n SearchProviderInitData,\n} from '../providers/types.js';\nimport { formatSearchResults } from './tools/docs-search.js';\nimport { formatPageContent } from './tools/docs-get-page.js';\nimport { formatSectionContent } from './tools/docs-get-section.js';\nimport { extractSection } from '../processing/heading-extractor.js';\n\n/**\n * Type guard to check if config uses file-based loading\n */\nfunction isFileConfig(config: McpServerConfig): config is McpServerFileConfig {\n return 'docsPath' in config && 'indexPath' in config;\n}\n\n/**\n * Type guard to check if config uses pre-loaded data\n */\nfunction isDataConfig(config: McpServerConfig): config is McpServerDataConfig {\n return 'docs' in config && 'searchIndexData' in config;\n}\n\n/**\n * MCP Server for documentation\n *\n * This class provides the MCP server implementation that can be used\n * with any HTTP framework (Express, Vercel, Cloudflare Workers, etc.)\n *\n * Supports two modes:\n * - File-based: Load docs and search index from filesystem (Node.js)\n * - Pre-loaded: Accept docs and search index data directly (Workers)\n *\n * Uses the official MCP SDK for proper protocol handling.\n */\nexport class McpDocsServer {\n private config: McpServerConfig;\n private searchProvider: SearchProvider | null = null;\n private mcpServer: McpServer;\n private initialized = false;\n\n constructor(config: McpServerConfig) {\n this.config = config;\n\n // Create MCP server using the high-level API\n this.mcpServer = new McpServer(\n {\n name: config.name,\n version: config.version ?? '1.0.0',\n },\n {\n capabilities: {\n tools: {},\n },\n }\n );\n\n this.registerTools();\n }\n\n /**\n * Register all MCP tools using the SDK's registerTool API\n */\n private registerTools(): void {\n // docs_search - Search across documentation\n this.mcpServer.registerTool(\n 'docs_search',\n {\n description:\n 'Search the documentation for relevant pages. Returns matching documents with snippets and relevance scores. Use this to find information across all documentation.',\n inputSchema: {\n query: z.string().min(1).describe('The search query string'),\n limit: z\n .number()\n .int()\n .min(1)\n .max(20)\n .optional()\n .default(5)\n .describe('Maximum number of results to return (1-20, default: 5)'),\n },\n },\n async ({ query, limit }) => {\n await this.initialize();\n\n if (!this.searchProvider || !this.searchProvider.isReady()) {\n return {\n content: [{ type: 'text' as const, text: 'Server not initialized. Please try again.' }],\n isError: true,\n };\n }\n\n try {\n const results = await this.searchProvider.search(query, { limit });\n return {\n content: [\n { type: 'text' as const, text: formatSearchResults(results, this.config.baseUrl) },\n ],\n };\n } catch (error) {\n console.error('[MCP] Search error:', error);\n return {\n content: [{ type: 'text' as const, text: `Search error: ${String(error)}` }],\n isError: true,\n };\n }\n }\n );\n\n // docs_get_page - Retrieve full page content\n this.mcpServer.registerTool(\n 'docs_get_page',\n {\n description:\n 'Retrieve the complete content of a documentation page as markdown. Use this when you need the full content of a specific page.',\n inputSchema: {\n route: z\n .string()\n .min(1)\n .describe('The page route path (e.g., \"/docs/getting-started\" or \"/api/reference\")'),\n },\n },\n async ({ route }) => {\n await this.initialize();\n\n if (!this.searchProvider || !this.searchProvider.isReady()) {\n return {\n content: [{ type: 'text' as const, text: 'Server not initialized. Please try again.' }],\n isError: true,\n };\n }\n\n try {\n const doc = await this.getDocument(route);\n return {\n content: [{ type: 'text' as const, text: formatPageContent(doc, this.config.baseUrl) }],\n };\n } catch (error) {\n console.error('[MCP] Get page error:', error);\n return {\n content: [{ type: 'text' as const, text: `Error getting page: ${String(error)}` }],\n isError: true,\n };\n }\n }\n );\n\n // docs_get_section - Retrieve a specific section\n this.mcpServer.registerTool(\n 'docs_get_section',\n {\n description:\n 'Retrieve a specific section from a documentation page by its heading ID. Use this when you need only a portion of a page rather than the entire content.',\n inputSchema: {\n route: z.string().min(1).describe('The page route path'),\n headingId: z\n .string()\n .min(1)\n .describe(\n 'The heading ID of the section to extract (e.g., \"installation\", \"api-reference\")'\n ),\n },\n },\n async ({ route, headingId }) => {\n await this.initialize();\n\n if (!this.searchProvider || !this.searchProvider.isReady()) {\n return {\n content: [{ type: 'text' as const, text: 'Server not initialized. Please try again.' }],\n isError: true,\n };\n }\n\n try {\n const doc = await this.getDocument(route);\n if (!doc) {\n return {\n content: [\n {\n type: 'text' as const,\n text: formatSectionContent(\n { content: null, doc: null, headingText: null, availableHeadings: [] },\n headingId,\n this.config.baseUrl\n ),\n },\n ],\n };\n }\n\n // Get available headings\n const availableHeadings = doc.headings.map((h) => ({\n id: h.id,\n text: h.text,\n level: h.level,\n }));\n\n // Find the heading\n const heading = doc.headings.find((h) => h.id === headingId.trim());\n\n if (!heading) {\n return {\n content: [\n {\n type: 'text' as const,\n text: formatSectionContent(\n { content: null, doc, headingText: null, availableHeadings },\n headingId,\n this.config.baseUrl\n ),\n },\n ],\n };\n }\n\n // Extract the section content\n const sectionContent = extractSection(doc.markdown, headingId.trim(), doc.headings);\n\n return {\n content: [\n {\n type: 'text' as const,\n text: formatSectionContent(\n { content: sectionContent, doc, headingText: heading.text, availableHeadings },\n headingId,\n this.config.baseUrl\n ),\n },\n ],\n };\n } catch (error) {\n console.error('[MCP] Get section error:', error);\n return {\n content: [{ type: 'text' as const, text: `Error getting section: ${String(error)}` }],\n isError: true,\n };\n }\n }\n );\n }\n\n /**\n * Get a document by route using the search provider\n */\n private async getDocument(route: string): Promise<ProcessedDoc | null> {\n if (!this.searchProvider) {\n return null;\n }\n\n // Use the provider's getDocument if available\n if (this.searchProvider.getDocument) {\n return this.searchProvider.getDocument(route);\n }\n\n // For FlexSearchProvider, we can access docs directly\n if (this.searchProvider instanceof FlexSearchProvider) {\n const docs = this.searchProvider.getDocs();\n if (!docs) return null;\n\n // Try exact match first\n if (docs[route]) {\n return docs[route];\n }\n\n // Try with/without leading slash\n const normalizedRoute = route.startsWith('/') ? route : `/${route}`;\n const withoutSlash = route.startsWith('/') ? route.slice(1) : route;\n\n return docs[normalizedRoute] ?? docs[withoutSlash] ?? null;\n }\n\n return null;\n }\n\n /**\n * Load docs and search index using the configured search provider\n *\n * For file-based config: reads from disk\n * For data config: uses pre-loaded data directly\n */\n async initialize(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n try {\n // Load the search provider\n const searchSpecifier = this.config.search ?? 'flexsearch';\n this.searchProvider = await loadSearchProvider(searchSpecifier);\n\n // Build provider context\n const providerContext: ProviderContext = {\n baseUrl: this.config.baseUrl ?? '',\n serverName: this.config.name,\n serverVersion: this.config.version ?? '1.0.0',\n outputDir: '', // Not relevant for runtime\n };\n\n // Build init data based on config type\n const initData: SearchProviderInitData = {};\n\n if (isDataConfig(this.config)) {\n // Pre-loaded data mode (Cloudflare Workers, etc.)\n initData.docs = this.config.docs;\n initData.indexData = this.config.searchIndexData;\n } else if (isFileConfig(this.config)) {\n // File-based mode (Node.js)\n initData.docsPath = this.config.docsPath;\n initData.indexPath = this.config.indexPath;\n } else {\n throw new Error('Invalid server config: must provide either file paths or pre-loaded data');\n }\n\n // Initialize the search provider\n await this.searchProvider.initialize(providerContext, initData);\n\n this.initialized = true;\n } catch (error) {\n console.error('[MCP] Failed to initialize:', error);\n throw error;\n }\n }\n\n /**\n * Handle an HTTP request using the MCP SDK's transport\n *\n * This method is designed for serverless environments (Vercel, Netlify).\n * It creates a stateless transport instance and processes the request.\n *\n * @param req - Node.js IncomingMessage or compatible request object\n * @param res - Node.js ServerResponse or compatible response object\n * @param parsedBody - Optional pre-parsed request body\n */\n async handleHttpRequest(\n req: IncomingMessage,\n res: ServerResponse,\n parsedBody?: unknown\n ): Promise<void> {\n await this.initialize();\n\n // Create a stateless transport for this request\n // enableJsonResponse: true means we get simple JSON responses instead of SSE\n const transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: undefined, // Stateless mode - no session tracking\n enableJsonResponse: true, // Return JSON instead of SSE streams\n });\n\n // Connect the server to this transport\n await this.mcpServer.connect(transport);\n\n try {\n // Let the transport handle the request\n await transport.handleRequest(req, res, parsedBody);\n } finally {\n // Clean up the transport after request\n await transport.close();\n }\n }\n\n /**\n * Handle a Web Standard Request (Cloudflare Workers, Deno, Bun)\n *\n * This method is designed for Web Standard environments that use\n * the Fetch API Request/Response pattern.\n *\n * @param request - Web Standard Request object\n * @returns Web Standard Response object\n */\n async handleWebRequest(request: Request): Promise<Response> {\n await this.initialize();\n\n // Create a stateless transport for Web Standards\n const transport = new WebStandardStreamableHTTPServerTransport({\n sessionIdGenerator: undefined, // Stateless mode\n enableJsonResponse: true,\n });\n\n // Connect the server to this transport\n await this.mcpServer.connect(transport);\n\n try {\n // Let the transport handle the request and return the response\n return await transport.handleRequest(request);\n } finally {\n // Clean up the transport after request\n await transport.close();\n }\n }\n\n /**\n * Get server status information\n *\n * Useful for health checks and debugging\n */\n async getStatus(): Promise<{\n name: string;\n version: string;\n initialized: boolean;\n docCount: number;\n baseUrl?: string;\n searchProvider?: string;\n }> {\n let docCount = 0;\n\n // Get doc count from FlexSearchProvider if available\n if (this.searchProvider instanceof FlexSearchProvider) {\n const docs = this.searchProvider.getDocs();\n docCount = docs ? Object.keys(docs).length : 0;\n }\n\n return {\n name: this.config.name,\n version: this.config.version ?? '1.0.0',\n initialized: this.initialized,\n docCount,\n baseUrl: this.config.baseUrl,\n searchProvider: this.searchProvider?.name,\n };\n }\n\n /**\n * Get the underlying McpServer instance\n *\n * Useful for advanced use cases like custom transports\n */\n getMcpServer(): McpServer {\n return this.mcpServer;\n }\n}\n","#!/usr/bin/env node\n/**\n * MCP Verification CLI\n *\n * Verifies that the MCP build output is valid and the server works correctly.\n *\n * Usage:\n * npx docusaurus-mcp-verify [buildDir]\n *\n * Options:\n * buildDir Path to Docusaurus build output (default: ./build)\n */\n\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { McpDocsServer } from '../mcp/server.js';\n\ninterface VerifyResult {\n success: boolean;\n docsFound: number;\n errors: string[];\n warnings: string[];\n}\n\n/**\n * Verify the MCP build output\n */\nasync function verifyBuild(buildDir: string): Promise<VerifyResult> {\n const result: VerifyResult = {\n success: true,\n docsFound: 0,\n errors: [],\n warnings: [],\n };\n\n const mcpDir = path.join(buildDir, 'mcp');\n\n // Check if MCP directory exists\n if (!(await fs.pathExists(mcpDir))) {\n result.errors.push(`MCP directory not found: ${mcpDir}`);\n result.errors.push('Did you run \"npm run build\" with the MCP plugin configured?');\n result.success = false;\n return result;\n }\n\n // Check required files\n const requiredFiles = ['docs.json', 'search-index.json', 'manifest.json'];\n\n for (const file of requiredFiles) {\n const filePath = path.join(mcpDir, file);\n if (!(await fs.pathExists(filePath))) {\n result.errors.push(`Required file missing: ${filePath}`);\n result.success = false;\n }\n }\n\n if (!result.success) {\n return result;\n }\n\n // Validate docs.json\n try {\n const docsPath = path.join(mcpDir, 'docs.json');\n const docs = await fs.readJson(docsPath);\n\n if (typeof docs !== 'object' || docs === null) {\n result.errors.push('docs.json is not a valid object');\n result.success = false;\n } else {\n result.docsFound = Object.keys(docs).length;\n\n if (result.docsFound === 0) {\n result.warnings.push('docs.json contains no documents');\n }\n\n // Validate document structure\n for (const [route, doc] of Object.entries(docs)) {\n const d = doc as Record<string, unknown>;\n if (!d.title || typeof d.title !== 'string') {\n result.warnings.push(`Document ${route} is missing a title`);\n }\n if (!d.markdown || typeof d.markdown !== 'string') {\n result.warnings.push(`Document ${route} is missing markdown content`);\n }\n }\n }\n } catch (error) {\n result.errors.push(`Failed to parse docs.json: ${(error as Error).message}`);\n result.success = false;\n }\n\n // Validate search-index.json\n try {\n const indexPath = path.join(mcpDir, 'search-index.json');\n const indexData = await fs.readJson(indexPath);\n\n if (typeof indexData !== 'object' || indexData === null) {\n result.errors.push('search-index.json is not a valid object');\n result.success = false;\n }\n } catch (error) {\n result.errors.push(`Failed to parse search-index.json: ${(error as Error).message}`);\n result.success = false;\n }\n\n // Validate manifest.json\n try {\n const manifestPath = path.join(mcpDir, 'manifest.json');\n const manifest = await fs.readJson(manifestPath);\n\n if (!manifest.name || typeof manifest.name !== 'string') {\n result.warnings.push('manifest.json is missing server name');\n }\n if (!manifest.version || typeof manifest.version !== 'string') {\n result.warnings.push('manifest.json is missing server version');\n }\n } catch (error) {\n result.errors.push(`Failed to parse manifest.json: ${(error as Error).message}`);\n result.success = false;\n }\n\n return result;\n}\n\n/**\n * Test the MCP server with the build output\n */\nasync function testServer(buildDir: string): Promise<{ success: boolean; message: string }> {\n const mcpDir = path.join(buildDir, 'mcp');\n const docsPath = path.join(mcpDir, 'docs.json');\n const indexPath = path.join(mcpDir, 'search-index.json');\n const manifestPath = path.join(mcpDir, 'manifest.json');\n\n try {\n const manifest = await fs.readJson(manifestPath);\n const docs = await fs.readJson(docsPath);\n const searchIndexData = await fs.readJson(indexPath);\n\n const server = new McpDocsServer({\n name: manifest.name || 'test-docs',\n version: manifest.version || '1.0.0',\n docs,\n searchIndexData,\n });\n\n await server.initialize();\n const status = await server.getStatus();\n\n if (!status.initialized) {\n return { success: false, message: 'Server failed to initialize' };\n }\n\n if (status.docCount === 0) {\n return { success: false, message: 'Server has no documents loaded' };\n }\n\n return {\n success: true,\n message: `Server initialized with ${status.docCount} documents`,\n };\n } catch (error) {\n return {\n success: false,\n message: `Server test failed: ${(error as Error).message}`,\n };\n }\n}\n\n/**\n * Main CLI entry point\n */\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n const buildDir = args[0] || './build';\n\n console.log('');\n console.log('🔍 MCP Build Verification');\n console.log('='.repeat(50));\n console.log(`Build directory: ${path.resolve(buildDir)}`);\n console.log('');\n\n // Verify build output\n console.log('📁 Checking build output...');\n const verifyResult = await verifyBuild(buildDir);\n\n if (verifyResult.errors.length > 0) {\n console.log('');\n console.log('❌ Errors:');\n for (const error of verifyResult.errors) {\n console.log(` • ${error}`);\n }\n }\n\n if (verifyResult.warnings.length > 0) {\n console.log('');\n console.log('⚠️ Warnings:');\n for (const warning of verifyResult.warnings) {\n console.log(` • ${warning}`);\n }\n }\n\n if (!verifyResult.success) {\n console.log('');\n console.log('❌ Build verification failed');\n process.exit(1);\n }\n\n console.log(` ✓ Found ${verifyResult.docsFound} documents`);\n console.log(' ✓ All required files present');\n console.log(' ✓ File structure valid');\n\n // Test server\n console.log('');\n console.log('🚀 Testing MCP server...');\n const serverResult = await testServer(buildDir);\n\n if (!serverResult.success) {\n console.log(` ❌ ${serverResult.message}`);\n console.log('');\n console.log('❌ Server test failed');\n process.exit(1);\n }\n\n console.log(` ✓ ${serverResult.message}`);\n\n console.log('');\n console.log('✅ All checks passed!');\n console.log('');\n console.log('Next steps:');\n console.log(' 1. Deploy your site to a hosting provider');\n console.log(' 2. Configure MCP endpoint (see README for platform guides)');\n console.log(' 3. Connect your AI tools to the MCP server');\n console.log('');\n\n process.exit(0);\n}\n\nmain().catch((error) => {\n console.error('Unexpected error:', error);\n process.exit(1);\n});\n"]}