serve

A command that runs ctx as an MCP server, allowing an AI assistant to query an indexed codebase through standard tools. MCP is a common way for AI assistants to use external tools.

In plain words
What is it for?
Use it to search symbols, view definitions, find references, inspect files, and select code relevant to a task.
Why use it?
It lets the assistant retrieve relevant code and relationships instead of relying only on the files already in its conversation.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/agentis-tools/ctx/serve
Clone the repo
git clone --depth 1 https://github.com/agentis-tools/ctx
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,149 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01149
Opus 5 $0.00000 $0.00575
Sonnet 5 $0.00000 $0.00230
Haiku 4.5 $0.00000 $0.00115

Measured 2d ago against content hash 05083da974b4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

serve scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/commands/serve.md · 191 lines

How it starts

The opening of the file, as written. The whole thing — 191 lines — stays where its author put it; the contents beside it link to each section on GitHub.

ctx serve

Start ctx as an MCP (Model Context Protocol) server for AI assistant integration.

Synopsis

ctx serve --mcp

Description

The serve command runs ctx as an MCP server over stdio, enabling AI assistants like Claude to query your codebase through standardized tools. This provides:

  • Real-time code intelligence - AI can search symbols, view definitions, analyze call graphs
  • Context-aware assistance - AI understands your codebase structure
  • Smart file selection - AI can request relevant files for tasks

Prerequisites

  1. Index your codebase:

    ctx index
    
  2. Generate embeddings (for smart context):

    ctx embed
    
  3. Build ctx with MCP support:

    cargo build --features mcp --release
    

Options

Option Description
--mcp Run as MCP server over stdio

Available MCP Tools

When running as an MCP server, ctx exposes these tools:

Search Tools

Tool Description
search_symbols Search for symbols by name pattern
get_definition Get source code for a symbol
find_references Find all references to a symbol

File Tools

Tool Description
get_file Read a file's contents
get_file_tree List files in the project

Analysis Tools

Tool Description
get_callers Find functions that call a function
get_callees Find functions called by a function
smart_context Intelligently select files for a task

Claude Desktop Integration

Configuration

Add ctx to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json Linux: ~/.config/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "ctx": {
      "command": "ctx",
      "args": ["serve", "--mcp"],
      "cwd": "/path/to/your/project"
    }
  }
}

Read the full file on GitHub · 191 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 191 lines · 0 tokens per session scan A 05083da974b4

Subscribe to this mod's changes

serve is a command published in the GitHub repository agentis-tools/ctx (11 stars, last pushed 15d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,149 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.