docusaurus-plugin-mcp-server 0.8.0 → 0.10.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/providers/search/flexsearch-provider.ts","../../src/providers/loader.ts","../../src/mcp/tools/docs-search.ts","../../src/mcp/tools/docs-fetch.ts","../../src/mcp/server.ts","../../src/cli/verify.ts"],"names":["results","fs"],"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,IAAI,WAAW,QAAA,CAAsC;AAAA;AAAA;AAAA,IAG1D,QAAA,EAAU,MAAA;AAAA;AAAA,IAGV,KAAA,EAAO,GAAA;AAAA;AAAA,IAGP,UAAA,EAAY,CAAA;AAAA;AAAA,IAGZ,OAAA,EAAS;AAAA,MACP,UAAA,EAAY,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AI,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.mjs","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_fetch\n */\nexport const docsFetchTool = {\n name: 'docs_fetch',\n description:\n 'Fetch the complete content of a documentation page. Use this after searching to get full 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 { 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-fetch.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 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 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 this.mcpServer.registerTool(\n 'docs_fetch',\n {\n description:\n 'Fetch the complete content of a documentation page. 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\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"]}
1
+ {"version":3,"sources":["../../src/search/flexsearch-core.ts","../../src/providers/search/flexsearch-provider.ts","../../src/providers/loader.ts","../../src/mcp/tools/docs-search.ts","../../src/mcp/tools/docs-fetch.ts","../../src/mcp/server.ts","../../src/cli/verify.ts"],"names":["results","fs","z"],"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,I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B,CAAA;AACtC,EAAA,MAAM,YAAA,GAAe,MAAM,UAAA,CAAW,QAAQ,CAAA;AAE9C,EAAA,IAAI,CAAC,aAAa,OAAA,EAAS;AACzB,IAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,UAAA,EAAQ,YAAA,CAAa,OAAO,CAAA,CAAE,CAAA;AAC1C,IAAA,OAAA,CAAQ,IAAI,EAAE,CAAA;AACd,IAAA,OAAA,CAAQ,IAAI,2BAAsB,CAAA;AAClC,IAAA,OAAA,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.mjs","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 *\n * @param index - The FlexSearch index\n * @param doc - The document to add\n * @param baseUrl - Optional base URL to construct full URL as document ID\n */\nexport function addDocumentToIndex(\n index: FlexSearchDocument,\n doc: ProcessedDoc,\n baseUrl?: string\n): void {\n // Use full URL as ID if baseUrl is provided, otherwise use route\n const id = baseUrl ? `${baseUrl.replace(/\\/$/, '')}${doc.route}` : doc.route;\n\n const indexable: IndexableDocument = {\n id,\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 *\n * @param docs - Documents to index\n * @param baseUrl - Optional base URL to construct full URLs as document IDs\n */\nexport function buildSearchIndex(docs: ProcessedDoc[], baseUrl?: string): FlexSearchDocument {\n const index = createSearchIndex();\n\n for (const doc of docs) {\n addDocumentToIndex(index, doc, baseUrl);\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 url: docId, // docId is the full URL when indexed with baseUrl\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-core.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(url: string): Promise<ProcessedDoc | null> {\n if (!this.docs) {\n throw new Error('[FlexSearch] Provider not initialized');\n }\n\n // Direct lookup by URL\n return this.docs[url] ?? 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 { z } from 'zod';\nimport type { ProcessedDoc, SearchResult, DocsSearchParams } from '../../types/index.js';\nimport { searchIndex, type FlexSearchDocument } from '../../search/flexsearch-core.js';\n\n/**\n * Zod schema for docs_search input parameters\n */\nexport const docsSearchInputSchema = {\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/**\n * Tool definition for docs_search\n */\nexport const docsSearchTool = {\n name: 'docs_search',\n description:\n 'Search the documentation for relevant pages. Returns matching documents with URLs, snippets, and relevance scores. Use this to find information across all documentation.',\n inputSchema: docsSearchInputSchema,\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[]): 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 lines.push(` URL: ${result.url}`);\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 lines.push('Use docs_fetch with the URL to retrieve the full page content.');\n\n return lines.join('\\n');\n}\n","import { z } from 'zod';\nimport type { ProcessedDoc } from '../../types/index.js';\n\n/**\n * Zod schema for docs_fetch input parameters\n */\nexport const docsFetchInputSchema = {\n url: z\n .string()\n .url()\n .describe(\n 'The full URL of the page to fetch (e.g., \"https://docs.example.com/docs/getting-started\")'\n ),\n};\n\n/**\n * Tool definition for docs_fetch\n */\nexport const docsFetchTool = {\n name: 'docs_fetch',\n description:\n 'Fetch the complete content of a documentation page. Use this after searching to get the full markdown content of a specific page.',\n inputSchema: docsFetchInputSchema,\n};\n\n/**\n * Format page content for MCP response\n */\nexport function formatPageContent(doc: ProcessedDoc | null): string {\n if (!doc) {\n return 'Page not found. Please check the URL 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 // 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 { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\nimport { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';\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 { docsSearchTool, formatSearchResults } from './tools/docs-search.js';\nimport { docsFetchTool, formatPageContent } from './tools/docs-fetch.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 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 definitions from tool files\n */\n private registerTools(): void {\n // Register docs_search tool\n this.mcpServer.registerTool(\n docsSearchTool.name,\n {\n description: docsSearchTool.description,\n inputSchema: docsSearchTool.inputSchema,\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: [{ type: 'text' as const, text: formatSearchResults(results) }],\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 // Register docs_fetch tool\n this.mcpServer.registerTool(\n docsFetchTool.name,\n {\n description: docsFetchTool.description,\n inputSchema: docsFetchTool.inputSchema,\n },\n async ({ url }) => {\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(url);\n return {\n content: [{ type: 'text' as const, text: formatPageContent(doc) }],\n };\n } catch (error) {\n console.error('[MCP] Fetch error:', error);\n return {\n content: [{ type: 'text' as const, text: `Error fetching page: ${String(error)}` }],\n isError: true,\n };\n }\n }\n );\n }\n\n /**\n * Get a document by URL using the search provider\n */\n private async getDocument(url: string): Promise<ProcessedDoc | null> {\n if (!this.searchProvider) {\n return null;\n }\n\n if (this.searchProvider.getDocument) {\n return this.searchProvider.getDocument(url);\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"]}
@@ -104,7 +104,9 @@ interface FlattenedRoute {
104
104
  * Search result from FlexSearch
105
105
  */
106
106
  interface SearchResult {
107
- /** Route of the matching document */
107
+ /** Full URL of the matching document (use this with docs_fetch) */
108
+ url: string;
109
+ /** Route path of the matching document */
108
110
  route: string;
109
111
  /** Title of the document */
110
112
  title: string;
@@ -189,20 +191,11 @@ interface DocsSearchParams {
189
191
  limit?: number;
190
192
  }
191
193
  /**
192
- * Input parameters for docs_get_page tool
194
+ * Input parameters for docs_fetch tool
193
195
  */
194
- interface DocsGetPageParams {
195
- /** Route path of the page */
196
- route: string;
197
- }
198
- /**
199
- * Input parameters for docs_get_section tool
200
- */
201
- interface DocsGetSectionParams {
202
- /** Route path of the page */
203
- route: string;
204
- /** Heading ID of the section */
205
- headingId: string;
196
+ interface DocsFetchParams {
197
+ /** Full URL of the page to fetch */
198
+ url: string;
206
199
  }
207
200
  /**
208
201
  * Content extraction result from HTML
@@ -220,4 +213,4 @@ interface ExtractedContent {
220
213
  */
221
214
  declare const DEFAULT_OPTIONS: ResolvedPluginOptions;
222
215
 
223
- export { type DocHeading as D, type ExtractedContent as E, type FlattenedRoute as F, type McpServerConfig as M, type ProcessedDoc as P, type ResolvedPluginOptions as R, type SearchResult as S, type McpServerPluginOptions as a, DEFAULT_OPTIONS as b, type DocsGetPageParams as c, type DocsGetSectionParams as d, type DocsIndex as e, type DocsSearchParams as f, type McpManifest as g, type McpServerDataConfig as h, type McpServerFileConfig as i };
216
+ export { type DocHeading as D, type ExtractedContent as E, type FlattenedRoute as F, type McpServerConfig as M, type ProcessedDoc as P, type ResolvedPluginOptions as R, type SearchResult as S, type McpServerFileConfig as a, type McpServerPluginOptions as b, DEFAULT_OPTIONS as c, type DocsFetchParams as d, type DocsIndex as e, type DocsSearchParams as f, type McpManifest as g, type McpServerDataConfig as h };
@@ -104,7 +104,9 @@ interface FlattenedRoute {
104
104
  * Search result from FlexSearch
105
105
  */
106
106
  interface SearchResult {
107
- /** Route of the matching document */
107
+ /** Full URL of the matching document (use this with docs_fetch) */
108
+ url: string;
109
+ /** Route path of the matching document */
108
110
  route: string;
109
111
  /** Title of the document */
110
112
  title: string;
@@ -189,20 +191,11 @@ interface DocsSearchParams {
189
191
  limit?: number;
190
192
  }
191
193
  /**
192
- * Input parameters for docs_get_page tool
194
+ * Input parameters for docs_fetch tool
193
195
  */
194
- interface DocsGetPageParams {
195
- /** Route path of the page */
196
- route: string;
197
- }
198
- /**
199
- * Input parameters for docs_get_section tool
200
- */
201
- interface DocsGetSectionParams {
202
- /** Route path of the page */
203
- route: string;
204
- /** Heading ID of the section */
205
- headingId: string;
196
+ interface DocsFetchParams {
197
+ /** Full URL of the page to fetch */
198
+ url: string;
206
199
  }
207
200
  /**
208
201
  * Content extraction result from HTML
@@ -220,4 +213,4 @@ interface ExtractedContent {
220
213
  */
221
214
  declare const DEFAULT_OPTIONS: ResolvedPluginOptions;
222
215
 
223
- export { type DocHeading as D, type ExtractedContent as E, type FlattenedRoute as F, type McpServerConfig as M, type ProcessedDoc as P, type ResolvedPluginOptions as R, type SearchResult as S, type McpServerPluginOptions as a, DEFAULT_OPTIONS as b, type DocsGetPageParams as c, type DocsGetSectionParams as d, type DocsIndex as e, type DocsSearchParams as f, type McpManifest as g, type McpServerDataConfig as h, type McpServerFileConfig as i };
216
+ export { type DocHeading as D, type ExtractedContent as E, type FlattenedRoute as F, type McpServerConfig as M, type ProcessedDoc as P, type ResolvedPluginOptions as R, type SearchResult as S, type McpServerFileConfig as a, type McpServerPluginOptions as b, DEFAULT_OPTIONS as c, type DocsFetchParams as d, type DocsIndex as e, type DocsSearchParams as f, type McpManifest as g, type McpServerDataConfig as h };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { LoadContext, Plugin } from '@docusaurus/types';
2
- import { a as McpServerPluginOptions, M as McpServerConfig, P as ProcessedDoc, S as SearchResult, E as ExtractedContent, D as DocHeading, F as FlattenedRoute } from './index-4g0ZZK3z.mjs';
3
- export { b as DEFAULT_OPTIONS, c as DocsGetPageParams, d as DocsGetSectionParams, e as DocsIndex, f as DocsSearchParams, g as McpManifest, h as McpServerDataConfig, i as McpServerFileConfig, R as ResolvedPluginOptions } from './index-4g0ZZK3z.mjs';
2
+ import { b as McpServerPluginOptions, M as McpServerConfig, P as ProcessedDoc, S as SearchResult, E as ExtractedContent, D as DocHeading, F as FlattenedRoute } from './index-j-CdaS6k.mjs';
3
+ export { c as DEFAULT_OPTIONS, d as DocsFetchParams, e as DocsIndex, f as DocsSearchParams, g as McpManifest, h as McpServerDataConfig, a as McpServerFileConfig, R as ResolvedPluginOptions } from './index-j-CdaS6k.mjs';
4
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
5
  import { IncomingMessage, ServerResponse } from 'node:http';
6
6
  import FlexSearch from 'flexsearch';
7
+ import { z } from 'zod';
7
8
  import { Root } from 'hast';
8
9
 
9
10
  /**
@@ -30,11 +31,11 @@ declare class McpDocsServer {
30
31
  private initialized;
31
32
  constructor(config: McpServerConfig);
32
33
  /**
33
- * Register all MCP tools using the SDK's registerTool API
34
+ * Register all MCP tools using definitions from tool files
34
35
  */
35
36
  private registerTools;
36
37
  /**
37
- * Get a document by route using the search provider
38
+ * Get a document by URL using the search provider
38
39
  */
39
40
  private getDocument;
40
41
  /**
@@ -314,11 +315,12 @@ declare function loadSearchProvider(specifier: string): Promise<SearchProvider>;
314
315
  * Built-in FlexSearch content indexer.
315
316
  *
316
317
  * This indexer builds a local FlexSearch index and produces:
317
- * - docs.json: All processed documents keyed by route
318
+ * - docs.json: All processed documents keyed by full URL
318
319
  * - search-index.json: Exported FlexSearch index for runtime search
319
320
  */
320
321
  declare class FlexSearchIndexer implements ContentIndexer {
321
322
  readonly name = "flexsearch";
323
+ private baseUrl;
322
324
  private docsIndex;
323
325
  private exportedIndex;
324
326
  private docCount;
@@ -327,7 +329,7 @@ declare class FlexSearchIndexer implements ContentIndexer {
327
329
  * It respects the indexers configuration - if not included, it won't run.
328
330
  */
329
331
  shouldRun(): boolean;
330
- initialize(_context: ProviderContext): Promise<void>;
332
+ initialize(context: ProviderContext): Promise<void>;
331
333
  indexDocuments(docs: ProcessedDoc[]): Promise<void>;
332
334
  finalize(): Promise<Map<string, unknown>>;
333
335
  getManifestData(): Promise<Record<string, unknown>>;
@@ -352,8 +354,11 @@ interface IndexableDocument {
352
354
  type FlexSearchDocument = FlexSearch.Document<IndexableDocument, string[]>;
353
355
  /**
354
356
  * Build the search index from processed documents
357
+ *
358
+ * @param docs - Documents to index
359
+ * @param baseUrl - Optional base URL to construct full URLs as document IDs
355
360
  */
356
- declare function buildSearchIndex(docs: ProcessedDoc[]): FlexSearchDocument;
361
+ declare function buildSearchIndex(docs: ProcessedDoc[], baseUrl?: string): FlexSearchDocument;
357
362
  /**
358
363
  * Search the index and return results with weighted ranking
359
364
  *
@@ -387,7 +392,7 @@ declare class FlexSearchProvider implements SearchProvider {
387
392
  initialize(_context: ProviderContext, initData?: SearchProviderInitData): Promise<void>;
388
393
  isReady(): boolean;
389
394
  search(query: string, options?: SearchOptions): Promise<SearchResult[]>;
390
- getDocument(route: string): Promise<ProcessedDoc | null>;
395
+ getDocument(url: string): Promise<ProcessedDoc | null>;
391
396
  healthCheck(): Promise<{
392
397
  healthy: boolean;
393
398
  message?: string;
@@ -409,19 +414,8 @@ declare const docsSearchTool: {
409
414
  name: string;
410
415
  description: string;
411
416
  inputSchema: {
412
- type: "object";
413
- properties: {
414
- query: {
415
- type: string;
416
- description: string;
417
- };
418
- limit: {
419
- type: string;
420
- description: string;
421
- default: number;
422
- };
423
- };
424
- required: string[];
417
+ query: z.ZodString;
418
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
425
419
  };
426
420
  };
427
421
 
@@ -432,14 +426,7 @@ declare const docsFetchTool: {
432
426
  name: string;
433
427
  description: string;
434
428
  inputSchema: {
435
- type: "object";
436
- properties: {
437
- route: {
438
- type: string;
439
- description: string;
440
- };
441
- };
442
- required: string[];
429
+ url: z.ZodString;
443
430
  };
444
431
  };
445
432
 
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { LoadContext, Plugin } from '@docusaurus/types';
2
- import { a as McpServerPluginOptions, M as McpServerConfig, P as ProcessedDoc, S as SearchResult, E as ExtractedContent, D as DocHeading, F as FlattenedRoute } from './index-4g0ZZK3z.js';
3
- export { b as DEFAULT_OPTIONS, c as DocsGetPageParams, d as DocsGetSectionParams, e as DocsIndex, f as DocsSearchParams, g as McpManifest, h as McpServerDataConfig, i as McpServerFileConfig, R as ResolvedPluginOptions } from './index-4g0ZZK3z.js';
2
+ import { b as McpServerPluginOptions, M as McpServerConfig, P as ProcessedDoc, S as SearchResult, E as ExtractedContent, D as DocHeading, F as FlattenedRoute } from './index-j-CdaS6k.js';
3
+ export { c as DEFAULT_OPTIONS, d as DocsFetchParams, e as DocsIndex, f as DocsSearchParams, g as McpManifest, h as McpServerDataConfig, a as McpServerFileConfig, R as ResolvedPluginOptions } from './index-j-CdaS6k.js';
4
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
5
  import { IncomingMessage, ServerResponse } from 'node:http';
6
6
  import FlexSearch from 'flexsearch';
7
+ import { z } from 'zod';
7
8
  import { Root } from 'hast';
8
9
 
9
10
  /**
@@ -30,11 +31,11 @@ declare class McpDocsServer {
30
31
  private initialized;
31
32
  constructor(config: McpServerConfig);
32
33
  /**
33
- * Register all MCP tools using the SDK's registerTool API
34
+ * Register all MCP tools using definitions from tool files
34
35
  */
35
36
  private registerTools;
36
37
  /**
37
- * Get a document by route using the search provider
38
+ * Get a document by URL using the search provider
38
39
  */
39
40
  private getDocument;
40
41
  /**
@@ -314,11 +315,12 @@ declare function loadSearchProvider(specifier: string): Promise<SearchProvider>;
314
315
  * Built-in FlexSearch content indexer.
315
316
  *
316
317
  * This indexer builds a local FlexSearch index and produces:
317
- * - docs.json: All processed documents keyed by route
318
+ * - docs.json: All processed documents keyed by full URL
318
319
  * - search-index.json: Exported FlexSearch index for runtime search
319
320
  */
320
321
  declare class FlexSearchIndexer implements ContentIndexer {
321
322
  readonly name = "flexsearch";
323
+ private baseUrl;
322
324
  private docsIndex;
323
325
  private exportedIndex;
324
326
  private docCount;
@@ -327,7 +329,7 @@ declare class FlexSearchIndexer implements ContentIndexer {
327
329
  * It respects the indexers configuration - if not included, it won't run.
328
330
  */
329
331
  shouldRun(): boolean;
330
- initialize(_context: ProviderContext): Promise<void>;
332
+ initialize(context: ProviderContext): Promise<void>;
331
333
  indexDocuments(docs: ProcessedDoc[]): Promise<void>;
332
334
  finalize(): Promise<Map<string, unknown>>;
333
335
  getManifestData(): Promise<Record<string, unknown>>;
@@ -352,8 +354,11 @@ interface IndexableDocument {
352
354
  type FlexSearchDocument = FlexSearch.Document<IndexableDocument, string[]>;
353
355
  /**
354
356
  * Build the search index from processed documents
357
+ *
358
+ * @param docs - Documents to index
359
+ * @param baseUrl - Optional base URL to construct full URLs as document IDs
355
360
  */
356
- declare function buildSearchIndex(docs: ProcessedDoc[]): FlexSearchDocument;
361
+ declare function buildSearchIndex(docs: ProcessedDoc[], baseUrl?: string): FlexSearchDocument;
357
362
  /**
358
363
  * Search the index and return results with weighted ranking
359
364
  *
@@ -387,7 +392,7 @@ declare class FlexSearchProvider implements SearchProvider {
387
392
  initialize(_context: ProviderContext, initData?: SearchProviderInitData): Promise<void>;
388
393
  isReady(): boolean;
389
394
  search(query: string, options?: SearchOptions): Promise<SearchResult[]>;
390
- getDocument(route: string): Promise<ProcessedDoc | null>;
395
+ getDocument(url: string): Promise<ProcessedDoc | null>;
391
396
  healthCheck(): Promise<{
392
397
  healthy: boolean;
393
398
  message?: string;
@@ -409,19 +414,8 @@ declare const docsSearchTool: {
409
414
  name: string;
410
415
  description: string;
411
416
  inputSchema: {
412
- type: "object";
413
- properties: {
414
- query: {
415
- type: string;
416
- description: string;
417
- };
418
- limit: {
419
- type: string;
420
- description: string;
421
- default: number;
422
- };
423
- };
424
- required: string[];
417
+ query: z.ZodString;
418
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
425
419
  };
426
420
  };
427
421
 
@@ -432,14 +426,7 @@ declare const docsFetchTool: {
432
426
  name: string;
433
427
  description: string;
434
428
  inputSchema: {
435
- type: "object";
436
- properties: {
437
- route: {
438
- type: string;
439
- description: string;
440
- };
441
- };
442
- required: string[];
429
+ url: z.ZodString;
443
430
  };
444
431
  };
445
432