Herald LogoHerald Docs
Guides

AI Agent MCP

Connect AI agents (Claude, Cursor, etc.) to Herald docs via MCP for assisted integration. Also covers using the Herald CLI as a direct tool for LLM agents.

AI Agent MCP

Herald exposes a Model Context Protocol (MCP) endpoint that lets AI agents browse documentation, search for topics, and retrieve copy-paste ready code — making integration faster.

Endpoint

POST https://useherald.xyz/api/mcp

The endpoint implements the MCP Streamable HTTP transport (JSON-RPC 2.0). No authentication required.

Available Tools

ToolDescription
get_herald_contextFull protocol context — architecture, SDK, API, specs, integration patterns
search_herald_docsSearch documentation by keyword. Params: query, maxResults
get_integration_exampleCopy-paste code. Params: pattern — see table below
get_doc_pageRead a doc page by slug. Params: slug (e.g. quickstart/quickstart, cli/commands)

get_integration_example patterns

PatternDescription
backendExpress server with liquidation alerts
serverlessNext.js API route
webhookWebhook receiver with HMAC signature verification
batchBatch-send to 100 wallets
registration-checkReact component to check wallet registration
broadcastBroadcast to all subscribers
subscribeManage wallet subscriptions
cli-sendHerald CLI one-liner for terminal or CI/CD
cli-agentHerald CLI agent tool-use pattern with --json, --wait, --from-stdin

Configuring in Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "herald-docs": {
      "type": "url",
      "url": "https://useherald.xyz/api/mcp"
    }
  }
}

Configuring in Cursor

  1. Go to Settings > Features > MCP Servers
  2. Add a new MCP server with URL: https://useherald.xyz/api/mcp

Configuring in Claude Code (CLI)

claude mcp add herald-docs --transport http https://useherald.xyz/api/mcp

Testing via curl

# List tools
curl -X POST https://useherald.xyz/api/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

# Get full context
curl -X POST https://useherald.xyz/api/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"get_herald_context","arguments":{}}}'

# Search docs
curl -X POST https://useherald.xyz/api/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"search_herald_docs","arguments":{"query":"CLI idempotency"}}}'

# Get CLI send example
curl -X POST https://useherald.xyz/api/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"get_integration_example","arguments":{"pattern":"cli-send"}}}'

# Get CLI agent pattern
curl -X POST https://useherald.xyz/api/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"get_integration_example","arguments":{"pattern":"cli-agent"}}}'

Using the Herald CLI as an agent tool

Instead of calling the REST API directly, AI agents can invoke the Herald CLI as a shell tool. This is simpler to configure, produces structured JSON output, and handles auth, retries, and idempotency automatically.

Install once

npm install -g @herald-protocol/cli

Tool definition (OpenAI / Claude tool-use format)

{
  "name": "herald_notify",
  "description": "Send a notification to a Solana wallet via Herald Protocol. Use --wait to block until delivered. Use --idempotency-key to make retries safe.",
  "parameters": {
    "type": "object",
    "properties": {
      "wallet":          { "type": "string", "description": "Recipient Solana wallet address" },
      "subject":         { "type": "string", "description": "Subject line (max ~100 chars)" },
      "body":            { "type": "string", "description": "Body text (Markdown supported)" },
      "category":        { "type": "string", "enum": ["defi","governance","system","marketing","security"] },
      "idempotency_key": { "type": "string", "description": "Unique key to prevent duplicate sends on retry" },
      "wait":            { "type": "boolean", "description": "Block until delivered or failed (recommended for agents)" }
    },
    "required": ["wallet", "subject", "body", "category"]
  }
}

Shell invocation

herald notify send \
  --wallet "$wallet" \
  --subject "$subject" \
  --body "$body" \
  --category "$category" \
  --idempotency-key "$idempotency_key" \
  --wait \
  --json
  1. Health check first — call herald doctor --json and halt if ok is false
  2. Send with --wait — get confirmed delivery in a single call instead of send + poll loop
  3. Always use --idempotency-key — pass a unique key derived from your job/run ID so retries don't duplicate
  4. Read exit codes0 success, 4 auth error, 5 rate-limited, 6 network down

Batch sends for agents

echo '[{"wallet":"…","subject":"…","body":"…","category":"system"}]' \
  | herald notify batch \
    --from-stdin \
    --idempotency-key "$JOB_ID" \
    --yes \
    --json

See the full CLI agent guide for more patterns.


Protocol

The endpoint uses MCP Streamable HTTP transport:

  1. Initialize: Send {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"client","version":"1.0"}}}
  2. List tools: {"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}
  3. Call tool: {"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"tool_name","arguments":{...}}}

All responses follow standard JSON-RPC 2.0 format.

On this page