ctx
Local MCP server for decision trace capture and deterministic explanations, providing tools to start, track, and query decision traces, and resources to retrieve trace data.
README
ctx-mcp
Local MCP server for decision trace capture and deterministic explanations.
Requirements
- Node.js 18+
Install
npm install
Run (stdio MCP server)
npm run dev
Architecture (high level)
flowchart LR
Client[MCP client] -->|stdio| Server[ctx MCP server]
Server --> Tools[Trace tools]
Tools --> Store[(Trace store)]
Server --> Resources[trace:// resources]
Store --> Resources
Usage contract (agents)
- You MUST call
trace.startwhen a user-requested task begins (once intent is clear). - You MUST call
trace.finishwhen that task is completed, even if the conversation continues, to mark outcome/status for downstream analysis. - Treat a "task" as a single user goal; if the user pivots to a new goal, start a new trace.
- If a task is completed and the user continues with a new goal, start a new trace (optionally link the prior trace in metadata).
Core tools
trace.starttrace.add_nodetrace.add_edgetrace.attach_artifacttrace.finishtrace.querytrace.get_subgraphtrace.find_pathstrace.explain_decisiontrace.similaritytrace.risk_check
Example tool calls
{
"tool": "trace.start",
"input": {
"intent": "Investigate alert",
"tags": ["incident", "p1"],
"metadata": { "ticket": "INC-123" }
}
}
{
"tool": "trace.add_node",
"input": {
"trace_id": "trace-uuid",
"type": "Decision",
"summary": "Roll back release",
"data": { "reason": "error rate spike" },
"confidence": 0.8
}
}
{
"tool": "trace.add_edge",
"input": {
"trace_id": "trace-uuid",
"from_node_id": "decision-node-id",
"to_node_id": "action-node-id",
"relation_type": "causes"
}
}
{
"tool": "trace.explain_decision",
"input": {
"trace_id": "trace-uuid",
"decision_node_id": "decision-node-id",
"depth": 4
}
}
{
"tool": "trace.similarity",
"input": {
"decision_node_id": "decision-node-id",
"scope": "all",
"limit": 5
}
}
{
"tool": "trace.risk_check",
"input": {
"decision_node_id": "decision-node-id",
"threshold": 0.6
}
}
Resources
trace://{trace_id}trace://{trace_id}/timelinetrace://{trace_id}/graphtrace://{trace_id}/subgraph?center=...&depth=...&dir=...trace://{trace_id}/explain?decision=...&depth=...trace://search?text=...&trace_id=...&type=...trace://{trace_id}/similarity?decision=...&scope=...&limit=...&depth=...&max_traces=...trace://{trace_id}/risk?decision=...&scope=...&limit=...&depth=...&threshold=...&max_traces=...
MCP config example
{
"mcpServers": {
"ctx": {
"command": "npx",
"args": ["ctx-mcp"]
}
}
}
Testing
npm test
Seed a sample trace
npm run seed
CLI examples
npm run risk-check -- decision-node-id
npm run similarity -- decision-node-id
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.