This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
npm run build # Build with tsup (ESM-only output)
npm run dev # Watch mode for development
npm run lint # Run ESLint and Prettier check
npm run lint:fix # Auto-fix lint issues
npm run typecheck # TypeScript type checking
npm run test # Run unit tests with Vitest
npm run test:watch # Run tests in watch mode
npm run test:mcp # Run Playwright MCP integration tests
npm run test:all # Run lint, typecheck, and all testsRun a single test file:
npx vitest run tests/html-to-markdown-test.tsThis is a Docusaurus plugin that exposes documentation as an MCP (Model Context Protocol) server for AI agents.
Build Time (src/plugin/): The Docusaurus plugin runs during docusaurus build:
docusaurus-plugin.ts- Main plugin withpostBuildhook- Processes HTML files → extracts content → converts to markdown → builds search index
- Outputs artifacts to
build/mcp/(docs.json, search-index.json, manifest.json)
Runtime (src/mcp/, src/adapters/): Serverless functions serve MCP requests:
McpDocsServerclass wraps the official MCP SDK- Platform adapters (Vercel, Netlify, Cloudflare) handle HTTP → MCP translation
- Two modes: file-based (Node.js) or pre-loaded data (Workers)
The package has three export paths configured in package.json:
.→ Main plugin + MCP server (src/index.ts)./adapters→ Platform handlers (src/adapters-entry.ts)./theme→ React components (src/theme/index.ts)
src/mcp/server.ts- Core MCP server using@modelcontextprotocol/sdksrc/mcp/tools/- MCP tool definitions (docs_search,docs_fetch)src/processing/- HTML parsing, markdown conversion, heading extractionsrc/search/- FlexSearch integration for full-text searchsrc/providers/- Pluggable indexer/search provider systemsrc/cli/verify.ts- CLI for verifying build output
Indexers and search providers are pluggable via the src/providers/ system:
ContentIndexer- Processes docs at build time (e.g., FlexSearchIndexer)SearchProvider- Handles queries at runtime (e.g., FlexSearchProvider)
- Unit tests:
tests/*.tsusing Vitest - Integration tests:
tests/playwright/mcp.spec.tsusing@gleanwork/mcp-server-tester
ESM-only ("type": "module"). All imports use .js extensions in source files.