MCP Server Guide

Submit and verify AgnCred work receipts directly from an MCP-capable agent runtime (for example Claude Code). Condensed from packages/mcp-server/README.md — that file is the authoritative reference.

The server speaks MCP over stdio. It authenticates to AgnCred with an agent credential from the environment; the key is only ever sent as an Authorization: Bearer header to agent endpoints and is redacted from all tool output.

Setup

Environment:

Variable Required Default Purpose
AGNCRED_API_KEY yes Agent credential secret (agk_...); the server exits if unset
AGNCRED_API_URL no http://localhost:3000 AgnCred base URL, without /api/v1

Issue the credential in the operator portal or via POST /api/v1/operator/agents/:agentId/credentials (see API_GUIDE.md). The tools need the receipts:create, receipts:read, and profile:read scopes.

Run over stdio:

AGNCRED_API_KEY=agk_... npx tsx packages/mcp-server/src/cli.ts
# or, after workspace install:
AGNCRED_API_KEY=agk_... agncred-mcp

Claude Code configuration (.mcp.json or claude mcp add):

{
  "mcpServers": {
    "agncred": {
      "command": "npx",
      "args": ["-y", "tsx", "D:/AI/Claude/AgnCred/packages/mcp-server/src/cli.ts"],
      "env": { "AGNCRED_API_URL": "http://localhost:3000", "AGNCRED_API_KEY": "agk_..." }
    }
  }
}

Tools

Tool Endpoint Purpose
agncred_submit_work_receipt POST /api/v1/agent/receipts (source_type: "mcp") Submit a work-receipt.v0.3. Required: task_type, task_category, started_at, completed_at, evidence (1–20 items with type and confidentiality). Optional: task_summary, company_id, engagement_id, metrics, claims, estimated_hours_saved, tools_used, workflow_id, execution_id, model_family, idempotency_key (sent as the Idempotency-Key header; a retry replays instead of duplicating). Returns {receipt_id, status, payload_hash, replayed, verification_url}.
agncred_get_receipt_status GET /api/v1/agent/receipts/:id Args: receipt_id. Returns {receipt_id, status, version, payload_hash, attested, signature_valid, event_chain_valid}.
agncred_get_agent_profile GET /api/v1/agent/profile No args. The authenticated agent's identity, score, and recent receipts.
agncred_verify_receipt GET /api/v1/receipts/:id/verify Public verification — no credentials sent; anyone can reproduce it. Returns the full verification report (signature, key status, event chain, lifecycle status).

Privacy rules

Development

pnpm --filter @agncred/mcp-server test

Tests exercise the tool handlers with an injected mock fetch; an end-to-end test against the local PGlite API lives in apps/api/src/mcp-e2e.test.ts.