contextsliver
An MCP server that indexes codebases into a local graph and provides on-demand context retrieval for AI coding agents, reducing token usage by tracking session history and delivering only relevant code subgraphs.
README
ContextSliver
On-demand context management for AI coding agents. Stop reading whole files — ask for the connected subgraph instead.
<p align="center"> <img src="assets/hero-banner.jpg" alt="ContextSliver — from chaos to clarity: on-demand code context for AI agents" width="800"> </p>
The problem
When you ask an AI coding agent (Claude Code, Cursor, Cline) to "fix the bug in AuthService," it repeatedly reads entire files to find the 5% that's relevant — burning 40,000–80,000 tokens on a question that needed ~3,000.
find . -name "*.ts" → 2,000 tokens (a file listing)
cat AuthService.ts → 3,000 tokens (whole file)
grep -r "AuthService" → 5,000 tokens (40 matches)
cat AuthMiddleware.ts → 2,500 tokens (whole file, again)
... × 10 more ...
Existing tools don't fully fix it: Graphify dumps one enormous whole-repo map into context up front; Repomix packs the entire repo into one file; Aider's repo-map sends a whole-repo summary with every message. None of them track what the agent has already seen this session.
What ContextSliver does
ContextSliver runs as a background MCP server on your machine. It indexes your codebase into a local SQLite graph of every function, class, and import. When the agent needs context, it calls an MCP tool instead of reading files:
Agent: "What connects to AuthService? Budget: 2,000 tokens."
ContextSliver:
symbol: AuthService (src/auth/AuthService.ts)
callers: [AuthMiddleware, LoginController] ← who uses it
dependencies: [UserRepository, TokenService] ← what it uses
already_in_context: [UserRepository] ← skipped, agent already has it
// ~380 tokens
Three things make it different:
- On-demand pruning — never sends the whole graph, only the connected subgraph for the task.
- Session ledger — tracks what the agent has already seen and skips re-sending it.
- One-command setup —
npx contextsliver init. No database server, no API key.
Quickstart
# In your project root:
npx contextsliver init # creates .sliver/, .mcp.json, CLAUDE.md, indexes the repo
npx contextsliver start # runs the MCP server + file watcher (stdio)
Then restart Claude Code / Cursor / Cline — they'll pick up the five tools automatically. See the templates for client-specific config.
The five MCP tools
| Tool | What it does | Typical tokens |
|---|---|---|
cs_index_repo |
Trigger a full re-index | ~50 |
cs_get_context |
Symbol definition + immediate connections | ~300–800 |
cs_blast_radius |
All callers + dependents up to N hops | ~500–2,000 |
cs_search_symbols |
Full-text search across indexed symbols | ~200–600 |
cs_index_status |
Index health, file count, last-updated | ~100 |
Pass the session_id from your first cs_get_context call to every subsequent call to enable
deduplication.
Supported languages
- TypeScript / JavaScript / TSX (v0.1)
- Python (v0.1)
- Go, Rust, Java — planned (see roadmap)
Adding a language = add a grammar package + a grammars/<lang>/tags.scm query + a fixture. See
CONTRIBUTING.md.
How it works
Your codebase ──chokidar──▶ Parser (Tree-sitter) ──▶ SQLite graph (.sliver/index.db)
│
MCP server (stdio) ◀──────────────────┘
│ session ledger (.sliver/sessions.db)
▼
Claude Code / Cursor / Cline
- Parser: Tree-sitter extracts symbols + imports per file.
- Graph engine: stores symbol→symbol edges; bidirectional BFS (
blastRadius) for blast radius with cycle detection. - Session manager: per-session ledger computes deltas so already-sent context is skipped.
- MCP server: exposes the five tools over stdio.
Token counting
Counts use gpt-tokenizer (cl100k_base) and are
labeled ~approximate — close enough for budget guidance, not billing.
Development
npm install
npm test # unit + integration tests
npm run test:bench # indexing benchmarks
npm run build # tsc → dist/
npm run lint # eslint
Requires Node ≥ 20.
Roadmap
- v0.1 ✅ TS/JS + Python, SQLite graph, session ledger, 5 tools, CLI, watcher
- v0.2 — incremental indexing polish, Cursor integration, CI benchmarks
- v0.3 — Go + Rust, monorepo workspace resolution, language-plugin docs
- v0.4 — PreToolUse hook, Java, published token-reduction benchmarks
- v0.5 — Streamable HTTP transport, DuckDB backend for 50k-file repos, PageRank ranking
- v1.0 — frozen API, optional native (napi-rs) engine, SCIP/LSP precision backend
See contextsliver-spec.md for the full specification.
License
MIT © Muneeb Ur Rehman
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。