@peac/mappings-mcp 0.12.5 → 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.
Files changed (2) hide show
  1. package/README.md +102 -3
  2. package/package.json +17 -5
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @peac/mappings-mcp
2
2
 
3
- Model Context Protocol (MCP) integration for PEAC
3
+ Model Context Protocol (MCP) integration for PEAC: attach and extract signed evidence carriers via MCP `_meta` keys.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,9 +8,108 @@ Model Context Protocol (MCP) integration for PEAC
8
8
  pnpm add @peac/mappings-mcp
9
9
  ```
10
10
 
11
- ## Documentation
11
+ ## What It Does
12
12
 
13
- See [peacprotocol.org](https://www.peacprotocol.org) for full documentation.
13
+ `@peac/mappings-mcp` provides the carrier format for embedding PEAC signed receipts in MCP tool responses. It uses reverse-DNS `_meta` keys (`org.peacprotocol/receipt_ref`, `org.peacprotocol/receipt_jws`) to attach and extract evidence carriers, with budget enforcement utilities for cost-controlled tool calls. Legacy `peac_receipt` format is supported for backward compatibility.
14
+
15
+ ## How Do I Use It?
16
+
17
+ ### Attach a receipt to an MCP tool response
18
+
19
+ ```typescript
20
+ import { attachReceiptToMeta } from '@peac/mappings-mcp';
21
+ import type { McpResultLike } from '@peac/mappings-mcp';
22
+
23
+ const result: McpResultLike = { content: [{ type: 'text', text: 'Done' }] };
24
+
25
+ attachReceiptToMeta(result, carrier, {
26
+ agentId: 'agent:tool-server-1',
27
+ verifiedAt: new Date().toISOString(),
28
+ });
29
+
30
+ // result._meta now contains:
31
+ // "org.peacprotocol/receipt_ref": "sha256:..."
32
+ // "org.peacprotocol/receipt_jws": "eyJ..."
33
+ // "org.peacprotocol/agent_id": "agent:tool-server-1"
34
+ ```
35
+
36
+ ### Extract a receipt from an MCP tool response
37
+
38
+ ```typescript
39
+ import { extractReceiptFromMeta, extractReceiptFromMetaAsync } from '@peac/mappings-mcp';
40
+
41
+ // Sync: structural validation only
42
+ const extracted = extractReceiptFromMeta(result);
43
+ if (extracted) {
44
+ console.log(extracted.receipts[0].receipt_ref);
45
+ }
46
+
47
+ // Async: includes receipt_ref consistency verification
48
+ const verified = await extractReceiptFromMetaAsync(result);
49
+ if (verified && verified.violations.length === 0) {
50
+ console.log(verified.receipts[0].receipt_jws);
51
+ }
52
+ ```
53
+
54
+ ### Use the carrier adapter interface
55
+
56
+ ```typescript
57
+ import { McpCarrierAdapter } from '@peac/mappings-mcp';
58
+
59
+ const adapter = new McpCarrierAdapter();
60
+
61
+ // Extract from incoming MCP response
62
+ const extracted = adapter.extract(mcpResult);
63
+
64
+ // Attach to outgoing MCP response
65
+ adapter.attach(mcpResult, [carrier]);
66
+ ```
67
+
68
+ ### Enforce budget limits on tool calls
69
+
70
+ ```typescript
71
+ import { checkBudget } from '@peac/mappings-mcp';
72
+ import type { BudgetConfig } from '@peac/mappings-mcp';
73
+
74
+ const config: BudgetConfig = {
75
+ maxPerCallMinor: 500n, // $5.00 max per call
76
+ maxDailyMinor: 10000n, // $100.00 max per day
77
+ currency: 'USD',
78
+ };
79
+
80
+ const result = checkBudget(8500n, 1000n, 'USD', config);
81
+
82
+ if (result.allowed) {
83
+ console.log(`Remaining: ${result.remainingMinor} minor units`);
84
+ } else {
85
+ console.log(`Denied: ${result.reason}`);
86
+ }
87
+ ```
88
+
89
+ ### Check for MCP reserved key collisions
90
+
91
+ ```typescript
92
+ import { isMcpReservedKey, assertNotMcpReservedKey } from '@peac/mappings-mcp';
93
+
94
+ isMcpReservedKey('dev.mcp/anything'); // true (reserved)
95
+ isMcpReservedKey('org.peacprotocol/receipt_ref'); // false (safe)
96
+ ```
97
+
98
+ ## Integrates With
99
+
100
+ - `@peac/kernel` (Layer 0): Evidence carrier types (`PeacEvidenceCarrier`, `CarrierAdapter`)
101
+ - `@peac/schema` (Layer 1): Carrier schema validation and `computeReceiptRef()`
102
+ - `@peac/mcp-server` (Layer 5): Uses this package for receipt attachment in tool responses
103
+
104
+ ## For Agent Developers
105
+
106
+ If you are building an MCP tool server that issues or verifies signed receipts:
107
+
108
+ - Use `attachReceiptToMeta()` to embed evidence in tool call responses
109
+ - Use `extractReceiptFromMetaAsync()` to extract and verify receipts from incoming responses
110
+ - Use `checkBudget()` for per-call and aggregate cost enforcement
111
+ - All `_meta` keys use the `org.peacprotocol/` prefix, which does not collide with MCP reserved prefixes
112
+ - See the [llms.txt](https://github.com/peacprotocol/peac/blob/main/llms.txt) for a concise protocol overview
14
113
 
15
114
  ## License
16
115
 
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@peac/mappings-mcp",
3
- "version": "0.12.5",
3
+ "version": "0.12.6",
4
4
  "description": "Model Context Protocol (MCP) integration for PEAC",
5
5
  "main": "dist/index.cjs",
6
6
  "types": "dist/index.d.ts",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/peacprotocol/peac.git",
9
+ "url": "git+https://github.com/peacprotocol/peac.git",
10
10
  "directory": "packages/mappings/mcp"
11
11
  },
12
- "author": "jithinraj <7850727+jithinraj@users.noreply.github.com>",
12
+ "author": "PEAC Protocol Contributors",
13
13
  "license": "Apache-2.0",
14
14
  "bugs": {
15
15
  "url": "https://github.com/peacprotocol/peac/issues"
@@ -23,8 +23,8 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@peac/kernel": "0.12.5",
27
- "@peac/schema": "0.12.5"
26
+ "@peac/kernel": "0.12.6",
27
+ "@peac/schema": "0.12.6"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "^22.19.11",
@@ -41,6 +41,18 @@
41
41
  },
42
42
  "./package.json": "./package.json"
43
43
  },
44
+ "keywords": [
45
+ "peac",
46
+ "peacprotocol",
47
+ "interaction-records",
48
+ "signed-records",
49
+ "receipts",
50
+ "originary",
51
+ "mcp",
52
+ "model-context-protocol",
53
+ "tool-calls",
54
+ "tool-invocation"
55
+ ],
44
56
  "scripts": {
45
57
  "prebuild": "rm -rf dist",
46
58
  "build": "pnpm run build:js && pnpm run build:types",