context-sniper-mcp
This server provides four MCP tools for working with code repositories: index_repo scans a repo and builds a chunked search index, search_code finds relevant code snippets using BM25 scoring, read_snippet reads bounded line ranges from files safely, and run_test_filtered runs a fixed allowlist of test commands and returns filtered failure output.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@context-sniper-mcpsearch code for 'validateUser' in current repo"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
context-sniper-mcp
A tiny local MCP server that indexes a repository into line-range chunks and serves compact "evidence packets" (file + lines + score + snippet) instead of dumping whole files into the model's context. Meant to be shared by Claude Code and Codex to cut token usage when exploring or debugging a repo.
No database — the index is a single JSON file written to
<repo>/.context-index/chunks.json.
Tools
index_repo
{ root }— scansroot(skippingnode_modules,.git,dist,build,.next,coverage,.venv,target), chunks supported files (ts tsx js jsx py java go rs md json yml yaml toml) into ~80-line sliding windows (max 120 lines/chunk), and writesroot/.context-index/chunks.json. Dependency lockfiles (package-lock.json,pnpm-lock.yaml,npm-shrinkwrap.json), minified bundles (*.min.js,*.bundle.js), and files larger than 512 KB are skipped so the index stays focused on real source.search_code
{ root, query, topK? }— loads the chunk index and scores it againstquerywith a BM25-style ranker. Returns up totopK(defaulthits, each with
FILE,LINES,SCORE, and a snippet capped at 4000 characters. If no index exists yet, it tells you to runindex_repofirst.
read_snippet
{ root, path, startLine, endLine }— reads an explicit line range from one file insideroot. Capped at 300 lines per call (longer ranges are truncated with a note).pathis resolved and checked againstroot; anything that would escaperootis refused.run_test_filtered
{ root, command }— runs one of a fixed allowlist of commands (npm_test→npm test,pnpm_test→pnpm test,pytest→pytest -q) viaspawnwithshell: false— no arbitrary shell execution. Captures stdout/stderr, keeps only lines matchingerror|failed|failure|assert|expected|received|tracebackor a test-file path, tail-capped at 120 lines. If nothing matches, falls back to the last 80 raw output lines. Always reports the resolved command and exit code.
There is intentionally no run_shell or equivalent — only the four tools
above are exposed.
Related MCP server: Repo Interrogator
Installation
For installation and client configuration, see INSTALL.md.
Recommended usage
Call index_repo once per repo (and again after large changes) before doing anything else.
Before fixing a bug, prefer search_code over opening files — search for the symptom, error message, or function name first.
Don't read a whole file up front. Let the evidence packet from
search_codetell you where to look.If a test fails, use run_test_filtered to get the trimmed failure output instead of piping raw test-runner logs into context.
If a returned snippet cuts off before the context you need, use read_snippet with a widened
startLine/endLinerange around it (still capped at 300 lines per call) rather than reading the entire file.
Project layout
context-sniper-mcp/
├── package.json
├── tsconfig.json
├── src/
│ ├── index.ts # MCP server wiring + tool registration
│ ├── repo-index.ts # scanning, chunking, safe path resolution, index I/O
│ ├── search.ts # BM25-style scoring + evidence packet formatting
│ ├── snippets.ts # bounded, path-safe line-range reads
│ └── output-gate.ts # allowlisted test runner + output filtering
├── build/ # compiled output (npm run build)
├── INSTALL.md
├── HUMAN.md
└── README.mdLicense
MIT
Available Tools
4 toolsindex_repoIndex repoA
Scan a repository and build a lightweight chunk index at /.context-index/chunks.json. Run this once before search_code (and re-run after significant code changes).
| Name | Required | Description | Default |
|---|---|---|---|
| root | Yes | Absolute path to the repository root |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, but the description transparently states the tool creates a file at a known path and is read-only in nature (scanning). It lacks details on permissions or safety, but the core behavior is clear.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences: first states action and output, second gives usage context. No unnecessary words, front-loaded with the key purpose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple index-building tool with one required param and no output schema, the description fully covers what it does, where output goes, and when to run it.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% with a single parameter 'root' described as 'Absolute path to the repository root.' The description adds value by showing the output path relative to root, exceeding schema info.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states 'Scan a repository and build a lightweight chunk index' with a specific output location. It distinguishes itself from siblings like search_code by being a prerequisite indexing step.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly advises 'Run this once before search_code (and re-run after significant code changes),' providing clear when-to-use and maintenance guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
read_snippetRead snippetA
Read an explicit line range from a single file inside root. Use this only after search_code narrows down a location and the returned snippet isn't enough context. Capped at 300 lines per call.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File path, relative to root (or absolute, but must resolve inside root) | |
| root | Yes | Absolute path to the repository root | |
| endLine | Yes | 1-based end line, inclusive | |
| startLine | Yes | 1-based start line, inclusive |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Discloses the 300-line cap and that it reads from a file inside root. No annotations, so description carries full burden; could mention read-only nature or return format but fairly transparent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, no fluff, front-loaded with purpose then usage. Every word earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple tool with full schema coverage and no output schema, the description adequately covers purpose, usage, and limitations. Could mention return type but not critical.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% so baseline 3. Description adds the line cap but repeats 'line range' which is already in schema. Minimal added value beyond schema fields.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Clearly states it reads a specific line range from a single file inside root, and distinguishes from siblings by referencing search_code for narrowing down locations.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly says to use only after search_code narrows a location and when more context is needed, providing a clear condition and alternative.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
run_test_filteredRun test (filtered)A
Run one of a fixed allowlist of test commands (no arbitrary shell) and return only the filtered failure-relevant output: command, exit code, and lines matching error/failed/assert/expected/traceback/test-file-path, tail-capped at 120 lines (falls back to last 80 raw lines if nothing matches).
| Name | Required | Description | Default |
|---|---|---|---|
| root | Yes | Absolute path to the repository root | |
| command | Yes | One of: npm_test, pnpm_test, pytest |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description discloses key behaviors: no arbitrary shell, filtered output based on specific patterns, tail-capped at 120 lines with fallback to 80 raw lines. No annotations are provided, so the description carries the full burden and does so thoroughly.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence that is comprehensive but somewhat long. It front-loads the core purpose and includes all necessary details, though it could be slightly more concise.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity (2 parameters, no output schema), the description fully covers input constraints and output behavior, including matching patterns and fallback logic, making it complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% with both parameters described. The description does not add new semantic information beyond what the schema provides, so a baseline of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool runs test commands from a fixed allowlist, not arbitrary shell commands, and returns filtered failure-relevant output. It distinguishes from sibling tools (index_repo, search_code, read_snippet) which have different purposes.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for running tests and getting filtered output. It does not explicitly mention when not to use or suggest alternatives, but the context is clear enough given the tool's specific purpose.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_codeSearch codeA
Search the previously built chunk index with a BM25-style keyword score and return a compact evidence packet (FILE / LINES / SCORE + snippet) instead of full files. Call index_repo first if no index exists.
| Name | Required | Description | Default |
|---|---|---|---|
| root | Yes | Absolute path to the repository root | |
| topK | No | Number of results to return (default 5) | |
| query | Yes | Natural language or keyword query |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Without annotations, the description carries full behavioral disclosure burden. It reveals the search algorithm (BM25-style), output structure (compact evidence packet), and dependency on a pre-built index. It does not discuss failure modes or idempotency, but for a code search tool this level of detail is adequate.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, front-loaded with the core action and output description. Every part is essential, with zero filler or redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no output schema, the description explains the return format (compact evidence packet). It addresses the key prerequisite (index_repo). Missing details about side effects or read-only nature, but overall sufficient for a search tool with three parameters.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema covers all three parameters (100% coverage), baseline is 3. The description adds minor value by mentioning 'BM25-style keyword score' which hints at how the query parameter is used, but it does not elaborate on 'root' or 'topK' beyond schema definitions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's action: searching a code chunk index using BM25-style keyword scoring. It specifies the return format (compact evidence packet with FILE/LINES/SCORE + snippet) and distinguishes itself from siblings like index_repo (precondition) and read_snippet (full file retrieval).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly advises to call index_repo first if no index exists, providing a clear prerequisite. Although it does not explicitly state when not to use the tool or mention alternatives, the context from sibling tools and the description's focus on searching versus reading or testing implies appropriate usage.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
4 tool updates
v0.1.0- First observed
index_repo - First observed
read_snippet - First observed
run_test_filtered - First observed
search_code
TDQS
Each tool has a distinct, non-overlapping purpose: indexing, searching, reading snippets, and running tests. No ambiguity in choosing between them.
All tool names follow a consistent verb_noun (or verb_noun_adjective) pattern in snake_case, making the action and target immediately clear.
Four tools cover the core workflow (index, search, read, test) without extraneous clutter. The count fits the domain perfectly.
The tool set provides a complete loop for code understanding and test failure analysis: build index, search, read context, run tests with filtered output. No obvious gaps for the stated purpose.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
An MCP server that gives your AI access to the source code and docs of all public github repos
Agent-native MCP server over the public saagarpatel.dev corpus. Read-only, stateless.
An MCP server that provides tools to discover and retrieve podcast episodes transcripts.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceA local MCP server that provides AI coding assistants with semantic search capabilities over codebases. It indexes code using local embeddings and exposes tools for efficient code retrieval, saving tokens and improving response quality.314MIT
- AlicenseAqualityAmaintenanceA local-first MCP server that enables AI tools to safely inspect and search code repositories, providing indexing, deterministic BM25 search, code outlining, and context bundles without code modification.91MIT
- AlicenseAqualityBmaintenanceMCP server that indexes your codebase's public API at startup and serves it via compact tool responses, saving tokens vs reading source files.521MIT
- AlicenseAqualityBmaintenanceAn MCP server that indexes reference repositories and provides tools for AI coding agents to retrieve lossless code context, enabling reasoning over codebases larger than the agent's context window.82Apache 2.0
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/wqiang-io/context-sniper-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server