@writechoice/docmcp
v0.1.2
Published
Index MDX docs and serve them as an MCP server via Cloudflare Workers
Downloads
339
Keywords
Readme
@writechoice/docmcp
Turns any MDX documentation site into an MCP server.
Works with Docusaurus, Fumadocs, Mintlify, or any folder of .md/.mdx files.
How it works
your project/
docs/ ← your MDX files
mcp/ ← generated by docmcp init
src/
index.js ← Cloudflare Worker
mcp.js
docs-data.json ← generated by docmcp index, updated by CI
wrangler.toml
package.json
.github/
workflows/
docmcp.yml ← generated by docmcp actionThe CLI scaffolds the mcp/ folder inside your project. From there you deploy the Worker yourself. CI keeps docs-data.json up to date automatically on every docs change.
Setup
1. Install the CLI
npm install -g @writechoice/docmcpOr use npx @writechoice/docmcp anywhere without installing.
2. Choose your Cloudflare deployment
Option A — Standalone Worker (any project):
docmcp cf workers my-project-docsCreates ./mcp/ with the Worker source, wrangler.toml, and an empty docs-data.json.
Option B — Pages Function (site already on Cloudflare Pages):
docmcp cf pagesCreates functions/mcp.js in your project. Deploys automatically with your next Pages push — no separate Worker needed.
3. Index your docs
docmcp index ./docsThis writes ./mcp/docs-data.json with all your parsed pages.
4. Deploy to Cloudflare
If you used cf workers:
cd mcp
npm install
wrangler login # one time
wrangler deployYou'll get a URL like https://my-project-docs.yourname.workers.dev.
If you used cf pages: just push — Pages deploys the function automatically. Your endpoint is https://your-site.pages.dev/mcp.
5. Set up CI (optional)
docmcp actionCreates .github/workflows/docmcp.yml. Every time you push changes to your docs, the action re-indexes and commits the updated docs-data.json. You deploy to Cloudflare manually whenever you're ready.
Connecting AI clients
Claude Code
Add to .claude/settings.json:
{
"mcpServers": {
"docs": {
"url": "https://my-project-docs.yourname.workers.dev/mcp"
}
}
}Cursor
Settings → MCP → Add server → paste the /mcp URL.
Claude.ai
Settings → Integrations → Add → paste the /mcp URL.
CLI reference
docmcp init [worker-name]
Scaffolds ./mcp/ in the current directory. worker-name defaults to the current folder name and becomes the CF Worker name.
docmcp init my-project-docsdocmcp index <docs-dir>
Parses all .md/.mdx files and writes ./mcp/docs-data.json.
docmcp index ./docs| Option | Default | Description |
| ------------------------ | ---------------------- | -------------------------------------------------- |
| -o, --output <path> | ./mcp/docs-data.json | Where to write the index |
| -f, --framework <type> | auto | docusaurus | fumadocs | mintlify | auto |
| --base-url <url> | (empty) | Public URL of your docs site |
| --max-content <chars> | 8000 | Max characters stored per page |
docmcp cf workers [worker-name]
Scaffolds ./mcp/ with a standalone Cloudflare Worker. Use when your project isn't on Pages, or when you want a separate deployment.
docmcp cf workers my-project-docsdocmcp cf pages
Adds functions/mcp.js to your project. Use when your site is already on Cloudflare Pages — the /mcp route deploys automatically with the site, no separate Worker needed.
docmcp cf pagesUse one or the other, not both.
docmcp action
Creates .github/workflows/docmcp.yml. Re-indexes docs on every push and commits the result.
docmcp action| Option | Default | Description |
| ------------------- | --------- | ------------------------------------ |
| --docs-dir <path> | docs | Docs directory to index |
| --branch <branch> | main | Branch that triggers the workflow |
| --paths <glob> | docs/** | File paths that trigger the workflow |
MCP tools exposed
| Tool | Description |
| ---------------------------- | ------------------------------------------- |
| list_docs | Lists all indexed pages with title and path |
| get_doc(path) | Returns the full content of a page |
| search_docs(query, limit?) | Keyword search across all pages |
Bundle size
docs-data.json is bundled into the Worker at deploy time. Cloudflare's free tier allows up to 1 MB. If your docs are large, lower --max-content:
docmcp index ./docs --max-content 3000