search-mcp
Provides an MCP server with a search tool for agents, backed by Cloudflare AI Search and a synced corpus of git repositories.
README
search-mcp
Open-source toolkit for Cloudflare AI Search:
- MCP Worker (
src/mcp.ts) -- bearer-gated Streamable-HTTP MCP with asearchtool for agents. - Query Worker (
src/index.ts) -- CORS + Turnstile + rate-limitedPOST /askthat streams answers for a browser widget. - Corpus sync (
scripts/sync.mjs,scripts/sync-runner.mjs) -- git-tracked sources to R2, with extension remapping so TypeScript, Dockerfiles, and other text AI Search would otherwise skip get indexed.
git repos -> sync.mjs -> R2 bucket -> AI Search instance -> /ask + /mcp
Quick start
npm install
cp wrangler.toml.example wrangler.toml
cp wrangler.mcp.toml.example wrangler.mcp.toml
cp scripts/targets.json.example scripts/targets.json
# edit the three files for your account, instance, bucket, and repos
npm run typecheck
npm test
Provision R2 + AI Search, sync your corpus, deploy both Workers. Step-by-step: docs/DEPLOY.md.
Workers
| Worker | Entry | Endpoint | Auth |
|---|---|---|---|
| Query | wrangler.toml |
POST /ask, GET /health |
Turnstile (optional) + CORS allowlist |
| MCP | wrangler.mcp.toml |
POST /mcp, GET /health |
Authorization: Bearer (fail closed) |
Deploy separately so browser traffic and agent traffic can bind different AI Search instances if you want.
npm run deploy # query Worker
npm run deploy:mcp # MCP Worker
wrangler secret put MCP_TOKEN -c wrangler.mcp.toml
wrangler secret put TURNSTILE_SECRET # optional; skips verification when unset
MCP client wiring
{
"mcpServers": {
"search-mcp": {
"type": "http",
"url": "https://YOUR_MCP_HOST/mcp",
"headers": { "Authorization": "Bearer YOUR_TOKEN" }
}
}
}
MCP_TOKEN accepts a single token or comma-separated name=token pairs for per-consumer attribution in logs.
Corpus sync
export R2_ACCESS_KEY_ID=... R2_SECRET_ACCESS_KEY=... CLOUDFLARE_ACCOUNT_ID=...
export CORPUS_GIT_ORG=your-org GITHUB_TOKEN=... # for sync-runner clone auth
npm run sync:dry # plan upload for the default `corpus` target
npm run sync # upload + prune
npm run sync:run # isolated clone root, sync all targets, optional reindex
The sync remaps non-native extensions (.ts, .tsx, extensionless Dockerfile, .service, etc.) to .txt keys so AI Search indexes them. See scripts/sync-ingest.mjs.
If you name a target public, optional boundary checks refuse overlap with restrictedRepos and can verify GitHub repo visibility before upload.
Ask widget
Copy public/ask-widget.js and public/ask-widget.css to your docs site:
<div id="docs-ask"></div>
<script defer src="/ask-widget.js"
data-endpoint="https://search.example.com/ask"
data-target="#docs-ask"
data-label="Ask the docs"
data-sitekey="YOUR_TURNSTILE_SITEKEY"></script>
License
AGPL-3.0-only. See LICENSE.
Community
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.