feat(cortex): MCP stdio server (--mcp) exposing the semantic graph to LLMs#98
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add crates/aingle_cortex/tests/mcp_integration.rs with two tests: - in-process duplex client/server driving AingleMcp via an rmcp client - subprocess stdout-hygiene check (stdout is JSON-RPC only) Enable the rmcp `client` feature as a dev-dependency for the in-process client (production `mcp` feature uses the server side only). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ns_batch, validate) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…trix Gate `AuditEntry`/`Event` imports in rest/triples.rs behind `#[cfg(any(feature = dag, feature = cluster))]` so the rest-only (no dag/cluster) build is warning-free; all usages live in the DAG/cluster write paths. Apply rustfmt to feature files and replace `map_or(true, ..)` with `is_none_or` in service/query.rs (clippy). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
Update: broad coverage completeThe follow-up "broad coverage" is now included in this PR — the MCP surface went from 6 to 25 tools, all following the same extract→delegate→tool pattern with per-capability unit tests and REST↔MCP parity. Tool inventory (25):
Feature-gated tools ( Verification: full build matrix (mcp-only / mcp+sparql / mcp+dag / default) green; 187 lib tests + 2 MCP integration tests pass; new code is clippy-clean and rustfmt-applied. |
This was referenced Jun 22, 2026
Closed
…mcp-server # Conflicts: # crates/aingle_cortex/src/main.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an MCP (Model Context Protocol) server to
aingle_cortex, enabling Claude Code / Claude Desktop to consume the aingle semantic graph as a context backend.aingle-cortex --mcpserves MCP over stdio (logs to stderr; stdout reserved for JSON-RPC), reusing the existingAppStateinstead of binding TCP.src/service/layer (Approach A): REST handlers and MCP tools call the same business logic, guaranteeing REST↔MCP parity.aingle_ping,aingle_query_pattern,aingle_graph_stats,aingle_create_triple(write),aingle_verify_proof(ZK; returnsvalid:falsefor invalid proofs, not an error), andaingle_dag_history(signed DAG provenance, gated by thedagfeature).mcpcargo feature (rmcp1.7 +schemars); themcpfeature does not requiredag— the dag tool is registered via a separate merged tool-router only whendagis on.mcpfeature and passing--mcpexits non-zero with a clear error.Implementation notes
#[cfg_attr(feature = "mcp", derive(schemars::JsonSchema))].read_only=false,idempotent=false— the graph keys triples by content hash, so a duplicate insert errors); read tools annotatedread_only=true.Test plan
cargo build -p aingle_cortex(default) — compilescargo build -p aingle_cortex --no-default-features --features "rest mcp"— compiles (mcp without dag)cargo build -p aingle_cortex --features "mcp dag"— compilescargo test -p aingle_cortex --features "mcp dag" --lib— 160 passed, 0 failedcargo test -p aingle_cortex --features "mcp dag" --test mcp_integration— in-process rmcp client round-trip (create→query) + tools/list incl.aingle_dag_history+ stdout-hygiene subprocess testclippy-clean; rustfmt appliedaingle-cortex --mcp --db ./data/graph.sledin a Claude MCP client and confirm tools appear and return dataNotes
cluster_integration_testfailures ("missing Ed25519 signature") reproduce on the base commit and are unrelated to this change.