Explore (579)Live Systems (52)Pricing
Log InGet API Key✓ Verify It Yourself

@h33/mcp

v0.1.0 MIT

H33 attestation layer for Model Context Protocol servers. Wraps any MCP server so that every tool call, resource read, and prompt completion produces a cryptographic receipt — post-quantum signed, DAG-chained, and independently verifiable.

Every tool call attested. Every response verifiable. Zero code changes to your existing MCP handlers.

$ npm install @h33/mcp @h33/agent @modelcontextprotocol/sdk
Package: @h33/mcp
Version: 0.1.0
License: MIT
Peer dependency: @modelcontextprotocol/sdk >= 0.5.0
Dependency: @h33/agent ^0.1.0
Repository: github.com/H33ai-postquantum/h33-mcp

1. Exports

attestMCPServer(server, config)

Wraps an existing MCP Server with automatic attestation. Zero code changes to existing handlers.

getAgent(server)

Access the underlying H33Agent instance for advanced operations such as verification, policy checks, and replay.

createAttestedTool(agent, def)

Create an individual tool definition with built-in attestation when you need per-tool control.

h33Middleware(agent)

Express/Hono middleware that adds X-H33-Receipt headers to every HTTP response.

The package also re-exports H33Agent and H33AgentConfig from @h33/agent for convenience.

2. Quick Start

Three lines transform a standard MCP server into one where every tool call produces a cryptographic receipt:

TypeScript
import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { attestMCPServer } from '@h33/mcp'; const server = new Server( { name: 'my-server', version: '1.0.0' }, { capabilities: { tools: {} } }, ); // One line -- every tool call is now attested const attested = attestMCPServer(server, { agent: { name: 'My MCP Server', canonicalName: 'h33.agent.acme.mcp.myserver.prod.001', tenantId: 'acme-corp', }, }); // Register tools as normal -- attestation is automatic attested.setRequestHandler('tools/call', async (request) => { const result = await handleToolCall(request); return result; // _h33_receipt automatically attached });

Set your API key via environment variable. Never hardcode credentials:

export H33_API_KEY="your-key-here"

3. attestMCPServer(server, config)

The primary integration point. Wraps an MCP Server instance by intercepting setRequestHandler calls. The returned object is the same server instance — existing code continues to work unchanged. Attestation is applied automatically based on configuration flags.

3.1. Configuration

FieldTypeDefaultDescription
agentH33AgentConfigrequiredAgent identity and configuration (name, canonicalName, tenantId).
attestToolsbooleantrueAttest tools/call requests.
attestResourcesbooleantrueAttest resources/read requests.
attestPromptsbooleanfalseAttest prompts/get requests. Opt-in because prompt responses may be large.

3.2. What Gets Attested

MCP MethodAttested by DefaultAttestation Type
tools/callYesTool call (input hash + output hash)
resources/readYesAction (resource URI hash + response hash)
prompts/getNo (opt-in)Action (prompt name hash + response hash)

4. createAttestedTool(agent, def)

When you need per-tool attestation control rather than wrapping the entire server, create individual attested tools. Each invocation hashes the input, executes the handler, hashes the output, and produces a receipt through the provided H33Agent.

TypeScript
import { H33Agent } from '@h33/agent'; import { createAttestedTool } from '@h33/mcp'; const agent = new H33Agent({ name: 'Claims Agent', canonicalName: 'h33.agent.acme.claims.review.prod.001', tenantId: 'acme-corp', }); await agent.start(); const searchTool = createAttestedTool(agent, { name: 'search_database', description: 'Search the claims database', inputSchema: { type: 'object', properties: { query: { type: 'string' } }, required: ['query'], }, handler: async (args) => await db.search(args.query), }); // Every call returns both the result and a receipt const { result, receipt } = await searchTool.handler({ query: 'open claims' }); console.log(receipt.verification_url);

The tool name is automatically namespaced as h33.tool.mcp.<name>.v1 in the attestation chain.

5. h33Middleware(agent)

HTTP middleware that attests every request/response pair. Compatible with Express, Hono, or any framework using the (req, res, next) pattern. Receipt ID and verification URL are set as response headers automatically.

5.1. Express

TypeScript
import express from 'express'; import { H33Agent } from '@h33/agent'; import { h33Middleware } from '@h33/mcp'; const agent = new H33Agent({ name: 'API Gateway', canonicalName: 'h33.agent.acme.gateway.prod.001', tenantId: 'acme-corp', }); await agent.start(); const app = express(); app.use('/tools', h33Middleware(agent)); app.post('/tools/search', async (req, res) => { const results = await db.search(req.body.query); res.json(results); // X-H33-Receipt and X-H33-Verify headers set automatically });

5.2. Hono

TypeScript
import { Hono } from 'hono'; import { H33Agent } from '@h33/agent'; import { h33Middleware } from '@h33/mcp'; const agent = new H33Agent({ /* ... */ }); await agent.start(); const app = new Hono(); app.use('/tools/*', h33Middleware(agent));

6. getAgent(server)

Retrieves the underlying H33Agent instance from a wrapped server. Returns null if the server has not been wrapped with attestMCPServer. Use this for advanced operations: verifying receipts, checking delegation policy, or replaying sessions.

TypeScript
const agent = getAgent(attested); if (agent) { const proof = await agent.verify(receipt); console.log(proof.valid); // true }

7. Attestation Flow

When an MCP client invokes a tool on a wrapped server, the following sequence executes transparently:

MCP Client | | tools/call request v Attested Server ---> Your Handler | | | v | result object | +---> H33Agent.callTool() | | | +-- SHA-256 hash input arguments | +-- SHA-256 hash output result | +-- PQ-sign + DAG-chain receipt | +-- Return receipt | +---> Attach _h33_receipt to result | v MCP Client <-- result + _h33_receipt

The attestation layer never modifies the handler's return value. Receipts are attached as a non-intrusive _h33_receipt property on the result object. If attestation fails for any reason, the original result is returned unmodified — attestation failure never breaks the response.

8. Receipt Structure

Receipts are attached to tool call results as a _h33_receipt property. For HTTP middleware, they appear as response headers instead.

8.1. Tool Call Receipts

JSON response with receipt
{ "content": [{ "type": "text", "text": "..." }], "_h33_receipt": { "receipt_id": "abc123...", "node_hash": "def456...", "verification_url": "https://api.h33.ai/api/v1/agents/proofs/abc123", "replay_ref": "..." } }

8.2. HTTP Middleware Headers

When using h33Middleware, attestation data is returned via HTTP response headers rather than in the response body:

X-H33-Receipt Unique receipt/node ID for this request-response attestation.
X-H33-Verify Public URL for independent verification. No API key required.

8.3. Receipt Fields

FieldTypeDescription
receipt_idstringUnique identifier for this attestation node.
node_hashstringSHA-256 hash chaining this node to its parent in the session DAG.
verification_urlstringPublic URL for independent verification (no API key needed).
replay_refstringReference for deterministic session replay.

9. Verification

Every receipt is independently verifiable. Verification requires no API key and can be performed by any party.

Via HTTP

GET https://api.h33.ai/api/v1/agents/proofs/{receipt_id}

Via CLI

$ hats verify --node {receipt_id}

Via SDK

const agent = getAgent(attested); const proof = await agent.verify(receipt); console.log(proof.valid); // true console.log(proof.chain_intact); // true

10. Full Example

A complete MCP server with two attested tools, running on stdio transport:

examples/basic-server.ts
import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { attestMCPServer } from '@h33/mcp'; const server = new Server( { name: 'example-attested-server', version: '1.0.0' }, { capabilities: { tools: {} } }, ); const attested = attestMCPServer(server, { agent: { name: 'Example MCP Server', canonicalName: 'h33.agent.example.mcp.server.dev.001', tenantId: 'example-org', }, }); attested.setRequestHandler('tools/list', async () => ({ tools: [ { name: 'lookup_claim', description: 'Look up an insurance claim by ID', inputSchema: { type: 'object', properties: { claim_id: { type: 'string' } }, required: ['claim_id'], }, }, ], })); attested.setRequestHandler('tools/call', async (request) => { const { name, arguments: args } = request.params; if (name === 'lookup_claim') { const claim = { id: args.claim_id, status: 'open', amount: 15000 }; return { content: [{ type: 'text', text: JSON.stringify(claim) }] }; } throw new Error(`Unknown tool: ${name}`); // _h33_receipt attached automatically to the result }); const transport = new StdioServerTransport(); await attested.connect(transport);

11. Related Resources