Skip to content

Receipt-signing middleware for MCP server frameworks #4

@tomjwxf

Description

@tomjwxf

Problem

MCP server implementations (Express, Hono, Cloudflare Workers) need a simple way to add receipt signing without adopting the full protect-mcp gateway. Developers want app.use(receiptMiddleware()) — not a separate proxy process.

Proposal

A lightweight middleware that plugs into existing MCP server frameworks:

import { receiptMiddleware } from 'protect-mcp/middleware';

// Express
app.use('/mcp', receiptMiddleware({
  keyPath: './keys/gateway.json',
  policy: './protect-mcp.json'
}));

// Hono
app.use('/mcp/*', receiptMiddleware({ ... }));

What the middleware does

  1. Intercepts tools/call requests
  2. Evaluates against policy (JSON, Cedar, or external PDP)
  3. Signs the decision as an Ed25519 receipt
  4. Attaches the receipt to the response headers
  5. Logs to .protect-mcp-receipts.jsonl

What it doesn't do

  • No process wrapping — runs in-process
  • No stdio proxying — HTTP only
  • No approval gates — those require the full gateway

Verification

npx @veritasacta/verify .protect-mcp-receipts.jsonl

Related

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions