@peac/mcp-server 0.12.4 → 0.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,232 +1,103 @@
1
1
  # @peac/mcp-server
2
2
 
3
- Verify, issue, and bundle PEAC receipts in any MCP client (Claude Desktop, Cursor, Windsurf): locally, offline, no API keys.
3
+ MCP tool server for signed interaction receipt operations: verify, inspect, decode, issue, and bundle.
4
4
 
5
- ## Quick Start
5
+ ## Installation
6
6
 
7
- ### 1. Add to your AI tool (read-only tools)
7
+ ```bash
8
+ pnpm add @peac/mcp-server
9
+ ```
8
10
 
9
- **Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
11
+ Or run directly:
10
12
 
11
- ```json
12
- {
13
- "mcpServers": {
14
- "peac": {
15
- "command": "npx",
16
- "args": ["-y", "@peac/mcp-server"]
17
- }
18
- }
19
- }
13
+ ```bash
14
+ npx @peac/mcp-server
20
15
  ```
21
16
 
22
- **Cursor / Windsurf** (`.mcp.json` at project root):
17
+ ## What It Does
23
18
 
24
- ```json
25
- {
26
- "mcpServers": {
27
- "peac": {
28
- "command": "npx",
29
- "args": ["-y", "@peac/mcp-server"]
30
- }
31
- }
32
- }
33
- ```
19
+ `@peac/mcp-server` exposes PEAC receipt operations as Model Context Protocol (MCP) tools that AI agents and LLM-based applications can call. It supports both stdio and Streamable HTTP transports, with static policy enforcement, concurrency limits, input size guards, and structured error responses with recovery hints.
20
+
21
+ ## How Do I Use It?
34
22
 
35
- ### 1b. Full configuration (with issuing and bundles)
23
+ ### Add to Claude Desktop
36
24
 
37
- **Claude Desktop** with all tools enabled:
25
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
38
26
 
39
27
  ```json
40
28
  {
41
29
  "mcpServers": {
42
30
  "peac": {
43
31
  "command": "npx",
44
- "args": [
45
- "-y",
46
- "@peac/mcp-server",
47
- "--issuer-key",
48
- "env:PEAC_ISSUER_KEY",
49
- "--issuer-id",
50
- "https://your-service.example.com",
51
- "--bundle-dir",
52
- "/tmp/peac-bundles",
53
- "--jwks-file",
54
- "./keys/jwks.json"
55
- ],
56
- "env": {
57
- "PEAC_ISSUER_KEY": "{\"kty\":\"OKP\",\"crv\":\"Ed25519\",\"d\":\"...\",\"x\":\"...\"}"
58
- }
32
+ "args": ["-y", "@peac/mcp-server"]
59
33
  }
60
34
  }
61
35
  }
62
36
  ```
63
37
 
64
- **Cursor / Windsurf** (`.mcp.json` at project root):
38
+ ### Add to Cursor or Windsurf
39
+
40
+ Add to `.mcp.json` at your project root:
65
41
 
66
42
  ```json
67
43
  {
68
44
  "mcpServers": {
69
45
  "peac": {
70
46
  "command": "npx",
71
- "args": [
72
- "-y",
73
- "@peac/mcp-server",
74
- "--issuer-key",
75
- "file:./keys/issuer.jwk",
76
- "--issuer-id",
77
- "https://your-service.example.com",
78
- "--bundle-dir",
79
- "./bundles"
80
- ]
47
+ "args": ["-y", "@peac/mcp-server"]
81
48
  }
82
49
  }
83
50
  }
84
51
  ```
85
52
 
86
- ### 2. Try it (15 seconds)
87
-
88
- Decode a demo receipt from the command line:
53
+ ### Enable receipt issuance
89
54
 
90
55
  ```bash
91
- echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"demo","version":"1.0"}}}
92
- {"jsonrpc":"2.0","method":"notifications/initialized"}
93
- {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"peac_decode","arguments":{"jws":"eyJhbGciOiJFZERTQSIsInR5cCI6InBlYWMtcmVjZWlwdC8wLjEiLCJraWQiOiJkZW1vIn0.eyJpc3MiOiJodHRwczovL2FwaS5leGFtcGxlLmNvbSIsImF1ZCI6Imh0dHBzOi8vY2xpZW50LmV4YW1wbGUuY29tIiwiYW10IjoxMDAsImN1ciI6IlVTRCIsInJhaWwiOiJzdHJpcGUiLCJyZWYiOiJ0eF9kZW1vIiwiaWF0IjoxNzM5MDAwMDAwfQ.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}}}' | npx -y @peac/mcp-server 2>/dev/null | tail -1 | node -e "process.stdin.on('data',d=>{const r=JSON.parse(d).result;console.log(JSON.stringify(r.structuredContent,null,2))})"
56
+ npx @peac/mcp-server \
57
+ --issuer-key env:PEAC_ISSUER_KEY \
58
+ --issuer-id https://example.com
94
59
  ```
95
60
 
96
- Or ask your agent directly:
97
-
98
- > "Decode this PEAC receipt: eyJhbGciOiJFZERTQSIsInR5cCI6InBlYWMt..."
99
-
100
- The agent will use `peac_verify` (with a public key), `peac_inspect` (metadata only), or `peac_decode` (raw header + payload) depending on context.
101
-
102
- ## Tools
103
-
104
- | Tool | What it does | Needs key? | Needs bundle-dir? |
105
- | -------------------- | ------------------------------------------------------- | ---------- | ----------------- |
106
- | `peac_verify` | Cryptographic signature verification + claim validation | No\* | No |
107
- | `peac_inspect` | Decode metadata without verifying signature | No | No |
108
- | `peac_decode` | Raw JWS header + payload dump | No | No |
109
- | `peac_issue` | Sign and return a PEAC receipt JWS | Yes | No |
110
- | `peac_create_bundle` | Create a signed evidence bundle directory | Yes | Yes |
111
-
112
- \* `peac_verify` needs a public key (inline, via JWKS, or `--jwks-file`) but not an issuer key.
113
-
114
- Privileged tools (`peac_issue`, `peac_create_bundle`) only appear in `tools/list` when the server is started with `--issuer-key` and `--issuer-id`. The bundle tool additionally requires `--bundle-dir`.
115
-
116
- Note: stdout is reserved for JSON-RPC messages. All diagnostics, banners, and errors go to stderr.
117
-
118
- ## Two Operating Modes
119
-
120
- **Pure mode** (default): verify, inspect, and decode receipts anywhere. No keys, no filesystem writes, no configuration needed. Safe for any environment.
61
+ ### Start with HTTP transport
121
62
 
122
63
  ```bash
123
- npx -y @peac/mcp-server
64
+ npx @peac/mcp-server --transport http --port 3000
124
65
  ```
125
66
 
126
- **Issuer mode**: additionally issue receipts and create signed evidence bundles. Requires explicit operator opt-in via CLI flags. Privileged tools are only visible and callable when their prerequisites are configured:
127
-
128
- - `--issuer-key` + `--issuer-id` enables `peac_issue`
129
- - `--bundle-dir` additionally enables `peac_create_bundle`
130
-
131
- ```bash
132
- npx -y @peac/mcp-server \
133
- --issuer-key env:PEAC_KEY \
134
- --issuer-id https://your-service.example.com \
135
- --bundle-dir ./bundles
136
- ```
137
-
138
- Evidence bundles are self-contained directories with canonical manifests (sorted keys, SHA-256 receipt hashes, content-addressable `bundle_id`) and signed provenance (`manifest.jws`). The `bundle_id` is deterministic: same receipts and policy always produce the same ID regardless of when the bundle is created. Manifest content includes `created_at`, so the signature differs across runs. Bundles can be verified offline, diffed, cached, and used for audits, disputes, or SOC 2 evidence collection.
139
-
140
- ## Transports
141
-
142
- ### stdio (default)
143
-
144
- Standard MCP transport for local/CLI usage. JSON-RPC over stdin/stdout.
145
-
146
- ```bash
147
- npx -y @peac/mcp-server
148
- ```
149
-
150
- ### Streamable HTTP (v0.11.0+)
151
-
152
- Remote transport for network-accessible MCP servers. Session-isolated with per-session `McpServer` + transport pairs (CVE-2026-25536 defense).
153
-
154
- ```bash
155
- npx -y @peac/mcp-server --transport http --port 3000
156
- ```
67
+ ### MCP tools
157
68
 
158
- Endpoints:
159
-
160
- - `POST /mcp`: JSON-RPC tool calls (requires `Mcp-Session-Id` after initialization)
161
- - `DELETE /mcp`: terminate session
162
- - `GET /health`: health check (no auth)
163
- - `GET /.well-known/oauth-protected-resource[/<path>]`: RFC 9728 PRM (when configured)
164
-
165
- Security defaults: localhost-only bind, CORS deny-all, 1MB request body limit, per-session + per-IP rate limiting (100 req/min), session TTL (30 min), max 100 concurrent sessions.
166
-
167
- See [HTTP Transport Security](../../docs/security/HTTP-TRANSPORT-SECURITY.md) for the full security model.
168
-
169
- ## CLI Options
170
-
171
- ```text
172
- peac-mcp-server [options]
173
-
174
- Options:
175
- --issuer-key <ref> Issuer signing key (env:VAR or file:/path to Ed25519 JWK)
176
- --issuer-id <uri> Issuer identifier URI (required with --issuer-key)
177
- --bundle-dir <path> Directory for evidence bundle output
178
- --policy <path> Policy configuration file (JSON)
179
- --jwks-file <path> JWKS file for verifier key resolution
180
- --transport <type> Transport: stdio (default) or http
181
- --port <number> HTTP port (default: 3000, http only)
182
- --host <address> HTTP bind address (default: 127.0.0.1)
183
- --cors-origins <list> Allowed CORS origins (comma-separated)
184
- --authorization-servers <l> OAuth authorization server URIs (enables PRM)
185
- --public-url <url> Canonical public URL (required for PRM)
186
- --trust-proxy <preset> Trust X-Forwarded-For (off/loopback/linklocal/private/all)
187
- -V, --version Output version number
188
- -h, --help Display help
189
- ```
69
+ | Tool | Description | Availability |
70
+ | -------------------- | ----------------------------------------- | ---------------------------------------------------------- |
71
+ | `peac_verify` | Verify a receipt JWS signature and claims | Always |
72
+ | `peac_inspect` | Inspect receipt structure and metadata | Always |
73
+ | `peac_decode` | Decode a receipt JWS without verification | Always |
74
+ | `peac_issue` | Sign and return a new receipt JWS | Requires `--issuer-key` and `--issuer-id` |
75
+ | `peac_create_bundle` | Create a signed evidence bundle directory | Requires `--issuer-key`, `--issuer-id`, and `--bundle-dir` |
190
76
 
191
- ## Policy Configuration
77
+ All tool responses include `_meta` with `serverVersion`, `policyHash`, `protocolVersion`, and `registeredTools`.
192
78
 
193
- Optional JSON file to customize behavior:
79
+ ### CLI options
194
80
 
195
- ```json
196
- {
197
- "version": "1",
198
- "allow_network": false,
199
- "redaction": {
200
- "strip_evidence": false,
201
- "strip_payment": false,
202
- "inspect_full_claims": false
203
- },
204
- "tools": {
205
- "peac_verify": { "enabled": true },
206
- "peac_inspect": { "enabled": true },
207
- "peac_decode": { "enabled": true },
208
- "peac_issue": { "enabled": true },
209
- "peac_create_bundle": { "enabled": true }
210
- },
211
- "limits": {
212
- "max_jws_bytes": 16384,
213
- "max_response_bytes": 65536,
214
- "tool_timeout_ms": 30000,
215
- "max_concurrency": 10,
216
- "max_claims_bytes": 262144,
217
- "max_bundle_receipts": 256,
218
- "max_bundle_bytes": 16777216,
219
- "max_ttl_seconds": 86400
220
- }
221
- }
222
- ```
81
+ | Flag | Description | Default |
82
+ | ----------------------- | ------------------------------------------------------ | ---------------- |
83
+ | `--transport <type>` | Transport: `stdio` or `http` | `stdio` |
84
+ | `--port <number>` | HTTP port | `3000` |
85
+ | `--host <address>` | HTTP bind address | `127.0.0.1` |
86
+ | `--issuer-key <ref>` | Issuer key reference (`env:VAR` or `file:/path`) | None |
87
+ | `--issuer-id <uri>` | Issuer identifier URI | None |
88
+ | `--policy <path>` | Policy configuration file path | Built-in default |
89
+ | `--jwks-file <path>` | JWKS file for verifier key resolution | None |
90
+ | `--bundle-dir <path>` | Directory for evidence bundle output | None |
91
+ | `--cors-origins <list>` | Allowed CORS origins (comma-separated, HTTP only) | None |
92
+ | `--trust-proxy <value>` | Trust `X-Forwarded-For` (`off`, `loopback`, `private`) | `off` |
223
93
 
224
- ## Library Usage
94
+ ### Programmatic usage
225
95
 
226
- Handlers can be used directly without the MCP server:
96
+ Handlers can be used directly without the MCP server binding:
227
97
 
228
98
  ```typescript
229
- import { handleVerify, getDefaultPolicy, computePolicyHash } from '@peac/mcp-server';
99
+ import { createPeacMcpServer, handleVerify } from '@peac/mcp-server';
100
+ import { getDefaultPolicy, computePolicyHash } from '@peac/mcp-server';
230
101
 
231
102
  const policy = getDefaultPolicy();
232
103
  const policyHash = await computePolicyHash(JSON.stringify(policy));
@@ -235,96 +106,39 @@ const result = await handleVerify({
235
106
  input: { jws: 'eyJ...', public_key_base64url: '...' },
236
107
  policy,
237
108
  context: {
238
- version: '0.11.0',
109
+ version: '0.12.4',
239
110
  policyHash,
240
- protocolVersion: '2025-11-25',
111
+ protocolVersion: '0.2',
241
112
  },
242
113
  });
243
-
244
- if (result.structured.ok) {
245
- // Signature valid, claims verified
246
- }
247
114
  ```
248
115
 
249
- ## MCP SDK Compatibility
250
-
251
- This package pins `@modelcontextprotocol/sdk` at `~1.27.0` (>= 1.26.0 required for CVE-2026-25536 fix). The SDK peer dependency accepts Zod `^3.25 || ^4.0`; the workspace uses Zod 4. If upgrading the SDK, verify tool registration still works by running `pnpm --filter @peac/mcp-server test`. See `package.json` for actual pinned versions.
116
+ ## Integrates With
252
117
 
253
- ## How to Verify a Receipt
118
+ - `@peac/protocol` (Layer 3): Receipt issuance and verification
119
+ - `@peac/crypto` (Layer 2): JWS signing and decoding
120
+ - `@peac/schema` (Layer 1): Receipt schema validation
121
+ - `@peac/kernel` (Layer 0): Error codes and constants
122
+ - `@modelcontextprotocol/sdk`: MCP server and transport bindings
254
123
 
255
- 1. Add the MCP server to your agent (see Quick Start above).
256
- 2. Provide the receipt JWS and a public key (base64url-encoded Ed25519).
257
- 3. Call `peac_verify` and check the `ok` field in the response.
124
+ ## For Agent Developers
258
125
 
259
- ```text
260
- > "Verify this receipt: eyJhbGci... with public key MCowBQYDK2..."
261
- ```
262
-
263
- The tool returns structured content with `ok: true/false`, claim details, and the verification report.
126
+ Connect your agent to this server over stdio or HTTP to gain receipt verification, decoding, and issuance capabilities. The tools use structured outputs with error codes and `next_action` recovery hints so your agent can handle failures programmatically. Every response includes `_meta` for audit and traceability.
264
127
 
265
- ## How to Issue a Receipt
128
+ Read-only tools (`peac_verify`, `peac_inspect`, `peac_decode`) are available with no configuration. To enable issuance, provide an Ed25519 signing key via `--issuer-key` and `--issuer-id`.
266
129
 
267
- Issuance requires an Ed25519 signing key. Start the server with `--issuer-key` and `--issuer-id`:
130
+ ## For Operators
268
131
 
269
- ```bash
270
- npx -y @peac/mcp-server --issuer-key env:PEAC_KEY --issuer-id https://your-service.example.com
271
- ```
132
+ The server enforces static policy with configurable concurrency limits, input size bounds, JWS size caps, and tool timeouts. HTTP transport binds to localhost by default with CORS deny-all. The stdout fence prevents non-JSON-RPC output from corrupting the stdio transport.
272
133
 
273
- Then call `peac_issue` with the receipt claims (amount, currency, rail, reference, audience).
274
-
275
- ## Use with Claude Desktop
276
-
277
- Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
134
+ Security properties: no ambient key discovery (keys must be explicitly provided), no implicit network fetches from tool handlers, path traversal prevention on bundle output, and session isolation on HTTP transport.
278
135
 
279
- ```json
280
- {
281
- "mcpServers": {
282
- "peac": {
283
- "command": "npx",
284
- "args": ["-y", "@peac/mcp-server"]
285
- }
286
- }
287
- }
288
- ```
289
-
290
- Restart Claude Desktop. The PEAC tools appear in the tool picker.
291
-
292
- ## Use with Cursor
293
-
294
- Add to `.cursor/mcp.json` at your project root:
295
-
296
- ```json
297
- {
298
- "mcpServers": {
299
- "peac": {
300
- "command": "npx",
301
- "args": ["-y", "@peac/mcp-server"]
302
- }
303
- }
304
- }
305
- ```
306
-
307
- Restart Cursor. PEAC tools are available in chat.
308
-
309
- ## Architecture
310
-
311
- - **DD-51**: Pure handlers with no MCP SDK dependency
312
- - **DD-52**: No ambient key discovery: explicit `--issuer-key` only
313
- - **DD-53**: Static policy loaded once at startup with SHA-256 hash
314
- - **DD-54**: Structured outputs (`structuredContent` + `text`) on every response
315
- - **DD-55**: No URLs resolved from tool inputs (SSRF prevention)
316
- - **DD-57**: Core modules (`handlers/`, `schemas/`, `infra/`) have zero MCP SDK imports
317
- - **DD-58**: Line-buffered stdout fence validates JSON-RPC 2.0 output (stdio only)
318
- - **DD-119**: Streamable HTTP as additive remote transport (session-isolated)
319
- - **DD-123**: HTTP security boundaries (CORS, rate limiting, Origin/Host validation)
136
+ ## License
320
137
 
321
- ## Links
138
+ Apache-2.0
322
139
 
323
- - Protocol: [peacprotocol.org](https://www.peacprotocol.org)
324
- - GitHub: [peacprotocol/peac](https://github.com/peacprotocol/peac)
325
- - npm: [@peac/mcp-server](https://www.npmjs.com/package/@peac/mcp-server)
326
- - Built by [Originary](https://www.originary.xyz)
140
+ ---
327
141
 
328
- ## License
142
+ PEAC Protocol is an open source project stewarded by Originary and community contributors.
329
143
 
330
- Apache-2.0
144
+ [Docs](https://www.peacprotocol.org) | [GitHub](https://github.com/peacprotocol/peac) | [Originary](https://www.originary.xyz)
package/dist/cli.cjs CHANGED
@@ -49,7 +49,7 @@ var SERVER_NAME, SERVER_VERSION, MCP_PROTOCOL_VERSION;
49
49
  var init_constants = __esm({
50
50
  "src/infra/constants.ts"() {
51
51
  SERVER_NAME = "peac-mcp-server";
52
- SERVER_VERSION = "0.12.4";
52
+ SERVER_VERSION = "0.12.6";
53
53
  MCP_PROTOCOL_VERSION = "2025-11-25";
54
54
  }
55
55
  });