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, which 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 none Agent credential secret (agk_...); the server exits if unset
AGNCRED_API_URL no http://localhost:3000 AgnCred base URL, without /api/v1
AGNCRED_PROJECT_DIR no the working directory The directory whose agent surface is fingerprinted. This is the lineage scope (OD-1): one lineage per project directory.
AGNCRED_STATE_DIR no <project dir>/.agncred Where the instance id is cached, so repeated sessions on one machine stay one deployment instance (CU-3).

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, profile:read and identity:register scopes.

Getting a key without pasting one

Consent linking (ADR 0026) is the way to hand a runtime its credentials without a secret ever passing through a chat window or a clipboard:

  1. In the workspace front on slobal.com, pick the agents to link. AgnCred mints one agk_ per selected agent and returns a single-use exchange code (agx_...) with a ten-minute life. The secrets are not in that response.
  2. The machine side redeems the code once: POST /api/v1/link/exchange with {"code": "agx_..."}. The secrets come back exactly once and are erased server-side in the same operation.
  3. Put the returned secret in AGNCRED_API_KEY.

A spent code answers 410 exchange_code_spent; an unknown one answers 404.

Identity registration happens before the first submit

The server fingerprints AGNCRED_PROJECT_DIR once per process, lazily, and registers the lineage, version, revision, instance and manifest hash before any receipt is submitted (defect D1). A receipt without build identity scores zero, so a failed registration blocks the submission rather than passing it through: the tool answers identity_registration_failed and nothing is sent.

Call agncred_identity_status to see what will be registered before submitting anything. If the project has no measurable components, the server falls back to a self_declared manifest and says so loudly, on every result, for as long as the fallback stands (decision register 11).

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

Clients

Every client below starts the same process: npx -y tsx <repo>/packages/mcp-server/src/cli.ts, with AGNCRED_API_URL, AGNCRED_API_KEY and AGNCRED_PROJECT_DIR in its environment. Only the file that holds the entry changes. The same six configurations are on the Setup guides panel in the workspace.

1. API, no MCP

If the runtime cannot start a local process, submit over HTTPS instead: API_GUIDE.md. Nothing on this page is required to produce a receipt.

2. Claude Code

Project scope lives in .mcp.json at the project root:

{
  "mcpServers": {
    "agncred": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "tsx", "/path/to/AgnCred/packages/mcp-server/src/cli.ts"],
      "env": {
        "AGNCRED_API_URL": "https://agncred.com",
        "AGNCRED_API_KEY": "agk_...",
        "AGNCRED_PROJECT_DIR": "/path/to/your/project"
      }
    }
  }
}

Or let the CLI write it:

claude mcp add --transport stdio --scope project \
  --env AGNCRED_API_URL=https://agncred.com \
  --env AGNCRED_API_KEY=agk_... \
  agncred -- npx -y tsx /path/to/AgnCred/packages/mcp-server/src/cli.ts

The session hooks in docs/adapters/claude-code.md are a separate mechanism and can run alongside this one: the hooks submit one receipt per session with no prompting, the MCP tools let the agent submit deliberately.

3. Claude.ai and Claude Cowork

Not available today, and there is no configuration to paste. A claude.ai connector needs a remote MCP endpoint over HTTP; this server is stdio only, so use the Claude Code hook or the API. A hosted endpoint is on the roadmap.

4. Codex CLI and Codex desktop

~/.codex/config.toml:

[mcp_servers.agncred]
command = "npx"
args = ["-y", "tsx", "/path/to/AgnCred/packages/mcp-server/src/cli.ts"]

[mcp_servers.agncred.env]
AGNCRED_API_URL = "https://agncred.com"
AGNCRED_API_KEY = "agk_..."
AGNCRED_PROJECT_DIR = "/path/to/your/project"

Or codex mcp add agncred --env AGNCRED_API_KEY=agk_... -- npx -y tsx /path/to/AgnCred/packages/mcp-server/src/cli.ts.

Codex on chatgpt.com runs no local process, so it cannot start a stdio server at all: submit over the API, or from a paired Helmsly install. The session adapter for the local clients is docs/adapters/codex.md.

5. Gemini CLI and Antigravity

One entry, two files. Gemini CLI reads ~/.gemini/settings.json; Antigravity reads the same mcpServers shape from ~/.gemini/config/mcp_config.json, or from .agents/mcp_config.json inside a workspace.

{
  "mcpServers": {
    "agncred": {
      "command": "npx",
      "args": ["-y", "tsx", "/path/to/AgnCred/packages/mcp-server/src/cli.ts"],
      "env": {
        "AGNCRED_API_URL": "https://agncred.com",
        "AGNCRED_API_KEY": "agk_...",
        "AGNCRED_PROJECT_DIR": "/path/to/your/project"
      }
    }
  }
}

6. Other MCP clients

Cursor, Windsurf, Cline, OpenClaw and Hermes agent all start a stdio server from a command, its arguments and its environment. The keys are the three above; the file that holds them belongs to the client, so read that client's own MCP documentation for the path. Hermes agent writes the same three keys as YAML under mcp_servers rather than JSON under mcpServers.

Tools

Tool Endpoint Purpose
agncred_submit_work_receipt POST /api/v1/agent/receipts (source_type: "mcp") Submit a work-receipt.v0.5. Required: task_type, task_category, task_summary, started_at, completed_at, evidence (1 to 20 items with type and confidentiality). Optional: 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} plus the registered identity.
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, and anyone can reproduce it. Returns the full verification report (signature, key status, event chain, lifecycle status).
agncred_identity_status none (reads the registration) No args. Reports the project directory being fingerprinted, the registered lineage, version, revision and instance, the manifest hash, the build tier and the component count. Registers the fingerprint if that has not happened yet. Call it to see whether receipts will carry a measured fingerprint or the self_declared fallback.

The required summary (work-receipt.v0.5)

task_summary is required from v0.5 (locked decision 12). The calling model writes it under a pinned instruction, and the sha256 of that instruction travels on the receipt in task.summary_instruction_hash. The instruction is part of the submit tool's description, so it reaches the model that writes the summary; the canonical text is contracts/summary-instruction.v1.md.

In substance: describe the work in plain factual language, naming the kind of task, the systems worked on, the categories of tool used and the shape of the outcome. Never rate, praise or grade the work. Never include customer or company names, personal data, credentials, secrets, prompts, source code, file contents or internal references. If in doubt, generalise.

Overriding the instruction changes its hash, and the receipt carries that hash, so the substitution reads as a measured change (FP-4) rather than as prose nobody can audit. Ingest also runs a register screen over the summary: a named deny-list of clearly evaluative words. A summary that grades the work is refused with invalid_receipt and the detail summary_evaluative_register:<word>.

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.