Skip to content

MCP Server

Terminal window
git clone https://github.com/nosqltips/AgentStateGraph.git
cd AgentStateGraph
cargo build --release -p agentstategraph-mcp
cargo run --release -p agentstategraph-mcp
# Creates ./agentstategraph.db, listens on stdio

Add to ~/.claude.json or your project’s .mcp.json:

{
"mcpServers": {
"agentstategraph": {
"command": "/path/to/AgentStateGraph/target/release/agentstategraph-mcp"
}
}
}

Or run from source:

{
"mcpServers": {
"agentstategraph": {
"command": "cargo",
"args": ["run", "--release", "-p", "agentstategraph-mcp", "--manifest-path", "/path/to/AgentStateGraph/Cargo.toml"]
}
}
}

Restart Claude Code. The 27 AgentStateGraph tools appear automatically.

The same binary also supports HTTP mode — 22 REST endpoints with CORS enabled:

Terminal window
cargo run --release -p agentstategraph-mcp -- --http --port 3001
Terminal window
curl http://localhost:3001/api/health
curl http://localhost:3001/api/stats/main
curl http://localhost:3001/api/state/main?path=/cluster/name
curl "http://localhost:3001/api/blame/main?path=/cluster/name"
curl "http://localhost:3001/api/state/main/search?query=mesh"

Full endpoint list:

MethodEndpointDescription
GET/api/healthHealth check
GET/api/stats/:refSummary statistics
GET/api/state/:ref?path=/xRead state value
GET/api/state/:ref/pathsList all paths
GET/api/state/:ref/search?query=xFull-text search values
POST/api/state/:ref/setWrite value with intent
POST/api/state/:ref/deleteDelete value with intent
GET/api/log/:refCommit log
GET/api/blame/:ref?path=/xBlame a path
GET/api/diff?ref_a=x&ref_b=yDiff two refs
POST/api/query/:refQuery with composable filters
GET/api/graph/:refCommit DAG
GET/api/branchesList branches
POST/api/branchesCreate branch
POST/api/mergeMerge branches
GET/api/epochsList epochs
POST/api/epochsCreate epoch
POST/api/epochs/sealSeal epoch
GET/api/intents/:refIntent decomposition tree

Any MCP client that supports stdio transport works. Point it at the agentstategraph-mcp binary.

Terminal window
agentstategraph-mcp [OPTIONS]
OPTIONS:
-s, --storage <TYPE> Storage backend: sqlite (default) or memory
-p, --path <PATH> SQLite database path (default: ./agentstategraph.db)
--http Run as HTTP REST API instead of MCP stdio
--port <PORT> HTTP port (default: 3001, requires --http)
-h, --help Print help with full endpoint list
ToolDescription
agentstategraph_getRead a value at any branch/path. Use / for entire state.
agentstategraph_setWrite a value with intent metadata (category, description, reasoning, confidence).
agentstategraph_deleteRemove a value, creating a commit with intent.
ToolDescription
agentstategraph_branchCreate a branch from any ref. Supports namespaced names.
agentstategraph_list_branchesList all branches, optionally filtered by namespace prefix.
agentstategraph_mergeSchema-aware three-way merge. Returns conflicts if auto-resolution fails.
agentstategraph_diffStructured typed diff between two refs (not text diffs).
ToolDescription
agentstategraph_speculateCreate a lightweight O(1) speculation from a ref.
agentstategraph_spec_modifyApply set/delete operations within a speculation.
agentstategraph_compareCompare multiple speculations side-by-side.
agentstategraph_commit_specPromote a speculation to a real commit on its base branch.
agentstategraph_discardDiscard a speculation. All changes freed immediately.
ToolDescription
agentstategraph_logCommit history with full intent, reasoning, and metadata.
agentstategraph_queryComposable filters: agent, category, tags, reasoning text, confidence range.
agentstategraph_blameFind which commit last modified a path and why.
ToolDescription
agentstategraph_create_epochCreate an epoch to group related work.
agentstategraph_seal_epochSeal an epoch (immutable, tamper-evident). Cannot be undone.
agentstategraph_list_epochsList all epochs with status, dates, and commit counts.
ToolDescription
agentstategraph_sessionsList active agent sessions with parent-child relationships.
ToolDescription
agentstategraph_list_pathsList all leaf paths in the state tree under a prefix.
agentstategraph_get_treeGet entire subtree as nested JSON (batch read).
agentstategraph_searchFull-text search across state values and key names.
agentstategraph_statsSummary statistics: commits, branches, paths, epochs, agents.
agentstategraph_commit_graphCommit DAG with parents, agents, categories for visualization.
agentstategraph_intent_treeIntent decomposition hierarchy across agents.
You: Store the cluster config under /cluster
Agent: [calls agentstategraph_set with path="/cluster/name", value="prod", ...]
You: Try two network approaches and compare them
Agent: [calls agentstategraph_speculate twice, agentstategraph_spec_modify on each,
agentstategraph_compare to diff them, agentstategraph_commit_spec on winner]
You: Who changed the network config and why?
Agent: [calls agentstategraph_blame with path="/cluster/network"]

See the full MCP Tools Reference for parameters and example payloads.