Document Search MCP Server
An MCP server that enables Claude Desktop or Claude Code to ingest and search local documents using vector embeddings, returning relevant chunks as tool results for the model to reason over.
README
Document Search — an MCP server
Wraps document ingestion and retrieval (the same chunking + Voyage embedding + Chroma logic from Project 2) as an MCP server — so Claude Desktop or Claude Code can search your own documents directly, as a native tool call, instead of you running a separate CLI.
This is Project 4 in a self-directed AI engineering learning path. It builds on Project 2 (RAG) and Project 3 (tool use) — MCP is essentially "tool use, standardized so any client can use your tools, not just code you wrote yourself."
The key design decision, and why it matters
Unlike Project 2's doc_chat.py, this server never calls the Claude
API to generate an answer. It only retrieves and returns relevant
chunks. This is intentional, not a missing feature:
When Claude Desktop (or Claude Code) calls search_documents, it's
already a Claude model in the loop — the client itself. It receives
the retrieved chunks as a tool result and writes the final answer using
its own reasoning, the same way it would use any other tool's output.
Having the server also call Claude to generate an answer would be
redundant — two models doing the same generation job — and would take
control away from the client, which is supposed to decide how to use
retrieved context, not just relay someone else's answer.
This is the real shift MCP represents: in Project 2, you wrote the code that calls Claude. In Project 4, Claude is the code calling your tool. The server's only job is to be a good, honest data source.
Setup
pip install -r requirements.txt
$env:VOYAGE_API_KEY = "your-voyage-key"
(No ANTHROPIC_API_KEY needed for the server itself — see above. You'll
still need one configured wherever Claude Desktop/Code itself runs, but
that's separate from this server.)
Connecting it to Claude Code
claude mcp add doc-search -- python /full/path/to/mcp_doc_server.py
Use the full absolute path to the script — relative paths won't resolve correctly once Claude Code launches it as a subprocess from a different working directory.
Then, in a Claude Code session, you can just ask naturally:
"Ingest the documents in ./sample_docs, then tell me the meal reimbursement policy."
Claude Code will call ingest_documents, then search_documents, then
write the answer itself — the same multi-step tool chaining you saw in
Project 3, except now the tool is your own MCP server instead of a
Python function baked into the same script.
Connecting it to Claude Desktop
Add this to your Claude Desktop MCP config file (claude_desktop_config.json
— check Claude Desktop's settings for its exact location on your system):
{
"mcpServers": {
"doc-search": {
"command": "python",
"args": ["/full/path/to/mcp_doc_server.py"],
"env": {
"VOYAGE_API_KEY": "your-voyage-key"
}
}
}
}
Restart Claude Desktop after editing the config. You should see "doc-search" appear as an available tool source in the app.
Testing without a live MCP client
fastmcp ships an in-process test client, which is what verified this
server before you ever connect it to Claude Desktop:
import asyncio
from fastmcp import Client
from mcp_doc_server import mcp
async def main():
async with Client(mcp) as client:
tools = await client.list_tools()
print(tools)
asyncio.run(main())
This calls the real MCP protocol layer — tool discovery, schema generation, invocation — without needing a full Claude Desktop install or a live API key, which is how the error-path behavior was verified during development.
Design notes
- Tool docstrings are the interface, more so than in Project 3.
With direct API tool use, you write a separate
descriptionfield. Withfastmcp, the Python docstring is the description the client sees — meaning writing a clear, accurate docstring isn't just good Python practice here, it's the actual mechanism by which Claude decides when and how to call your tool. - Global client caching (
_voyage_client,_collection). MCP servers are typically long-running processes (started once, called many times), unlike a CLI script that runs once and exits. Creating a new Voyage client or Chroma connection on every single tool call would be wasteful; lazy-initializing them once and reusing them across calls is the correct pattern for a persistent server. - Tools return strings, not raising exceptions, for expected error
cases (missing folder, empty collection) — same philosophy as
Project 3's
execute_tool. The calling model needs to see and reason about a failure, not have the whole server crash.
What's next
- Add a
list_ingested_sourcestool so the client can check what's already searchable before deciding whether to re-ingest. - Add authentication if this were ever exposed over network transport instead of run locally via stdio.
- Package as a proper installable MCP server others could add to their own Claude Desktop config without cloning the repo.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。