cocoindex MCP
An MCP server that incrementally indexes repositories and documents into a Postgres + pgvector store using CocoIndex, and exposes semantic search over them.
README
cocoindex MCP
An MCP server that incrementally indexes repositories and documents into a Postgres + pgvector store using CocoIndex, and exposes semantic search over them.
The pipeline is source → extract (format registry) → chunk → embed → store:
- Sources (
src/mcp_coco/sources.py) — local filesystem today, as two profiles:repo(code-aware, vendored dirs excluded) anddocument(markdown/text/pdf, prose chunking). - Formats (
src/mcp_coco/formats.py) — a registry mapping a file to normalized text. PDF (viapymupdf) is just one handler; add a format by registering one. - Indexer (
src/mcp_coco/indexer.py) — the CocoIndex app: chunk + embed (sentence-transformers) and declare rows into onedoc_embeddingstable. - Search (
src/mcp_coco/db.py) — embeds the query and runs a pgvector similarity search.
CocoIndex tracks its incremental state in a local LMDB file (COCOINDEX_DB), so
re-indexing only reprocesses what changed and removes rows for deleted files.
Prerequisites
- uv (Python package manager)
- just (task runner, optional but convenient)
- A Postgres instance with pgvector
- Docker (if you want to run pgvector via the included compose file)
Quick start (local)
1. Start a pgvector database
If you already have a Postgres instance with pgvector, skip this step and set
DATABASE_URL accordingly.
Otherwise, use the included compose file:
docker compose up -d
This starts pgvector on localhost:5432 with user/password/db all set to cocoindex.
2. Install dependencies
uv sync
3. Configure
cp .env.example .env
Edit .env and set DATABASE_URL to point at your Postgres instance. For the
Docker-based database:
DATABASE_URL=postgresql://cocoindex:cocoindex@localhost:5432/cocoindex
Optional settings:
| Variable | Default | Description |
|---|---|---|
EMBED_MODEL |
sentence-transformers/all-MiniLM-L6-v2 |
Embedding model for indexing and search |
RERANK_MODEL |
cross-encoder/ms-marco-MiniLM-L-6-v2 |
Cross-encoder model for result re-ranking |
COCO_TABLE_NAME |
doc_embeddings |
Postgres table name |
COCOINDEX_DB |
/data/cocoindex/state.db |
Path to CocoIndex incremental state store |
4. Verify the database connection
just init
5. Index something
just index ./path/to/repo repo
just index ./path/to/docs document
The first run downloads the embedding model (~80 MB) from Hugging Face.
6. Search
just search "how does authentication work"
Using with Coding Agents
Add the MCP server to your Claude Code settings
(~/.claude/settings.json for global, or .claude/settings.json in a project):
{
"mcpServers": {
"cocoindex": {
"command": "uv",
"args": ["run", "--directory", "/absolute/path/to/cocoindex-mcp", "mcp-coco-server"],
"env": {
"DATABASE_URL": "postgresql://cocoindex:cocoindex@localhost:5432/cocoindex",
"COCOINDEX_DB": "/absolute/path/to/cocoindex-mcp/.cocoindex/state.db"
}
}
}
}
Replace /absolute/path/to/cocoindex-mcp with the actual path to this repository.
If your Postgres instance is elsewhere (e.g. a cloud-hosted database), adjust
DATABASE_URL accordingly. It is highly encouraged to pass your authentication information through env vars, do NOT hardcode into the connection string!
Once configured, Claude Code can use these tools:
| Tool | Description |
|---|---|
index_repo(path) |
Index a code repository |
index_documents(path) |
Index a document collection |
search(query, limit, source_kind) |
Semantic search — returns condensed summaries and a results_file path |
read_search_results(results_file, indices, rerank) |
Retrieve full details for specific results from a previous search |
Two-stage search
To keep context lean, search writes full results to a temporary JSON file
and returns only condensed summaries (~80-char excerpts) inline. The caller
triages from the summary, then uses read_search_results to fetch full
details for the results it actually needs.
By default, read_search_results re-ranks the selected results using a
cross-encoder model (cross-encoder/ms-marco-MiniLM-L-6-v2) for more
accurate relevance ordering. Disable with rerank=false. The model is
configurable via the RERANK_MODEL environment variable.
Development (devcontainer)
-
Open this folder in VS Code and Reopen in Container (Dev Containers). The
dbservice starts automatically alongside the app container. -
Run the preflight check:
just install just initCopy
.env.exampleto.envto customize settings. Inside the devcontainer the database hostname isdb(the default).
just recipes
just index <path> [repo|document|auto] # index a path
just index-repo <path> # index as code repository
just index-docs <path> # index as document collection
just search "query" [limit] # semantic search
just drop <path> [repo|document|auto] # remove a source from the index
just visualize_index # show a map of what's indexed
just serve # run the MCP server over stdio
just test # run tests
just lint # run ruff
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。