Skip to main content
Glama
datarian
by datarian

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) and document (markdown/text/pdf, prose chunking).

  • Formats (src/mcp_coco/formats.py) — a registry mapping a file to normalized text. PDF (via pymupdf) 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 one doc_embeddings table.

  • 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)

Related MCP server: ragi

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.

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

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)

  1. Open this folder in VS Code and Reopen in Container (Dev Containers). The db service starts automatically alongside the app container.

  2. Run the preflight check:

    just install
    just init

    Copy .env.example to .env to customize settings. Inside the devcontainer the database hostname is db (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

Available Tools

3 tools
index_documentsIndex DocumentsC

Index a document collection (markdown, text, PDF, ...).

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry the full burden. It only says 'Index a document collection', with no details on side effects (e.g., destructive vs. read-only), required permissions, or rate limits. This is insufficient for safe tool invocation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise (one sentence) and front-loaded with the action. However, it sacrifices necessary detail; conciseness is good but should not come at the cost of completeness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations, output schema, and parameter descriptions, the description is severely incomplete. It does not explain what 'index' means, the process, or what the tool returns, making it inadequate for an agent to select and invoke correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, meaning the 'path' parameter has no description. The description implies 'path' points to a collection of files but does not clarify whether it expects a directory, a file, or how to specify file types. It adds minimal value beyond the parameter name.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Index') and the resource ('document collection'), with specific file types (markdown, text, PDF). It implicitly distinguishes from sibling 'index_repo' (likely for code repos) and 'search' (a different operation).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'index_repo' or 'search'. The description does not mention context or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

index_repoIndex RepositoryB

Index a code repository (code-aware chunking, vendored dirs skipped).

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYes

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full responsibility for behavioral disclosure. It mentions code-aware chunking and skipping vendored dirs, which are useful behaviors, but it does not indicate whether the operation is destructive, requires specific permissions, or any rate limits. Given that indexing likely involves writing to storage, more transparency is needed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no wasted words. It fronts the core action ('Index a code repository') immediately and adds the key differentiators in parentheses. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool performs an operation with potential side effects (indexing), the description is too brief. It lacks information about the output or success/failure indicators, prerequisites like repository structure, and any associated side effects (e.g., overwriting existing index). With no output schema, the description should provide more context about what happens after indexing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, so the description must compensate. The single parameter 'path' is implicitly explained by the tool's purpose: it is the file system path to the repository. However, the description does not specify format (absolute/relative), constraints, or expected content. The added value is marginal but sufficient for a simple parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Index a code repository'. It adds specific details like 'code-aware chunking' and 'vendored dirs skipped', which distinguishes it clearly from siblings like index_documents (likely for other file types) and search (querying). The verb 'index' and resource 'code repository' are specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when you need to index a repository with code-aware chunking and skip vendored directories, but it does not explicitly state when to use this tool versus alternatives like index_documents. There is no mention of prerequisites or conditions for use, nor when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A3.5/5.0
Disambiguation5/5

Each tool has a clear and distinct purpose: indexing documents, indexing repos, and searching. There is no overlap or ambiguity.

Naming Consistency4/5

Tool names follow a consistent snake_case pattern, with two using verb_noun (index_documents, index_repo) and one using a simple verb (search). This is mostly consistent with a minor deviation.

Tool Count4/5

Three tools is a reasonable count for a focused indexing and search server. It covers the core functionality without being too sparse or excessive.

Completeness4/5

The tool surface covers the primary operations: indexing two types of content and searching across them. While there are no delete or update operations, the server appears to be scoped for basic indexing and retrieval, which is adequately covered.

Maintenance

ActivityStale
ResponsivenessSyncing

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

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Local MCP server that provides semantic search (RAG) over code repositories, enabling AI clients like Claude and Gemini to access project context without manual re-upload.
  • A
    license
    A
    quality
    D
    maintenance
    Local-first RAG indexing and semantic search MCP server. Enables document retrieval and context-aware queries using local embedding models.
    3
    14
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that indexes documents and serves relevant context to LLMs via Retrieval Augmented Generation (RAG).
    48
    37
    MIT
  • A
    license
    A
    quality
    F
    maintenance
    MCP server for semantic code search that indexes your codebase and allows AI editors to search using natural language queries.
    9
    112
    53
    MIT

Latest Blog Posts

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/datarian/mcp-coco'

If you have feedback or need assistance with the MCP directory API, please join our Discord server