Skip to main content

trelix-mcp

MCP server for trelix v3.1.5 — semantic code search with streaming /ask endpoint, watch bridge notifications, and REST API integration for Claude Code, Cursor, Windsurf, and Continue.dev.

⚠️ Breaking Change in v2.4.0

search_code now returns a pagination envelope instead of a bare list:

# v2.3.x (old)
results = search_code(query="auth", repo_path="/repo")
for r in results:  # results was list[dict]
    print(r["symbol"])

# v2.4.0 (new)
response = search_code(query="auth", repo_path="/repo")
for r in response["results"]:  # now dict with pagination
    print(r["symbol"])
# Paginate: pass response["next_cursor"] as cursor= for next page

Install

pip install trelix-mcp

Unpinned on purpose. trelix-mcp carries the core version stamp and is published only by a core v* tag, so the newest trelix-mcp is always the one built alongside the newest trelix. To pin in your own requirements.txt, pin all four distributions to the same version — see the FAQ.

To use Bedrock embeddings or synthesis (no extra API key beyond AWS credentials):

pip install trelix-mcp "trelix[bedrock]"

Other optional LLM provider extras:

pip install trelix-mcp "trelix[anthropic]"   # Anthropic Claude direct
pip install trelix-mcp "trelix[vertex]"      # Google Vertex AI / Gemini
pip install trelix-mcp "trelix[litellm]"     # 100+ providers via LiteLLM
pip install trelix-mcp "trelix[llm-all]"     # all LLM providers

Usage

Claude Code

claude mcp add trelix -- trelix-mcp

Cursor (~/.cursor/mcp.json)

{
  "mcpServers": {
    "trelix": {
      "command": "trelix-mcp",
      "args": []
    }
  }
}

Continue.dev (.continue/config.json)

{
  "mcpServers": [
    {
      "name": "trelix",
      "command": "trelix-mcp",
      "args": []
    }
  ]
}

Configuration

Set environment variables before starting the MCP server. All variables are optional — defaults work out of the box with the local embedding provider and openai chat provider.

Embedding provider

# Local sentence-transformers — no API key (default)
TRELIX_EMBEDDER_PROVIDER=local

# Local BGE Code — EXPERIMENTAL: pooling unverified, no quality claim, no API key
TRELIX_EMBEDDER_PROVIDER=bge-code

# Local Nomic Code — competitive code embeddings, no API key
TRELIX_EMBEDDER_PROVIDER=nomic-code

# Azure OpenAI embeddings
TRELIX_EMBEDDER_PROVIDER=azure
AZURE_API_KEY=...
AZURE_ENDPOINT=https://<resource>.openai.azure.com/

# Voyage AI — best API-based code embeddings (CoIR 56.26)
TRELIX_EMBEDDER_PROVIDER=voyage
VOYAGE_API_KEY=...

# AWS Bedrock Cohere — strong code retrieval, no extra key beyond AWS creds
TRELIX_EMBEDDER_PROVIDER=bedrock-cohere
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_REGION=us-east-1

# AWS Bedrock Titan v2 — configurable 256/512/1024 dims
TRELIX_EMBEDDER_PROVIDER=bedrock-titan
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_REGION=us-east-1

Chat / synthesis provider (used by index_codebase contextual chunking and synthesis)

# OpenAI (default)
TRELIX_LLM_PROVIDER=openai
OPENAI_API_KEY=sk-...

# Azure GPT-4o
TRELIX_LLM_PROVIDER=azure
AZURE_API_KEY=...
AZURE_ENDPOINT=https://<resource>.openai.azure.com/

# AWS Bedrock — Claude Sonnet 4.6 default with auto-fallback to Haiku
TRELIX_LLM_PROVIDER=bedrock
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_REGION=us-east-1
# Optional overrides:
TRELIX_LLM_BEDROCK_PRIMARY_MODEL=us.anthropic.claude-sonnet-4-6
TRELIX_LLM_BEDROCK_FALLBACK_MODEL=us.anthropic.claude-haiku-4-5-20251001-v1:0

# Anthropic direct
TRELIX_LLM_PROVIDER=anthropic
ANTHROPIC_API_KEY=sk-ant-...

# Google Vertex AI / Gemini
TRELIX_LLM_PROVIDER=vertex
GOOGLE_CLOUD_PROJECT=my-project
GOOGLE_CLOUD_LOCATION=us-central1

# LiteLLM — 100+ providers
TRELIX_LLM_PROVIDER=litellm
TRELIX_LLM_MODEL=bedrock/claude-3-5-sonnet

Resource subscription limits

# Max concurrent resource subscriptions across all clients — caps unbounded
# growth from a client that subscribes repeatedly without ever unsubscribing
TRELIX_MCP_MAX_SUBSCRIBERS=1000

# Auto-evict a subscription after this many seconds of inactivity
TRELIX_MCP_SUBSCRIPTION_TTL_SECONDS=3600

Tools

Tool Description
search_code(query, repo_path, k=10, cursor=0) Hybrid semantic+BM25 search with cursor pagination
index_codebase(repo_path, provider="local") Index a repo (run once); emits progress notifications
get_symbol(qualified_name, repo_path) Get full source of a symbol by qualified name
blast_radius(symbol_name, repo_path) Direct callers + importers of a symbol, from the call/import graph (no embedding model, ~60-120 ms)
build_knowledge_graph(repo_path) Build code property graph
graph_search_mcp(query, repo_path) Search via knowledge graph
subscribe_resource(uri, subscription_id) Subscribe to change notifications for a trelix:// resource URI (v2.5.0+)
unsubscribe_resource(subscription_id) Cancel a resource subscription (v2.5.0+)

Multi-Repo Federation Tools (v2.8.0)

Tool Description
federation_list_repos(config_path=None) List all repos registered for federated search
federation_add_repo(alias, path, weight=1.0, config_path=None) Register a repo for federated search (absolute path required)
federation_remove_repo(alias, config_path=None) Unregister a repo by alias
federation_search_all(query, k=10, cursor=0, config_path=None) Search across all registered repos with RRF-weighted fusion

Persistent Agent Session Tools (v2.8.0)

Tool Description
ask_agent(query, repo_path, session_id=None) Multi-turn ReAct Q&A with persistent memory (pass session_id to resume)
agent_list_sessions(repo_path, limit=50) List recent agent sessions for a repo
agent_clear_session(repo_path, session_id) Delete a persisted agent session and all its turn history

Resource Subscriptions (v2.5.0)

trelix-mcp supports live index change notifications. When trelix watch detects a file change, connected MCP clients receive a notifications/resources/updated push — then call resources/read to fetch the updated index. Subscribe with the subscribe_resource tool.

# Subscribe to a repo manifest
subscribe_resource(
    uri="trelix://repo//path/to/repo/manifest",
    subscription_id="my-sub-001"
)
# → client receives notifications/resources/updated when trelix watch fires
# → call resources/read on the URI to get the refreshed index

# Cancel the subscription
unsubscribe_resource(subscription_id="my-sub-001")

The resources.subscribe capability is advertised in server capabilities. URIs follow the scheme trelix://repo/{repo_path}/manifest. The notify_file_changed() hook (wired into FileWatcher._do_reindex since v2.7.0) fires per-URI notifications with the subscriptionId in params._meta.

Subscriptions are capped and TTL'd by default — see Resource subscription limits (TRELIX_MCP_MAX_SUBSCRIBERS, default 1000; TRELIX_MCP_SUBSCRIPTION_TTL_SECONDS, default 3600). Subscriptions older than the TTL are swept on the next registry access. If the registry is at capacity, subscribe_resource does not raise — it returns {"subscribed": false, "uri": ..., "subscription_id": ..., "error": "..."} so callers can handle rejection gracefully.

Pagination

search_code supports cursor-based pagination for large codebases:

# Fetch page 1
page1 = search_code(query="authentication", repo_path="/repo", k=10)
print(page1["total_available"])  # total results
print(page1["results"])          # this page's results

# Fetch page 2 if more results exist
if page1["next_cursor"] is not None:
    page2 = search_code(query="authentication", repo_path="/repo", k=10, cursor=page1["next_cursor"])

Knowledge Graph Tools

Two tools expose the knowledge graph layer to AI agents:

build_knowledge_graph

Builds a Code Property Graph over an indexed repo. Returns node/edge counts, community count, and a summary of top architectural clusters.

build_knowledge_graph(repo_path="/path/to/repo")
→ {node_count: 4599, edge_count: 4945, community_count: 2409, community_summary: [...]}

Use this before graph_search_mcp for best results — or let graph_search_mcp call it automatically.

graph_search_mcp

Hybrid search: first retrieves semantic seeds, then expands via BFS over call/import/type edges.

graph_search_mcp(query="how does auth relate to the user model?", repo_path="/path/to/repo", k=10)
→ [{file, symbol, kind, score, source, body}, ...]

When to use graph_search_mcp instead of search_code:

  • "What does X depend on?"
  • "What would break if I change Y?"
  • "How does module A connect to module B?"
  • Architecture understanding queries where structural relationships matter

Install the knowledge graph extra for full functionality:

pip install trelix-mcp 'trelix[knowledge-graph]'

Watch Bridge (v2.7.0)

The trelix watch command now fires MCP notifications after every file re-index, allowing real-time codebase awareness across all subscribed clients:

# Terminal 1: Start trelix-mcp
trelix-mcp

# Terminal 2: Enable file watching
trelix watch /path/to/repo

Clients subscribe to a repository's manifest URI via subscribe_resource, which takes two required strings. There is no glob support:

subscribe_resource(uri="trelix://repo//path/to/repo/manifest", subscription_id="my-sub-001")

After each re-index, subscribed clients receive notifications/resources/updated carrying only {"uri": ..., "_meta": {"subscriptionId": ...}} — no file paths and no stats. Call resources/read on that URI to see what changed.

Release files for trelix-mcp 3.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trelix-mcp 3.2.5
File Size Uploaded
trelix_mcp-3.2.5.tar.gz 42.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for trelix-mcp 3.2.5
File Interpreter ABI Platform
trelix_mcp-3.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 67.8 kB

Release files / trelix_mcp-3.2.5.tar.gz

Download URL trelix_mcp-3.2.5.tar.gz
Size 42.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0028d7eaa4b160b89adec0240f1e44038556f54b2f4635128bda9bc788182668
BLAKE2b-256 checksum
How to use checksums
06a22e02969ad875ce6f459aa43a2a133f9117d0ccaa57a6971dde1c4f6a4454
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / trelix_mcp-3.2.5-py3-none-any.whl

Download URL trelix_mcp-3.2.5-py3-none-any.whl
Size 25.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a03ce600bf94c7444a4aa28ba119343136e4d4d94bab827cedb63d234d95d63
BLAKE2b-256 checksum
How to use checksums
53c7dc615f8fb2310c596a7be4a32ddedcb99dfe8dbb8d10f8fb33737666d092
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release history Release notifications | RSS feed

3.3.8

2 release files

3.3.7

2 release files

3.3.6

2 release files

3.3.5

2 release files

3.3.0

2 release files

This release

3.2.5 This release

2 release files

3.2.4

2 release files

3.2.3

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.7

2 release files

3.1.6

2 release files

3.1.5

2 release files

3.1.4

2 release files

3.1.3

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.10.0

2 release files

2.9.0

2 release files

2.8.1

2 release files

2.8.0

2 release files

2.7.2

2 release files

2.7.1

2 release files

2.5.0

2 release files

2.4.0

2 release files

2.0.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page