docs_search
Enables AI agents to search project documentation via a semantic index, returning relevant markdown files to read before editing code.
README
docs_search MCP
docs_search MCP is a small Model Context Protocol server that lets an AI agent find the right project documentation before it edits code.
<p align="center"> <img src="assets/readme/docs-search-call.png" alt="docs_search MCP call returning relevant documentation files" width="900"> </p>
The repository contains two pieces:
knowledge-server.mjsexposes MCP tools:docs_searchanddocs_reindex.scripts/ai/build-index.shscans a project'sdocs/folder and writes.semantic-index.json.
It also includes a reusable documentation-update prompt pack:
prompts/documentation/docs-rules.prompt.md— the final prompt you send to Claude after a coding session when you want it to review the work and update project docs.prompts/documentation/правила-документации.md— the source text embedded into that prompt.
The important idea is simple: documentation stays inside each project, but the AI does not have to guess which markdown file to read. It asks docs_search with a symptom or task, the router selects relevant files from .semantic-index.json, and the agent reads only those files.
Why This Exists
Large projects collect many facts, fixes, design principles, and workflow notes. A normal README cannot carry all of that context, and asking an AI to read the whole docs/ folder wastes context.
This MCP creates a narrow lookup step:
- A project stores docs in
docs/knowledge/,docs/methodology/,docs/product/, anddocs/meta/. build-index.shsummarizes every markdown file into tags and user-visible symptoms..semantic-index.jsonbecomes a compact routing table.docs_searchsends the developer request plus that index to Gemini or Claude.- The tool returns exact markdown files with absolute paths.
- The AI reads those files before changing code.
Project Documentation Layout
Recommended layout:
PROJECT_ROOT/
├── CLAUDE.md
├── docs/
│ ├── knowledge/
│ │ ├── fact-*.md
│ │ └── fix-*.md
│ ├── methodology/
│ │ └── *.md
│ ├── product/
│ │ └── *.md
│ ├── meta/
│ │ └── *.md
│ └── tmp/
└── scripts/
└── ai/
└── build-index.sh
docs/tmp/ and _intro.md files are skipped by the indexer.
Install
Clone this repository somewhere stable:
git clone https://github.com/RevinFedor/docs_search_mcp.git
cd docs_search_mcp
chmod +x knowledge-server.mjs scripts/ai/build-index.sh
Requirements:
- Node.js 18+;
jq;- Gemini API key for the default router and indexer;
- optional Claude CLI if you want
provider="claude".
On macOS:
brew install jq
Add The Indexer To A Project
Copy the indexer into the project that has docs/:
mkdir -p /path/to/project/scripts/ai
cp scripts/ai/build-index.sh /path/to/project/scripts/ai/build-index.sh
chmod +x /path/to/project/scripts/ai/build-index.sh
Create or update the semantic index:
cd /path/to/project
export GEMINI_API_KEY="your_key"
bash scripts/ai/build-index.sh --gemini-write
The result is:
/path/to/project/.semantic-index.json
Commit .semantic-index.json when you want the same routing table available to every developer and AI session.
Register The MCP Server
Register globally for Claude Code:
claude mcp add docs-search \
-s user \
-e GEMINI_API_KEY="$GEMINI_API_KEY" \
-- node /path/to/docs_search_mcp/knowledge-server.mjs
For one project, pin the default project directory:
claude mcp add docs-search \
-s local \
-e CLAUDE_PROJECT_DIR="/path/to/project" \
-e GEMINI_API_KEY="$GEMINI_API_KEY" \
-- node /path/to/docs_search_mcp/knowledge-server.mjs
You can still search any project from a tool call by passing projectPath.
Tools
docs_search
Searches the selected project index and returns markdown files to read.
Example request:
{
"query": "fix stale loader state on mobile terminal project list",
"projectPath": "/path/to/project"
}
Example result:
{
"found": 3,
"files": [
{
"path": "docs/knowledge/fact-mobile-web.md",
"fullPath": "/path/to/project/docs/knowledge/fact-mobile-web.md"
}
]
}
The agent should then read each fullPath before editing code.
docs_reindex
Runs the project's scripts/ai/build-index.sh and reloads .semantic-index.json.
Example:
{
"projectPath": "/path/to/project",
"provider": "gemini",
"model": "gemini-3.5-flash",
"parallel": 5
}
Use this after changing important documentation files.
Documentation Update Prompt
docs_search solves only the routing step: which documentation files the agent should read before it changes code.
After the implementation work is done, the next step is often the opposite one: ask Claude to look back at the finished session and update docs/knowledge/, docs/methodology/, and related project docs in a disciplined way.
That is what prompts/documentation/docs-rules.prompt.md is for.
Typical flow:
- The agent works on code and uses
docs_searchduring the session to read the right docs. - The session ends.
- You send
prompts/documentation/docs-rules.prompt.mdas a final follow-up prompt to Claude. - Claude analyzes the completed session and applies the documentation update workflow defined in that prompt.
Why both files are included:
docs-rules.prompt.mdis the runnable prompt artifact.правила-документации.mdis the maintained source-of-truth text that gets transcluded into it.
If you use the same pattern in another project, keep the pair together so the prompt remains readable in Git and maintainable in the editor workflow.
Switching Models
Defaults:
- router provider:
gemini; - Gemini model:
gemini-3.5-flash; - Claude model:
haiku.
Per-call override:
{
"query": "timeline hover preview is clipped",
"provider": "claude",
"model": "haiku"
}
Environment defaults:
export KNOWLEDGE_ROUTER_PROVIDER=gemini
export KNOWLEDGE_INDEX_PROVIDER=gemini
export KNOWLEDGE_GEMINI_MODEL=gemini-3.5-flash
export KNOWLEDGE_CLAUDE_MODEL=haiku
If provider="claude" fails, the server falls back to Gemini when a Gemini key is available.
Global Cross-Project Docs
The server can merge a small global pattern library into every project search. By default it looks at:
~/Global-Templates/🧩 Code-Patterns/docs-projects/.semantic-index.json
Override it with:
export KNOWLEDGE_GLOBAL_DIR="/path/to/docs-projects"
Global entries are returned with docs-global/ prefixes. Keep this folder small and public-safe; it should contain reusable patterns, not private project notes.
Security
Do not publish private project docs by accident.
Safe to publish:
- this MCP server;
- the generic indexer;
- example
.semantic-index.jsonshapes; - public documentation written for reuse.
Do not publish:
docs/knowledge/from private projects;.envfiles;- transcripts, logs, tokens, or local MCP configs;
- global documentation folders that include personal workflows or private prompts.
README Note For Projects
Add this note near the end of any repository that uses the MCP:
> ! Documentation is routed through `docs_search MCP`: agents call `docs_search` before complex work, receive the relevant files from `.semantic-index.json`, and read those files into context. Rebuild the index with `docs_reindex` or `bash scripts/ai/build-index.sh --gemini-write` after documentation changes.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.