ctx
An MCP server that converts GitHub repositories and documentation sites into token-counted, searchable context blobs for AI agents, with tools like pack_repo, search_context, and pack_docs.
README
ctx.vanshul.com
A public Model Context Protocol (MCP) server, running as a Cloudflare Worker, that turns a GitHub repository or a documentation site into agent-ready context. Point an AI agent at it and it can pack a whole repo (or crawl a docs site) into one token-counted blob — or search it and get back only the relevant passages, each with its file/URL and line.
It's the agent-first companion to mcp/: where mcp reads a single
web page, ctx reads whole repos and doc sites. The repo pipeline fetches,
gunzips and parses the tarball in-process; docs extraction reuses Mozilla
Readability + Turndown.
Endpoint
POST https://ctx.vanshul.com/mcp # JSON-RPC 2.0 (MCP)
GET https://ctx.vanshul.com/health # { ok: true, tools: [...] }
Tools
| Tool | Input | Returns |
|---|---|---|
pack_repo |
{ repo, ref?, include?, exclude?, max_tokens? } |
The repo as one context blob with ==== path ==== headers + token estimate |
search_context |
{ repo, query, ref?, include?, exclude?, max_matches?, context_chars? } |
Only the passages matching query, each with file, line and score |
list_files |
{ repo, ref?, include?, exclude? } |
JSON: the text files ctx would include, with byte sizes |
get_file |
{ repo, path, ref? } |
The full text of a single file |
pack_docs |
{ url, depth?, max_pages?, max_tokens? } |
A crawled docs site as one context blob (each page → Markdown) |
search_docs |
{ url, query, depth?, max_pages?, max_matches?, context_chars? } |
Only the docs passages matching query, each with page URL, line and score |
repo is owner/repo, owner/repo/ref, or a github.com URL. url (for the
docs tools) is an absolute http(s) docs page to start crawling from.
Connect from an MCP client
{ "mcpServers": { "ctx": { "url": "https://ctx.vanshul.com/mcp" } } }
Stdio-only clients bridge with npx mcp-remote https://ctx.vanshul.com/mcp.
Add it to your client
- Cursor — Settings → MCP → Add new server, or drop this into
~/.cursor/mcp.json:{ "mcpServers": { "ctx": { "url": "https://ctx.vanshul.com/mcp" } } } - Claude Desktop — add the same block to
claude_desktop_config.json(Settings → Developer → Edit Config). If your version is stdio-only, use:{ "mcpServers": { "ctx": { "command": "npx", "args": ["mcp-remote", "https://ctx.vanshul.com/mcp"] } } } - Continue / VS Code — add
ctxwith URLhttps://ctx.vanshul.com/mcpto your MCP servers config.
Try it with curl
# Pack a repo, capped to 8000 tokens
curl -s https://ctx.vanshul.com/mcp -H 'content-type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call",
"params":{"name":"pack_repo","arguments":{"repo":"sindresorhus/slugify","max_tokens":8000}}}'
# Search a repo for just the relevant passages
curl -s https://ctx.vanshul.com/mcp -H 'content-type: application/json' \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call",
"params":{"name":"search_context","arguments":{"repo":"sindresorhus/slugify","query":"replace separator"}}}'
Layout
ctx/
├── src/
│ ├── worker.ts # entry: routes /mcp, /health, rate limit, CORS
│ ├── mcp.ts # JSON-RPC dispatch + the six tool definitions
│ ├── github.ts # fetch tarball, gunzip, parse tar, filter files (no deps)
│ ├── pack.ts # assemble the context blob + token estimate
│ ├── search.ts # ranked passage search over files (file + line)
│ ├── docs.ts # crawl a docs site into pages (BFS, same-section)
│ ├── extract.ts # HTML -> Markdown / links (Readability + Turndown)
│ ├── fetcher.ts # bounded fetch with re-validated redirects (SSRF)
│ └── security.ts # SSRF guard (block private/internal addresses)
├── public/
│ ├── index.html # landing page (served for non-API paths)
│ ├── og.png / og.svg
│ ├── robots.txt
│ └── sitemap.xml
├── tests/ # vitest: github (tar parsing), pack, search, mcp, worker
├── docs/ # architecture, tools/API reference, deployment
├── wrangler.toml
├── package.json
└── tsconfig.json
Develop & deploy
cd ctx
npm install
npm run typecheck
npm test # vitest — full suite
npm run dev # local worker at http://localhost:8787 (POST /mcp)
npm run deploy # wrangler deploy
How it works
owner/repo → github.com tarball → DecompressionStream('gzip')
→ in-process tar parse → drop binaries/lockfiles/build dirs
→ pack (concat + token estimate) OR search (ranked passages)
The GitHub URL is always constructed from a fixed owner/repo slug, so the repo
tools have no SSRF surface. The docs tools fetch caller-supplied URLs, so every
URL and redirect hop is re-validated against the SSRF guard. Downloads are
bounded (timeout, size caps, page/file-count caps) and results are cached
per-isolate for a few minutes.
Security & limits
- No SSRF: input is a repo slug, not an arbitrary URL; only github.com is fetched.
- Bounded: 20s download timeout, ~60 MB uncompressed cap, 512 KB/file, ≤3000 files, per-IP rate limit.
- Stateless & private: no code stored, no LLM in the loop; public repos by default (private with a token).
Authentication (optional)
Set a GITHUB_TOKEN Worker secret to lift GitHub's rate limit (60 → 5,000/hour) and
read private repos:
wrangler secret put GITHUB_TOKEN
The token is a Worker secret only — never a tool argument — so it can't leak to an agent.
Documentation
- docs/architecture.md — modules, pipeline, tar parsing, limits
- docs/tools.md — full tool & JSON-RPC API reference
- docs/deployment.md — Cloudflare Worker + custom-domain deploy
License
MIT © Vanshul Goyal
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。