MCP Server

MCP Server

contextd can run as a Model Context Protocol (MCP) server, giving AI coding agents programmatic access to your project’s context.

Starting the server

npx contextd serve

The server runs over stdio transport (not HTTP), which is the standard for MCP. It requires @modelcontextprotocol/sdk to be installed.

Options

OptionDefaultDescription
--port <port>3333Port to serve on (for future HTTP support)

Available tools

ToolDescriptionParameters
get_project_overviewGet high-level project overview + architectureNone
get_conventionsGet coding conventions and standardsNone
get_relevant_contextGet context relevant to specific filesfiles — array of file paths
list_decisionsList all architecture decision records (ADRs)None
get_module_contextGet context for a specific module or directorymodule — module name or path

Configuring Claude Code

Add an .mcp.json file to your project root:

{
  "mcpServers": {
    "contextd": {
      "command": "npx",
      "args": ["contextd", "serve"]
    }
  }
}

Configuring Cursor

Add the server to Cursor’s MCP settings:

{
  "mcpServers": {
    "contextd": {
      "command": "npx",
      "args": ["contextd", "serve"]
    }
  }
}

How it works

When the server starts, it:

  1. Finds the project root (directory containing .context/)
  2. Auto-refreshes stale remote sources (>24 hours old) non-blocking
  3. Warns if any source hasn’t synced in >7 days
  4. Registers all 5 MCP tools
  5. Connects via stdio transport
  6. Prints the MCP configuration JSON to stderr for you to add to your .mcp.json

Remote context inclusion

All MCP tools automatically include remote contexts if configured. When you call get_relevant_context, the server matches files against both local and cached remote module scopes.

Tool behavior

  • get_project_overview — Merges project.md and architecture.md content
  • get_conventions — Returns conventions.md content
  • get_relevant_context — Uses the same relevance algorithm as export --files: always includes project + conventions, adds matching modules by scope, and relevant decisions by tags
  • list_decisions — Lists all ADRs with titles and statuses
  • get_module_context — Finds a module context file by name or path and returns its content