MCP Server

Cortex includes a Model Context Protocol (MCP) server that exposes chain state as tools for AI agents. The server connects to the same Postgres database as the REST API.

Server Info

{
  "name": "ai-chain",
  "version": "0.1.0"
}

Tools

lookup_agent

Look up an agent by its numeric ID. Returns owner, metadata, pubkey, capabilities, and revocation status.

Parameters: agentId: number

// Agent calls:
lookup_agent({ agentId: 1 })

// Returns:
{
  "agent_id": "1",
  "owner": "0x3c44...",
  "metadata_uri": "ipfs://agent-meta",
  "pubkey": "0xaabb",
  "revoked": false
}

list_open_intents

List intents filtered by status. Defaults to OPEN intents. Returns intent details including tokens, amounts, and deadlines.

Parameters: status?: 'open' | 'filled' | 'cancelled', limit?: number

// List open intents:
list_open_intents({ status: "open", limit: 10 })

// Returns array of intent objects with
// owner, tokens, amounts, deadline, nonce

get_policy

Get spending policies for a smart account. Returns spend limits, target allowlists, and function allowlists.

Parameters: account: string (address)

// Query account policies:
get_policy({ account: "0x70997..." })

// Returns spend limits, target allowlists,
// and function selector allowlists

explain_tx

Get a human-readable explanation of a transaction. Returns decoded events and a summary of what happened.

Parameters: txHash: string

// Explain a transaction:
explain_tx({ txHash: "0xabc..." })

// Returns summary + decoded events:
// "Intent #1 submitted by 0x..."

lookup_attestation

Look up an attestation by its numeric ID. Returns attester, schema, subject, data hash, and revocation status.

Parameters: attestationId: number

// Look up attestation:
lookup_attestation({ attestationId: 1 })

// Returns attester, schema, subject,
// data hash, and revocation status

list_licenses

List Cortex machine-readable license documents for an agent, issuer, merchant, service, or asset.

Parameters: holder?: string, issuer?: string, merchant_id?: string, service_numeric_id?: string, asset_id?: string, active?: boolean

// List active licenses for an agent:
list_licenses({ holder: "0x70997...", active: true })

// Returns canonical license inventory
// with rights, asset, quote, receipt, and expiry fields

check_license

Check whether an agent can use a licensed asset for a requested action and context.

Parameters: license_hash: string, action: string, agent?: string, quote_hash?: string, receipt_id?: string

// Check use before consuming a protected report:
check_license({
  license_hash: "0x...",
  agent: "0x70997...",
  action: "commercial_output",
  commercial: true
})

// Returns allowed plus per-check reasons

Usage

The MCP server runs as a stdio transport. Connect it to any MCP-compatible client (Claude Desktop, Claude Code, etc.) by adding it to your MCP configuration:

{
  "mcpServers": {
    "cortex": {
      "command": "node",
      "args": ["mcp/dist/src/index.js"],
      "env": {
        "DATABASE_URL": "postgresql://ai_chain:ai_chain@localhost:5433/ai_chain",
        "API_URL": "http://localhost:3001"
      }
    }
  }
}