Skip to main content

Crate truthlinked_mcp

Crate truthlinked_mcp 

Source
Expand description

TruthLinked on-chain MCP primitives for agent-native blockchain execution.

This is not a server wrapping the chain. MCP tools, resources, and prompts are smart cells deployed on TruthLinked.

Architecture:

McpRegistry cell - the chain’s MCP namespace. Stores all registered tool resource prompt cell ids. The agent’s tools list is a read of this cell’s storage.

McpTool cell - each tool is a deployed Axiom cell with storage[“schema”] = json schema bytes storage[“name”] = tool name bytes storage[“version”] = semver bytes calling the tool is a CallCell on that cell. the tool’s Axiom bytecode is the tool’s logic.

McpResource cell - a cell whose storage is the resource data. reading a resource reads cell storage slots. the resource is versioned by manifest_version.

McpPrompt cell - a cell storing prompt templates in storage. validators approve prompts via the name registry. prompt provenance is provable: who deployed it, which block, what manifest hash.

AgentPolicy cell - a Axiom cell that enforces what calls an agent is permitted to make. Called before every tool call via CallCellChain. Reverts the chain if policy is violated, the chain enforces it, not middleware.

AgentRegistry cell - maps agent_id to policy_cell_id. owner sets this. Agent cannot change it. stored on chain. Immutable once the owner locks it.

New TransactionIntents:

RegisterMcpTool - deploys a tool cell and registers in McpRegistry RegisterMcpResource - deploys a resource cell and registers in McpRegistry RegisterMcpPrompt - deploys a prompt cell and validator approves name RegisterAgent - binds agent_id to policy_cell_id in AgentRegistry UpdateAgentPolicy - owner calls policy cell to change permissions SuspendAgent - owner sets agent status to Suspended in AgentRegistry McpToolCall - agent calls a tool with policy check and execution, all atomic in one CallCellChain transaction

The MCP protocol transport (websocket json-rpc) is a thin adapter that translates MCP wire messages into TruthLinked transactions and reads. Every tool call produces a transaction. Every resource read reads cell storage. The chain is the MCP server. The transport is just protocol glue.

Modules§

agent_reg_keys
Canonical storage keys for the AgentRegistry cell
policy_keys
Canonical storage keys for an AgentPolicy cell
private_balance
Agent Private Balance v2 - Full Confidential System
prompt_keys
Canonical storage keys for a McpPrompt cell
protocol_addresses
Canonical MCP protocol cell addresses (well-known, deterministic)
registry_keys
Canonical storage keys for the McpRegistry cell
resource_keys
Canonical storage keys for a McpResource cell
tool_keys
Canonical storage keys for a McpTool cell
zk_transfer
Complete ZK circuit for confidential transfers.

Structs§

PolicyUpdate
Policy fields an owner may update

Enums§

McpIntent
All new MCP-related intent variants to be added to TransactionIntent. Design rule: every intent maps to deterministic state transitions. The parallel executor’s conflict domain extracts their storage keys.

Traits§

McpStateView

Functions§

compile_tool_call_to_chain
Compile McpToolCall into a CallCellChain intent.
deploy_mcp_genesis_cells
Deploy all MCP protocol cells at genesis. This is called from genesis.rs during chain initialization.
diff_register_agent
Compute the StateDiff for RegisterAgent. Binds agent_id -> (policy_cell_id, owner_id) in the AgentRegistry.
diff_register_prompt
Compute the StateDiff for RegisterMcpPrompt. Deploys a prompt cell and registers it in the McpRegistry. Prompts go through the validator name registry for on-chain approval.
diff_register_resource
Compute the StateDiff for RegisterMcpResource. Deploys a resource cell and registers it in the McpRegistry.
diff_register_tool
Compute the StateDiff for RegisterMcpTool.
diff_set_agent_status
Compute the StateDiff for SuspendAgent / ReinstateAgent.
enumerate_prompts
enumerate_resources
enumerate_tools
get_prompt
mcp_conflict_domain
Extract conflict domain for MCP intents. This is the extension point for compiler_aware.rs.
read_resource