Skip to main content
Glama
mcp-server-docs-search

mcp-server-docs-search

README.md
# mcp-server-docs-search

**MCP server (Model Context Protocol) that lets Claude Code, Cursor, and other AI agents search your project's local Markdown docs. BM25 ranking, section-level results with line numbers, zero dependencies, no embeddings or API keys.**

[![CI](https://github.com/metraflaxtech-png/mcp-server-docs-search/actions/workflows/ci.yml/badge.svg)](https://github.com/metraflaxtech-png/mcp-server-docs-search/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue)
![Dependencies: none](https://img.shields.io/badge/dependencies-none-brightgreen)
![MCP](https://img.shields.io/badge/MCP-stdio%20server-8A2BE2)

Your agent should read *your* docs before it guesses. Point this server at a `docs/` folder (or the whole repo) and the agent gets three tools: search the docs, read one section, list what exists. Results are **sections** (split at headings), so the agent pulls 10 relevant lines instead of a 600-line page.

## Quick start (under a minute)

```bash
pipx install git+https://github.com/metraflaxtech-png/mcp-server-docs-search.git
# or: uvx --from git+https://github.com/metraflaxtech-png/mcp-server-docs-search.git mcp-server-docs-search --help
```

**Claude Code**

```bash
claude mcp add docs-search -- mcp-server-docs-search serve --root ./docs
```

**Cursor** (`.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "docs-search": {
      "command": "mcp-server-docs-search",
      "args": ["serve", "--root", "./docs"]
    }
  }
}
```

**Claude Desktop / other MCP clients**: same `command` and `args`, with an absolute `--root`.

Try it without an MCP client:

```bash
mcp-server-docs-search search "how do I rotate api keys" --root ./docs
```

## Example output

Against the sample docs in [`examples/docs`](examples/docs):

```text
$ mcp-server-docs-search search "how do I rotate api keys" --root examples/docs -k 3
1. guides/authentication.md:7  [Authentication > Rotating keys]  score=5.68
   Rotate keys every 90 days. Old keys keep working for 24 hours after rotation so deploys do not break.
2. guides/authentication.md:3  [Authentication > API keys]  score=4.05
   Create an API key in the dashboard under Settings > Keys. Send it in the `Authorization: Bearer <key>` header.
3. guides/rate-limits.md:1  [Rate limits]  score=1.36
   Every API key gets 600 requests per minute. When you go over, the API returns HTTP 429 with a `Retry-After` header.
```

`read_doc` over stdio, fetching just one section:

```text
> {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"read_doc","arguments":{"path":"guides/rate-limits.md","heading":"Retrying"}}}
< {"jsonrpc":"2.0","id":2,"result":{"content":[{"type":"text","text":"## Retrying\n\nBack off exponentially and respect `Retry-After`. Batch endpoints count as one request."}],"isError":false}}
```

## Tools

| Tool | Arguments | What it returns |
| --- | --- | --- |
| `search_docs` | `query`, `top_k` (default 5), `path_glob` | Ranked sections: `path:start-end [Heading > Sub]`, score, snippet |
| `read_doc` | `path`, optional `heading` | The whole doc, or one section by heading or `Parent > Child` breadcrumb |
| `list_docs` | optional `path_glob` | Every indexed doc and its section headings |

## How it works

- Indexes `.md`, `.mdx`, `.markdown`, `.rst`, and `.txt` under `--root`, skipping hidden folders, `node_modules`, virtualenvs, build output, and files over 1 MB.
- Splits each doc at Markdown headings (ignoring `#` lines inside code fences) and keeps the heading breadcrumb.
- Ranks with BM25 (k1 = 1.5, b = 0.75). Heading words count double, and identifiers like `max_tokens` match both whole and in parts.
- Re-indexes automatically when a doc is added, removed, or edited, so the agent never searches stale docs.
- Read-only, local, no network calls. Paths that escape the root, including through symlinks, are refused.

## FAQ

**Why BM25 instead of embeddings / vector search?**
For project docs, the words people search with (function names, config keys, error codes) usually appear in the docs verbatim, and keyword ranking handles that well with zero setup: no model download, no API key, no vector database. Hybrid ranking is a welcome contribution; see the issues.

**How do I give Claude Code access to my documentation?**
Run `claude mcp add docs-search -- mcp-server-docs-search serve --root ./docs` in your project, then ask Claude a question about your project. It can call `search_docs` and `read_doc`.

**Is this RAG?**
It is the retrieval half of RAG, exposed as tools so the agent decides when to search. The agent's model does the generation.

**How big a docs folder can it handle?**
It keeps the index in memory and rebuilds when files change. That is comfortable for typical project docs (hundreds of files). Very large doc sets would benefit from incremental re-indexing, which is an open issue.

**Does it work with Windsurf, Zed, VS Code, or other MCP clients?**
Any client that runs MCP servers over stdio should work. It implements `initialize`, `ping`, `tools/list`, and `tools/call` (protocol versions 2025-06-18, 2025-03-26, 2024-11-05).

## Development

```bash
python3 -m pip install -e ".[dev]"
python3 -m pytest
```

CI runs the tests on Python 3.10–3.13 plus a real stdio smoke test. See [CONTRIBUTING.md](CONTRIBUTING.md) and the [good first issues](https://github.com/metraflaxtech-png/mcp-server-docs-search/labels/good%20first%20issue). Questions or ideas? Open a [discussion](https://github.com/metraflaxtech-png/mcp-server-docs-search/discussions). Please follow the [Code of Conduct](CODE_OF_CONDUCT.md).

## License

[MIT](LICENSE) © 2026 Sangram More

## More from metraflaxtech-png

- [agent-toolbelt](https://github.com/metraflaxtech-png/agent-toolbelt): ready-to-use skills, rules, and prompts for AI coding agents (Claude Code, Cursor, AGENTS.md)
- [prompttest](https://github.com/metraflaxtech-png/prompttest): regression-test LLM prompts with YAML suites in CI
- [mcp-server-repo-context](https://github.com/metraflaxtech-png/mcp-server-repo-context): MCP server giving Claude Code and Cursor token-budgeted repo context
- [agents-md-sync](https://github.com/metraflaxtech-png/agents-md-sync): one source for AGENTS.md, CLAUDE.md, Cursor rules, and Copilot instructions
- [llm-tool-schema-lint](https://github.com/metraflaxtech-png/llm-tool-schema-lint): lint LLM function-calling and MCP tool schemas before your model sees them

TDQS

A4/5.0

Scored across 3 tools

Disambiguation5/5

Each tool maps to a distinct retrieval mode: keyword search (search_docs), content retrieval (read_doc), and enumeration of the index (list_docs). There is no realistic scenario where an agent cannot pick the right one, and the descriptions explicitly cross-reference each other's outputs (headings, line numbers).

Naming Consistency5/5

All three names follow the same verb_noun pattern (search_docs, read_doc, list_docs) with the same 'doc(s)' noun, and the singular/plural distinction is used naturally between collection-level and single-item operations.

Tool Count5/5

Three tools is exactly the right surface for a read-only documentation lookup server — search to find, read to retrieve, list to survey. Nothing is padded and nothing feels arbitrarily omitted.

Completeness4/5

Discovery (list, search) and retrieval (whole doc or section) cover the core read lifecycle with no dead ends for a read-only domain. Minor gaps: no way to read a file that isn't indexed, and search offers no filtering (by file type, path, or result count).

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues