Skip to main content

MCP server for trelix — semantic code search for Claude Code, Cursor, Windsurf, Continue.dev

Project description

trelix-mcp

MCP server for trelix v2.5.0 — semantic code search with streaming /ask endpoint 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==2.5.0

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

pip install "trelix-mcp==2.5.0" "trelix[bedrock]"

Other optional LLM provider extras:

pip install "trelix-mcp==2.5.0" "trelix[anthropic]"   # Anthropic Claude direct
pip install "trelix-mcp==2.5.0" "trelix[vertex]"       # Google Vertex AI / Gemini
pip install "trelix-mcp==2.5.0" "trelix[litellm]"      # 100+ providers via LiteLLM
pip install "trelix-mcp==2.5.0" "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 (v1.5) — superior code retrieval, 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

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) Find what depends on a symbol
ask Streaming chat endpoint for conversational code exploration (v2.0.0+)
build_knowledge_graph(repo_path) Build code property graph
graph_search_mcp(query, repo_path) Search via knowledge graph
subscribe_resource uri: str, subscription_id: str
unsubscribe_resource subscription_id: str

Resource Subscriptions (v2.5.0)

trelix-mcp now 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 fires per-URI notifications with the subscriptionId in params._meta.

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==2.5.0' 'trelix[knowledge-graph]'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trelix_mcp-2.5.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trelix_mcp-2.5.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file trelix_mcp-2.5.0.tar.gz.

File metadata

  • Download URL: trelix_mcp-2.5.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for trelix_mcp-2.5.0.tar.gz
Algorithm Hash digest
SHA256 f515d13e4c4890ff48aa53d1994219d2c30ee7e36121c9d448ce7aa7281e62fd
MD5 dda5cfabf3d4fcc70d92d14d2749e4d9
BLAKE2b-256 c10f349ca5e9579bc28eb98bf0901d5a4b8d7a1aab6e435d4e0ce49e0c89e886

See more details on using hashes here.

Provenance

The following attestation bundles were made for trelix_mcp-2.5.0.tar.gz:

Publisher: release.yml on sairam0424/trelix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trelix_mcp-2.5.0-py3-none-any.whl.

File metadata

  • Download URL: trelix_mcp-2.5.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for trelix_mcp-2.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 444c5a4eb814eb100a98c3cd49b55f8784c3232966ee8c440f6ceaebb1265a6d
MD5 0b251cd8ae61c4d3b93a77fa039e61de
BLAKE2b-256 30d23f288b932b18cba51de7b8f1250da7745f4baf9d985fb1dd1a12c00281b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for trelix_mcp-2.5.0-py3-none-any.whl:

Publisher: release.yml on sairam0424/trelix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page