@emilia-protocol/mcp-server 0.1.0 → 1.0.1

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 (5) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +969 -34
  3. package/auto-receipt.js +402 -0
  4. package/index.js +1552 -246
  5. package/package.json +41 -11
package/README.md CHANGED
@@ -1,65 +1,1000 @@
1
- # EMILIA Protocol MCP Server
1
+ # @emilia-protocol/mcp-server
2
2
 
3
- Trust layer tools for AI agents. Give any MCP-compatible client (Claude, etc.) the ability to check EMILIA Scores before transacting.
3
+ [![npm version](https://img.shields.io/npm/v/@emilia-protocol/mcp-server)](https://www.npmjs.com/package/@emilia-protocol/mcp-server)
4
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
+ [![MCP](https://img.shields.io/badge/protocol-MCP-5a5aff)](https://modelcontextprotocol.io)
4
6
 
5
- ## Quick Start
7
+ **Trust enforcement for high-risk actions via MCP. Pre-action binding, policy-bound verification, one-time consumption, and accountable human signoff.**
6
8
 
7
- ```bash
8
- npx @emilia-protocol/mcp-server
9
+ ---
10
+
11
+ ## What This Is
12
+
13
+ EMILIA Protocol enforces trust before a high-risk action. This MCP server gives any Claude conversation or agent pipeline EP's gate: call **`ep_guard_action`** before any irreversible action — a payment, deletion, or account change — to require a named human's signoff and get a verifiable receipt, then poll **`ep_check_signoff`** until it's approved. 36 tools in all, but by default the server advertises a **focused 17** — the trust gate plus the pre-action protocol (handshake + commit binding, signoff orchestration, policy evaluation, offline receipt verification, delegation, install preflight). Set `EP_INCLUDE_REGISTRY_TOOLS=true` to also expose the legacy registry and reputation tools. Add it to Claude Desktop in 60 seconds. No self-hosted EP backend required.
14
+
15
+ ---
16
+
17
+ ## Installation
18
+
19
+ Add the following to your MCP client config. No local install required — `npx` handles it.
20
+
21
+ ### Claude Desktop
22
+
23
+ Config file: `~/Library/Application Support/Claude/claude_desktop_config.json`
24
+
25
+ ```json
26
+ {
27
+ "mcpServers": {
28
+ "emilia-protocol": {
29
+ "command": "npx",
30
+ "args": ["-y", "@emilia-protocol/mcp-server"],
31
+ "env": {
32
+ "EP_API_KEY": "ep_live_your_key_here",
33
+ "EP_BASE_URL": "https://emiliaprotocol.ai"
34
+ }
35
+ }
36
+ }
37
+ }
9
38
  ```
10
39
 
11
- ## Claude Desktop Config
40
+ ### Cursor
12
41
 
13
- Add to `~/.claude/claude_desktop_config.json`:
42
+ Config file: `.cursor/mcp.json`
14
43
 
15
44
  ```json
16
45
  {
17
46
  "mcpServers": {
18
- "emilia": {
47
+ "emilia-protocol": {
19
48
  "command": "npx",
20
- "args": ["@emilia-protocol/mcp-server"],
49
+ "args": ["-y", "@emilia-protocol/mcp-server"],
21
50
  "env": {
22
- "EP_BASE_URL": "https://emiliaprotocol.ai",
23
- "EP_API_KEY": "ep_live_your_key_here"
51
+ "EP_API_KEY": "ep_live_your_key_here",
52
+ "EP_BASE_URL": "https://emiliaprotocol.ai"
24
53
  }
25
54
  }
26
55
  }
27
56
  }
28
57
  ```
29
58
 
30
- `EP_API_KEY` is only required for write operations (submit receipt, register entity). Score lookup and verification are public.
59
+ ### npx (zero install, test immediately)
60
+
61
+ ```bash
62
+ EP_API_KEY=ep_live_your_key_here npx @emilia-protocol/mcp-server
63
+ ```
64
+
65
+ Use EP Commit when a relying system wants proof that a high-stakes action was evaluated before it proceeded.
31
66
 
32
- ## Tools
67
+ ---
33
68
 
34
- | Tool | Auth | Description |
35
- |------|------|-------------|
36
- | `ep_score_lookup` | None | Check any entity's EMILIA Score |
37
- | `ep_submit_receipt` | API Key | Submit a transaction receipt |
38
- | `ep_verify_receipt` | None | Verify receipt against on-chain Merkle root |
39
- | `ep_search_entities` | None | Search entities by name/capability |
40
- | `ep_register_entity` | API Key | Register a new entity |
41
- | `ep_leaderboard` | None | Get top-scored entities |
69
+ ## Quick Start
42
70
 
43
- ## Example Usage (in Claude)
71
+ Five scenarios you can try immediately after connecting.
44
72
 
45
- > "Check the EMILIA Score for rex-booking-v1 before I book with them."
73
+ ### 1. Check if you should transact with a counterparty
46
74
 
47
- > "Submit a receipt for my last purchase from entity abc-merchant-v1. Delivery was on time (95), product matched the listing (88), price was honored (100)."
75
+ ```
76
+ "Check if I can trust acme-logistics for a $5,000 freight booking"
77
+ ```
48
78
 
49
- > "Find me a booking agent with an EMILIA Score above 80."
79
+ EP runs the gate check, then retrieves the full behavioral profile:
50
80
 
51
- ## Self-Hosted
81
+ ```
82
+ ep_trust_gate(entity_id="acme-logistics", action="purchase", value_usd=5000, policy="standard")
83
+ ep_trust_profile(entity_id="acme-logistics")
84
+ ```
52
85
 
53
- Point `EP_BASE_URL` to your own EP implementation:
86
+ **Trust gate response:**
87
+ ```
88
+ Trust Gate: purchase
89
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
90
+ Entity: acme-logistics
91
+ Decision: ✓ ALLOW
92
+ Policy: standard
93
+ Confidence: confident
54
94
 
55
- ```json
56
- {
57
- "env": {
58
- "EP_BASE_URL": "https://your-instance.example.com"
95
+ Reasons:
96
+ ✓ Confidence meets standard threshold
97
+ Completion rate 94% (above 85% floor)
98
+ Dispute rate 1.2% (below 5% ceiling)
99
+ ```
100
+
101
+ **Trust profile response:**
102
+ ```
103
+ Trust Profile: Acme Logistics (acme-logistics)
104
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
105
+ Confidence: confident
106
+ Established: Yes
107
+ Evidence: 47 (current) / 112 (historical)
108
+ Receipts: 112 from 23 submitters
109
+
110
+ Behavioral:
111
+ Completion rate: 94%
112
+ Retry rate: 4%
113
+ Abandon rate: 1%
114
+ Dispute rate: 1.2%
115
+
116
+ Signals:
117
+ Delivery: 91
118
+ Product: 88
119
+ Price: 96
120
+ Returns: 82
121
+ Consistency: 0.91
122
+
123
+ Provenance: bilateral: 71%, self_attested: 29%
124
+ Bilateral rate: 71%
125
+ ```
126
+
127
+ ---
128
+
129
+ ### 2. Submit a receipt after a completed task
130
+
131
+ ```
132
+ "Record that freight-agent-7 completed my delivery order on time"
133
+ ```
134
+
135
+ ```
136
+ ep_submit_receipt(
137
+ entity_id="freight-agent-7",
138
+ transaction_ref="FRT-20241218-001",
139
+ transaction_type="delivery",
140
+ agent_behavior="completed",
141
+ delivery_accuracy=96,
142
+ price_integrity=100,
143
+ claims={"delivered": true, "on_time": true, "price_honored": true}
144
+ )
145
+ ```
146
+
147
+ **Response:**
148
+ ```
149
+ Receipt submitted.
150
+ ID: ep_rcpt_a8f3c2d1e9b4
151
+ Hash: sha256:7f3a9c1b2e8d4f6a...
152
+ Entity trust profile updated. Query with ep_trust_profile for current state.
153
+ ```
154
+
155
+ Receipts are append-only and cryptographically chain-linked. They cannot be deleted — only disputed.
156
+
157
+ ---
158
+
159
+ ### 3. Check if a plugin is safe to install
160
+
161
+ ```
162
+ "Should I install the code-helper GitHub App in my private repo?"
163
+ ```
164
+
165
+ ```
166
+ ep_install_preflight(
167
+ entity_id="github_app:acme/code-helper",
168
+ policy="github_private_repo_safe_v1",
169
+ context={"host": "github", "data_sensitivity": "private_repo", "permission_class": "read_write"}
170
+ )
171
+ ```
172
+
173
+ **Response:**
174
+ ```
175
+ Install Preflight: Acme Code Helper (github_app:acme/code-helper)
176
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
177
+ Decision: ⚠ REVIEW
178
+ Policy: github_private_repo_safe_v1
179
+ Confidence: provisional
180
+
181
+ Reasons:
182
+ Publisher not verified against GitHub profile
183
+ Permission class (read_write) exceeds policy floor for private repos
184
+ Provenance not verified (no signed release artifacts)
185
+
186
+ Software:
187
+ Publisher verified: false
188
+ Provenance verified: false
189
+ Permission class: read_write
190
+ ```
191
+
192
+ ---
193
+
194
+ ### 4. Create a delegation
195
+
196
+ ```
197
+ "Authorize my scheduling agent to book meetings on my behalf for the next 8 hours"
198
+ ```
199
+
200
+ ```
201
+ ep_create_delegation(
202
+ principal_id="ep_principal_usr_abc123",
203
+ agent_entity_id="my-scheduler",
204
+ scope=["book_meeting", "send_invite"],
205
+ max_value_usd=0,
206
+ expires_at="2024-12-18T20:00:00Z"
207
+ )
208
+ ```
209
+
210
+ **Response:**
211
+ ```
212
+ Delegation created.
213
+ ID: ep_dlg_x7y2z9w1
214
+ Principal: ep_principal_usr_abc123
215
+ Agent: my-scheduler
216
+ Scope: book_meeting, send_invite
217
+ Expires: 2024-12-18T20:00:00Z
218
+ Status: active
219
+ ```
220
+
221
+ Any action the agent takes can now reference this delegation ID, creating a complete, auditable authorization chain.
222
+
223
+ ---
224
+
225
+ ### 5. File a dispute
226
+
227
+ ```
228
+ "That receipt for acme-co was wrong — they abandoned my order, not completed it"
229
+ ```
230
+
231
+ ```
232
+ ep_dispute_file(
233
+ receipt_id="ep_rcpt_a8f3c2d1e9b4",
234
+ reason="inaccurate_signals",
235
+ description="Receipt records agent_behavior=completed but the order was abandoned after 3 days with no communication. Order ref FRT-20241218-001.",
236
+ evidence={"order_status_screenshot": "url", "support_ticket": "TKT-9921"}
237
+ )
238
+ ```
239
+
240
+ **Response:**
241
+ ```
242
+ Dispute filed.
243
+ Dispute ID: ep_disp_3f7a1c9b
244
+ Receipt: ep_rcpt_a8f3c2d1e9b4
245
+ Status: open
246
+ Response deadline: 2024-12-25T12:00:00Z
247
+ The submitter has 7 days to respond. Trust is suspended pending resolution.
248
+ ```
249
+
250
+ ---
251
+
252
+ ## Tool Reference
253
+
254
+ ### Summary
255
+
256
+ | Tool | Description | Auth Required |
257
+ |------|-------------|:---:|
258
+ | `ep_guard_action` | THE GATE — call before any irreversible action; mints a receipt, opens signoff | Yes |
259
+ | `ep_check_signoff` | Poll a pending signoff until a named human approves or denies | Yes |
260
+ | `ep_trust_profile` | Full trust profile — the canonical read surface | No |
261
+ | `ep_trust_evaluate` | Policy evaluation with Trust Decision (allow/review/deny) and failure reasons | No |
262
+ | `ep_trust_gate` | Pre-action trust check — call before irreversible actions | No |
263
+ | `ep_submit_receipt` | Record a behavioral outcome to the EP ledger | Yes |
264
+ | `ep_batch_submit` | Submit up to 50 receipts atomically | Yes |
265
+ | `ep_domain_score` | Per-domain trust scores (financial, code, comms, etc.) | No |
266
+ | `ep_search_entities` | Find entities by name, type, or capability | No |
267
+ | `ep_register_entity` | Register a new entity — returns first API key | No |
268
+ | `ep_leaderboard` | Top entities ranked by trust confidence | No |
269
+ | `ep_verify_receipt` | Verify a receipt against its Merkle proof | No |
270
+ | `ep_install_preflight` | Software pre-action enforcement before installing plugins/packages (experimental) | No |
271
+ | `ep_dispute_file` | Challenge an inaccurate or fraudulent receipt | Yes |
272
+ | `ep_dispute_status` | Check the status of a dispute | No |
273
+ | `ep_appeal_dispute` | Appeal a dispute resolution | Yes |
274
+ | `ep_report_trust_issue` | Human-accessible trust report (no auth required) | No |
275
+ | `ep_create_delegation` | Authorize an agent to act on a principal's behalf | Yes |
276
+ | `ep_verify_delegation` | Check that a delegation is valid for a specific action | No |
277
+ | `ep_principal_lookup` | Look up the enduring principal behind entities | No |
278
+ | `ep_lineage` | Entity lineage, predecessors, continuity, whitewashing flags | No |
279
+ | `ep_delegation_judgment` | Score a principal's track record of choosing and overseeing agents | No |
280
+ | `ep_configure_auto_receipt` | Configure automatic receipt generation from MCP tool call events (opt-in) | Yes |
281
+ | `ep_generate_zk_proof` | Generate a commitment proof for a score claim | No |
282
+ | `ep_verify_zk_proof` | Verify a commitment proof | No |
283
+ | `ep_list_policies` | List all available trust policies | No |
284
+ | `ep_issue_commit` | Issue a signed EP Commit before a high-stakes action | Yes |
285
+ | `ep_verify_commit` | Verify a commit's signature, status, and validity | No |
286
+ | `ep_get_commit_status` | Get current state of a commit | Yes |
287
+ | `ep_revoke_commit` | Revoke an active commit | Yes |
288
+ | `ep_bind_receipt_to_commit` | Bind a post-action receipt to a commit | Yes |
289
+ | `ep_initiate_handshake` | Initiate a structured identity exchange between parties | Yes |
290
+ | `ep_add_presentation` | Add an identity presentation (proof) to a handshake | Yes |
291
+ | `ep_verify_handshake` | Evaluate handshake presentations against policy | Yes |
292
+ | `ep_get_handshake` | Get full handshake state | Yes |
293
+ | `ep_revoke_handshake` | Revoke an active handshake | Yes |
294
+
295
+ ---
296
+
297
+ ### ep_trust_profile
298
+
299
+ Get an entity's full trust profile. This is the canonical read surface in EP — use it before transacting with any counterparty or installing any software.
300
+
301
+ **Parameters:**
302
+
303
+ | Parameter | Type | Required | Description |
304
+ |-----------|------|:--------:|-------------|
305
+ | `entity_id` | string | Yes | Entity slug (e.g. `acme-logistics`) or UUID |
306
+
307
+ **Example:**
308
+ ```
309
+ ep_trust_profile(entity_id="stripe-payments")
310
+ ```
311
+
312
+ **Returns:** Confidence level, behavioral rates (completion/retry/abandon/dispute), signal scores (delivery/product/price/returns), provenance composition, consistency score, dispute summary, and anomaly alerts. The compatibility score field exists for legacy sorting use cases — use the trust profile for decisions.
313
+
314
+ ---
315
+
316
+ ### ep_trust_evaluate
317
+
318
+ Evaluate an entity against a named trust policy. Returns a Trust Decision (allow/review/deny) with specific failure reasons — designed to be consumed programmatically by routing logic.
319
+
320
+ **Parameters:**
321
+
322
+ | Parameter | Type | Required | Description |
323
+ |-----------|------|:--------:|-------------|
324
+ | `entity_id` | string | Yes | Entity to evaluate |
325
+ | `policy` | string | No | `strict`, `standard`, `permissive`, `discovery` (default: `standard`) |
326
+ | `context` | object | No | Context key: `{ task_type, category, geo, modality, value_band }` |
327
+
328
+ **Example:**
329
+ ```
330
+ ep_trust_evaluate(
331
+ entity_id="acme-logistics",
332
+ policy="strict",
333
+ context={"value_band": "high", "category": "freight"}
334
+ )
335
+ ```
336
+
337
+ **Response:**
338
+ ```
339
+ Trust Evaluation: Acme Logistics (acme-logistics)
340
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
341
+ Policy: strict
342
+ Decision: ✗ DENY
343
+ Confidence: provisional
344
+ Context: {"value_band": "high", "category": "freight"}
345
+
346
+ Reasons:
347
+ ✗ Insufficient evidence for strict policy (need: high, have: moderate)
348
+ ✗ Dispute rate 1.2% exceeds strict ceiling of 0.5%
349
+ ```
350
+
351
+ ---
352
+
353
+ ### ep_trust_gate
354
+
355
+ The canonical pre-action check. Call this before payments, installs, sending messages on behalf of users, or any irreversible action. Combines trust evaluation with optional delegation verification in a single call.
356
+
357
+ **Parameters:**
358
+
359
+ | Parameter | Type | Required | Description |
360
+ |-----------|------|:--------:|-------------|
361
+ | `entity_id` | string | Yes | Entity requesting to perform the action |
362
+ | `action` | string | Yes | Action being requested (e.g. `process_payment`, `send_email`, `install_package`) |
363
+ | `policy` | string | No | Policy to enforce (default: `standard`) |
364
+ | `value_usd` | number | No | Transaction value for risk calibration |
365
+ | `delegation_id` | string | No | If agent is acting on behalf of a human, the delegation ID |
366
+
367
+ **Example:**
368
+ ```
369
+ ep_trust_gate(
370
+ entity_id="payment-processor-x",
371
+ action="process_payment",
372
+ policy="strict",
373
+ value_usd=12500
374
+ )
375
+ ```
376
+
377
+ **Response:**
378
+ ```
379
+ Trust Gate: process_payment
380
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
381
+ Entity: payment-processor-x
382
+ Decision: ✓ ALLOW
383
+ Policy: strict
384
+ Confidence: confident
385
+
386
+ Reasons:
387
+ ✓ Confidence meets strict threshold
388
+ ✓ Completion rate 98% exceeds strict floor
389
+ ✓ Dispute rate 0.3% below strict ceiling
390
+ ```
391
+
392
+ When a gate blocks, the response includes an `appeal_path` — because trust must never be more powerful than appeal.
393
+
394
+ ---
395
+
396
+ ### ep_submit_receipt
397
+
398
+ Submit a transaction receipt to the EP ledger. Receipts are append-only, cryptographically hashed, and chain-linked. `agent_behavior` is the strongest behavioral signal and should always be set.
399
+
400
+ **Parameters:**
401
+
402
+ | Parameter | Type | Required | Description |
403
+ |-----------|------|:--------:|-------------|
404
+ | `entity_id` | string | Yes | Entity the receipt describes |
405
+ | `transaction_ref` | string | Yes | Your external transaction reference |
406
+ | `transaction_type` | string | Yes | `purchase`, `service`, `task_completion`, `delivery`, `return` |
407
+ | `agent_behavior` | string | No | `completed`, `retried_same`, `retried_different`, `abandoned`, `disputed` |
408
+ | `delivery_accuracy` | number | No | 0–100 |
409
+ | `product_accuracy` | number | No | 0–100 |
410
+ | `price_integrity` | number | No | 0–100 |
411
+ | `return_processing` | number | No | 0–100 |
412
+ | `claims` | object | No | `{ delivered, on_time, price_honored, as_described }` |
413
+ | `evidence` | object | No | Supporting evidence references |
414
+ | `context` | object | No | `{ task_type, category, geo, modality, value_band, risk_class }` |
415
+
416
+ **Example:**
417
+ ```
418
+ ep_submit_receipt(
419
+ entity_id="saas-vendor-y",
420
+ transaction_ref="INV-2024-08871",
421
+ transaction_type="service",
422
+ agent_behavior="completed",
423
+ delivery_accuracy=95,
424
+ price_integrity=100,
425
+ claims={"delivered": true, "price_honored": true}
426
+ )
427
+ ```
428
+
429
+ ---
430
+
431
+ ### ep_batch_submit
432
+
433
+ Submit up to 50 receipts atomically. All receipts share the same API key as submitter. Returns per-receipt success or failure without aborting the batch — useful for bulk reconciliation or recording a full session of agent-entity interactions.
434
+
435
+ **Parameters:**
436
+
437
+ | Parameter | Type | Required | Description |
438
+ |-----------|------|:--------:|-------------|
439
+ | `receipts` | array | Yes | Array of receipt objects (same schema as `ep_submit_receipt`, max 50) |
440
+
441
+ **Example:**
442
+ ```
443
+ ep_batch_submit(receipts=[
444
+ {
445
+ "entity_id": "vendor-a",
446
+ "transaction_ref": "TXN-001",
447
+ "transaction_type": "service",
448
+ "agent_behavior": "completed"
449
+ },
450
+ {
451
+ "entity_id": "vendor-b",
452
+ "transaction_ref": "TXN-002",
453
+ "transaction_type": "purchase",
454
+ "agent_behavior": "abandoned"
59
455
  }
60
- }
456
+ ])
457
+ ```
458
+
459
+ **Response:**
460
+ ```
461
+ Batch submission: 1 succeeded, 1 failed
462
+ ✓ vendor-a — ep_rcpt_f4a2b1c9
463
+ ✗ vendor-b — Entity not found
464
+ ```
465
+
466
+ ---
467
+
468
+ ### ep_domain_score
469
+
470
+ Trust is not a scalar. An agent excellent at financial transactions may be unreliable at creative tasks. `ep_domain_score` returns per-domain confidence and behavioral rates so you can make task-appropriate trust decisions.
471
+
472
+ **Domains:** `financial`, `code_execution`, `communication`, `delegation`, `infrastructure`, `content_creation`, `data_access`
473
+
474
+ **Parameters:**
475
+
476
+ | Parameter | Type | Required | Description |
477
+ |-----------|------|:--------:|-------------|
478
+ | `entity_id` | string | Yes | Entity to query |
479
+ | `domains` | array | No | Specific domains to query (omit for all) |
480
+
481
+ **Example:**
482
+ ```
483
+ ep_domain_score(entity_id="dev-agent-42", domains=["code_execution", "data_access"])
484
+ ```
485
+
486
+ **Response:**
487
+ ```
488
+ Domain Scores: dev-agent-42
489
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
490
+
491
+ code_execution:
492
+ Confidence: confident
493
+ Evidence: 38 receipts
494
+ Completion: 97%
495
+ Dispute rate: 0.8%
496
+
497
+ data_access:
498
+ Confidence: provisional
499
+ Evidence: 6 receipts
500
+ Completion: 83%
501
+ Dispute rate: 5.1%
502
+ ```
503
+
504
+ ---
505
+
506
+ ### ep_search_entities
507
+
508
+ Search for entities by name, capability, or category.
509
+
510
+ **Parameters:**
511
+
512
+ | Parameter | Type | Required | Description |
513
+ |-----------|------|:--------:|-------------|
514
+ | `query` | string | Yes | Search query |
515
+ | `entity_type` | string | No | Filter by type (see entity types below) |
516
+
517
+ **Entity types:** `agent`, `merchant`, `service_provider`, `github_app`, `github_action`, `mcp_server`, `npm_package`, `chrome_extension`, `shopify_app`, `marketplace_plugin`, `agent_tool`
518
+
519
+ **Example:**
520
+ ```
521
+ ep_search_entities(query="freight logistics", entity_type="service_provider")
522
+ ```
523
+
524
+ ---
525
+
526
+ ### ep_register_entity
527
+
528
+ Register a new entity on EP. This is a public operation — no API key required. Returns the first API key immediately. Save it: it is shown only once.
529
+
530
+ **Parameters:**
531
+
532
+ | Parameter | Type | Required | Description |
533
+ |-----------|------|:--------:|-------------|
534
+ | `entity_id` | string | Yes | Slug: lowercase, hyphens only (e.g. `my-agent-v2`) |
535
+ | `display_name` | string | Yes | Human-readable name |
536
+ | `entity_type` | string | Yes | One of the entity types listed above |
537
+ | `description` | string | Yes | What this entity does |
538
+ | `capabilities` | array | No | List of capability strings |
539
+
540
+ **Example:**
61
541
  ```
542
+ ep_register_entity(
543
+ entity_id="my-scheduling-agent",
544
+ display_name="My Scheduling Agent",
545
+ entity_type="agent",
546
+ description="Books meetings and sends calendar invites on behalf of users.",
547
+ capabilities=["book_meeting", "send_invite", "check_availability"]
548
+ )
549
+ ```
550
+
551
+ **Response:**
552
+ ```
553
+ Registered: my-scheduling-agent
554
+ API Key: ep_live_xxxxxxxxxxxxxxxxxxxxxxxx
555
+ ⚠ Save this key — it won't be shown again.
556
+ ```
557
+
558
+ ---
559
+
560
+ ### ep_leaderboard
561
+
562
+ Get entities ranked by trust confidence, optionally filtered by type.
563
+
564
+ **Parameters:**
565
+
566
+ | Parameter | Type | Required | Description |
567
+ |-----------|------|:--------:|-------------|
568
+ | `limit` | number | No | Max results (default: 10, max: 50) |
569
+ | `entity_type` | string | No | Filter by entity type |
570
+
571
+ **Example:**
572
+ ```
573
+ ep_leaderboard(entity_type="mcp_server", limit=5)
574
+ ```
575
+
576
+ ---
577
+
578
+ ### ep_verify_receipt
579
+
580
+ Verify a receipt's integrity against its Merkle proof. Use when you need cryptographic assurance that a receipt has not been tampered with after submission.
581
+
582
+ **Parameters:**
583
+
584
+ | Parameter | Type | Required | Description |
585
+ |-----------|------|:--------:|-------------|
586
+ | `receipt_id` | string | Yes | Receipt ID (`ep_rcpt_...`) |
587
+
588
+ **Example:**
589
+ ```
590
+ ep_verify_receipt(receipt_id="ep_rcpt_a8f3c2d1e9b4")
591
+ ```
592
+
593
+ **Response:**
594
+ ```
595
+ Receipt: ep_rcpt_a8f3c2d1e9b4
596
+ Hash: sha256:7f3a9c1b2e8d4f6a...
597
+ Anchored: Yes
598
+ Verified: YES
599
+ ```
600
+
601
+ ---
602
+
603
+ ### ep_install_preflight
604
+
605
+ EP-SX: Should I install this plugin, app, package, or extension? Evaluates a software entity against a context-aware policy covering publisher verification, permission class, provenance, and behavioral history. Returns `allow`, `review`, or `deny` with specific reasons.
606
+
607
+ **Parameters:**
608
+
609
+ | Parameter | Type | Required | Description |
610
+ |-----------|------|:--------:|-------------|
611
+ | `entity_id` | string | Yes | Software entity ID (e.g. `github_app:acme/code-helper`, `npm:left-pad`) |
612
+ | `policy` | string | No | Software-specific or standard policy (see trust policies section) |
613
+ | `context` | object | No | `{ host, install_scope, permission_class, data_sensitivity, execution_mode }` |
614
+
615
+ **Software policies:** `github_private_repo_safe_v1`, `npm_buildtime_safe_v1`, `browser_extension_safe_v1`, `mcp_server_safe_v1`
616
+
617
+ **Example:**
618
+ ```
619
+ ep_install_preflight(
620
+ entity_id="mcp_server:some-org/data-extractor",
621
+ policy="mcp_server_safe_v1",
622
+ context={
623
+ "host": "mcp",
624
+ "data_sensitivity": "private_workspace",
625
+ "execution_mode": "persistent"
626
+ }
627
+ )
628
+ ```
629
+
630
+ ---
631
+
632
+ ### ep_dispute_file
633
+
634
+ Challenge an inaccurate or fraudulent receipt. Any affected party can file. The submitter has 7 days to respond. The receipt remains on the ledger — nothing is deleted — but trust is suspended pending resolution.
635
+
636
+ **Parameters:**
637
+
638
+ | Parameter | Type | Required | Description |
639
+ |-----------|------|:--------:|-------------|
640
+ | `receipt_id` | string | Yes | Receipt to dispute (`ep_rcpt_...`) |
641
+ | `reason` | string | Yes | `fraudulent_receipt`, `inaccurate_signals`, `identity_dispute`, `context_mismatch`, `duplicate_transaction`, `coerced_receipt`, `other` |
642
+ | `description` | string | No | Explanation of the dispute |
643
+ | `evidence` | object | No | Supporting evidence |
644
+
645
+ **Example:**
646
+ ```
647
+ ep_dispute_file(
648
+ receipt_id="ep_rcpt_a8f3c2d1e9b4",
649
+ reason="inaccurate_signals",
650
+ description="Agent behavior recorded as 'completed' but order was abandoned after 72 hours. No communication received.",
651
+ evidence={"support_ticket_url": "https://...", "order_status": "abandoned"}
652
+ )
653
+ ```
654
+
655
+ ---
656
+
657
+ ### ep_dispute_status
658
+
659
+ Check the status of a dispute. Public — transparency is a protocol value.
660
+
661
+ **Parameters:**
662
+
663
+ | Parameter | Type | Required | Description |
664
+ |-----------|------|:--------:|-------------|
665
+ | `dispute_id` | string | Yes | Dispute ID (`ep_disp_...`) |
666
+
667
+ **Example:**
668
+ ```
669
+ ep_dispute_status(dispute_id="ep_disp_3f7a1c9b")
670
+ ```
671
+
672
+ ---
673
+
674
+ ### ep_appeal_dispute
675
+
676
+ Appeal a dispute resolution. Only dispute participants can appeal. The dispute must be in `upheld`, `reversed`, or `dismissed` state. The protocol guarantees this path exists — trust must never be more powerful than appeal.
677
+
678
+ **Parameters:**
679
+
680
+ | Parameter | Type | Required | Description |
681
+ |-----------|------|:--------:|-------------|
682
+ | `dispute_id` | string | Yes | Dispute to appeal (`ep_disp_...`) |
683
+ | `reason` | string | Yes | Why the resolution should be reconsidered (minimum 10 characters) |
684
+ | `evidence` | object | No | Additional supporting evidence |
685
+
686
+ **Example:**
687
+ ```
688
+ ep_appeal_dispute(
689
+ dispute_id="ep_disp_3f7a1c9b",
690
+ reason="Resolution relied on incomplete evidence. I now have courier tracking data confirming non-delivery.",
691
+ evidence={"tracking_data": "https://...", "courier_confirmation": "CNF-4821"}
692
+ )
693
+ ```
694
+
695
+ ---
696
+
697
+ ### ep_report_trust_issue
698
+
699
+ File a human trust report. No authentication required. Use when someone has been wrongly downgraded, harmed by a trusted entity, or witnesses fraud. EP must never make trust more powerful than appeal — this tool is the human escape hatch.
700
+
701
+ **Parameters:**
702
+
703
+ | Parameter | Type | Required | Description |
704
+ |-----------|------|:--------:|-------------|
705
+ | `entity_id` | string | Yes | Entity the report concerns |
706
+ | `report_type` | string | Yes | `wrongly_downgraded`, `harmed_by_trusted_entity`, `fraudulent_entity`, `inaccurate_profile`, `other` |
707
+ | `description` | string | Yes | What happened |
708
+ | `contact_email` | string | No | Email for follow-up |
709
+
710
+ **Example:**
711
+ ```
712
+ ep_report_trust_issue(
713
+ entity_id="some-merchant",
714
+ report_type="harmed_by_trusted_entity",
715
+ description="Entity shows high trust but charged my card without authorization.",
716
+ contact_email="user@example.com"
717
+ )
718
+ ```
719
+
720
+ ---
721
+
722
+ ### ep_create_delegation
723
+
724
+ Record that a principal (human or organization) authorizes an agent to act on their behalf. The delegation is stored in the EP ledger with an explicit scope, expiry, and optional constraints. Every delegated action can reference this ID to prove authorization.
725
+
726
+ **Parameters:**
727
+
728
+ | Parameter | Type | Required | Description |
729
+ |-----------|------|:--------:|-------------|
730
+ | `principal_id` | string | Yes | The principal granting authorization (`ep_principal_...`) |
731
+ | `agent_entity_id` | string | Yes | The agent entity being authorized |
732
+ | `scope` | array | Yes | Permitted action types (e.g. `["purchase", "book_meeting", "send_email"]`) |
733
+ | `max_value_usd` | number | No | Maximum transaction value this delegation authorizes |
734
+ | `expires_at` | string | No | ISO 8601 expiry (default: 24 hours from creation) |
735
+ | `constraints` | object | No | Additional constraints: `{ geo, merchant_category, ... }` |
736
+
737
+ **Example:**
738
+ ```
739
+ ep_create_delegation(
740
+ principal_id="ep_principal_usr_abc123",
741
+ agent_entity_id="travel-agent-v2",
742
+ scope=["book_flight", "book_hotel", "purchase"],
743
+ max_value_usd=2000,
744
+ expires_at="2024-12-20T00:00:00Z",
745
+ constraints={"merchant_category": ["airline", "hotel"]}
746
+ )
747
+ ```
748
+
749
+ ---
750
+
751
+ ### ep_verify_delegation
752
+
753
+ Verify that an agent holds a currently valid delegation for a specific action. Call this before accepting a task from an agent claiming to act on behalf of a human.
754
+
755
+ **Parameters:**
756
+
757
+ | Parameter | Type | Required | Description |
758
+ |-----------|------|:--------:|-------------|
759
+ | `delegation_id` | string | Yes | Delegation to verify (`ep_dlg_...`) |
760
+ | `action_type` | string | No | Specific action to check against the delegation scope |
761
+
762
+ **Example:**
763
+ ```
764
+ ep_verify_delegation(
765
+ delegation_id="ep_dlg_x7y2z9w1",
766
+ action_type="book_flight"
767
+ )
768
+ ```
769
+
770
+ **Response:**
771
+ ```
772
+ Delegation: ep_dlg_x7y2z9w1
773
+ Status: ✓ VALID
774
+ Principal: ep_principal_usr_abc123
775
+ Agent: travel-agent-v2
776
+ Scope: book_flight, book_hotel, purchase
777
+ Expires: 2024-12-20T00:00:00Z
778
+ Action "book_flight": ✓ Permitted
779
+ ```
780
+
781
+ ---
782
+
783
+ ### ep_principal_lookup
784
+
785
+ Look up a principal — the enduring actor behind one or more entities. Returns identity bindings, controlled entities, and continuity history. A principal persists across entity re-registrations, making whitewashing detectable.
786
+
787
+ **Parameters:**
788
+
789
+ | Parameter | Type | Required | Description |
790
+ |-----------|------|:--------:|-------------|
791
+ | `principal_id` | string | Yes | Principal ID (`ep_principal_...`) |
792
+
793
+ **Example:**
794
+ ```
795
+ ep_principal_lookup(principal_id="ep_principal_usr_abc123")
796
+ ```
797
+
798
+ ---
799
+
800
+ ### ep_lineage
801
+
802
+ View an entity's lineage: predecessors, successors, and continuity decisions. Use this to detect whitewashing — where an entity attempts to shed a bad trust history by re-registering under a new ID.
803
+
804
+ **Parameters:**
805
+
806
+ | Parameter | Type | Required | Description |
807
+ |-----------|------|:--------:|-------------|
808
+ | `entity_id` | string | Yes | Entity to check lineage for |
809
+
810
+ **Example:**
811
+ ```
812
+ ep_lineage(entity_id="new-vendor-rebranded")
813
+ ```
814
+
815
+ **Response:**
816
+ ```
817
+ Lineage: new-vendor-rebranded
818
+
819
+ Predecessors:
820
+ <- old-vendor-ltd (rebranding) [approved] transfer: partial
821
+
822
+ No successors.
823
+ ```
824
+
825
+ ---
826
+
827
+ ### ep_delegation_judgment
828
+
829
+ Score a principal's track record of choosing and overseeing agents. This is the inverse of `ep_trust_profile` — instead of asking "can I trust this agent?", it asks "can I trust the human who authorized it?" A principal with poor delegation authority has a history of authorizing misbehaving agents, even if those individual agents no longer appear active.
830
+
831
+ **Parameters:**
832
+
833
+ | Parameter | Type | Required | Description |
834
+ |-----------|------|:--------:|-------------|
835
+ | `principal_id` | string | Yes | Principal ID (`ep_principal_...`) |
836
+
837
+ **Example:**
838
+ ```
839
+ ep_delegation_judgment(principal_id="ep_principal_usr_abc123")
840
+ ```
841
+
842
+ **Response:**
843
+ ```
844
+ Delegation Judgment: ep_principal_usr_abc123
845
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
846
+ Score: 0.94 (excellent)
847
+ Agents authorized: 6
848
+ Active agents: 2
849
+ Good outcome rate: 94%
850
+ Avg agent confidence: 0.82
851
+
852
+ Interpretation:
853
+ Consistently authorizes high-confidence agents with excellent outcomes (47 receipts, 94% positive).
854
+
855
+ Recent signals:
856
+ ✓ travel-agent-v2 — positive
857
+ ✓ data-fetcher-x — positive
858
+ ✗ old-scheduler — negative
859
+ ...
860
+ ```
861
+
862
+ **Grade thresholds:**
863
+
864
+ | Grade | Score range |
865
+ |-------|-------------|
866
+ | `excellent` | 0.85 – 1.0 |
867
+ | `good` | 0.70 – 0.84 |
868
+ | `fair` | 0.50 – 0.69 |
869
+ | `poor` | < 0.50 |
870
+
871
+ Delegation judgment scores are computed from `principal_delegation_signals` — lightweight attribution rows written each time a delegated agent's receipt is processed. The score is the weighted fraction of those signals that recorded a positive outcome. A principal with no delegation history returns `judgmentScore: null` and `grade: null`.
872
+
873
+ ---
874
+
875
+ ### ep_list_policies
876
+
877
+ List all available trust policies with their requirements, families, and minimum confidence thresholds.
878
+
879
+ **Parameters:** None
880
+
881
+ **Example:**
882
+ ```
883
+ ep_list_policies()
884
+ ```
885
+
886
+ Use the returned policy names with `ep_trust_evaluate`, `ep_trust_gate`, and `ep_install_preflight`.
887
+
888
+ ---
889
+
890
+ ## MCP Resources
891
+
892
+ In addition to tools, the server exposes four URI-addressable resources that can be read directly by MCP clients that support resource access.
893
+
894
+ | URI | Description |
895
+ |-----|-------------|
896
+ | `entity://acme-logistics` | Full trust profile JSON — identical to `ep_trust_profile` |
897
+ | `score://acme-logistics` | Condensed confidence snapshot: entity_id, confidence, evidence, established |
898
+ | `receipt://ep_rcpt_abc123` | Receipt with hash, provenance, and verification status |
899
+ | `delegation://ep_dlg_xyz789` | Delegation details: principal, agent, scope, expiry, status |
900
+
901
+ Resources are useful when you want to pass a trust profile into a prompt context directly rather than calling a tool. In Claude, you can attach them as context documents before making a routing decision.
902
+
903
+ ---
904
+
905
+ ## MCP Prompts
906
+
907
+ Three structured prompts orchestrate multi-step trust workflows. Invoke them from any MCP client that supports prompts.
908
+
909
+ ### `trust_decision`
910
+
911
+ Orchestrates a full trust evaluation workflow. Instructs the model to call `ep_trust_gate`, retrieve the full trust profile, and synthesize a clear ALLOW, REVIEW, or DENY recommendation with the key behavioral signals that drove the decision — plus what the entity would need to do to qualify if denied.
912
+
913
+ **Arguments:** `entity_id` (required), `action` (required), `value_usd` (optional)
914
+
915
+ ---
916
+
917
+ ### `receipt_quality_check`
918
+
919
+ Guides accurate receipt submission. Checks the entity's current trust state first, then walks through each signal field interactively before submitting. Warns when signals appear inconsistent with the declared `agent_behavior` — for example, `delivery_accuracy=95` paired with `agent_behavior=abandoned`.
920
+
921
+ **Arguments:** `entity_id` (required), `transaction_ref` (required)
922
+
923
+ ---
924
+
925
+ ### `install_decision`
926
+
927
+ Full software trust review before installing any plugin, package, or extension. Calls `ep_install_preflight`, checks lineage for suspicious continuity gaps, retrieves the full trust profile, and produces a clear INSTALL / REVIEW / DENY recommendation. If not INSTALL, lists specific questions to investigate before proceeding.
928
+
929
+ **Arguments:** `entity_id` (required), `install_context` (optional, e.g. `private_repo`, `production_server`)
930
+
931
+ ---
932
+
933
+ ## Trust Policies
934
+
935
+ EP ships four built-in behavioral policies. Software-specific policies apply the same framework with domain-appropriate thresholds.
936
+
937
+ ### Built-in Policies
938
+
939
+ | Policy | Use Case | Min Evidence | Max Dispute Rate |
940
+ |--------|----------|:------------:|:----------------:|
941
+ | `strict` | High-value transactions, critical infrastructure | high | 2% |
942
+ | `standard` | Normal operations, typical counterparties | moderate | 5% |
943
+ | `permissive` | Low-risk discovery, early relationships | low | 15% |
944
+ | `discovery` | Allow unevaluated entities for exploration | none | any |
945
+
946
+ ### Software-Specific Policies
947
+
948
+ | Policy | Target |
949
+ |--------|--------|
950
+ | `github_private_repo_safe_v1` | GitHub Apps installed in private repositories |
951
+ | `npm_buildtime_safe_v1` | npm packages running in build pipelines |
952
+ | `browser_extension_safe_v1` | Browser extensions with broad page access |
953
+ | `mcp_server_safe_v1` | MCP servers connecting to agent workspaces |
954
+
955
+ Use `ep_list_policies` to see the full set of currently available policies.
956
+
957
+ ---
958
+
959
+ ## Environment Variables
960
+
961
+ | Variable | Description | Required |
962
+ |----------|-------------|:--------:|
963
+ | `EP_API_KEY` | Your API key (`ep_live_...`). Required for write operations: submitting receipts, filing disputes, creating delegations, filing appeals. | For writes |
964
+ | `EP_BASE_URL` | API endpoint. Defaults to `https://emiliaprotocol.ai` | No |
965
+
966
+ Read-only operations — trust profiles, policy evaluation, trust gates, pre-action enforcement, search, leaderboard, dispute status, lineage — work without an API key.
967
+
968
+ ---
969
+
970
+ ## Get an API Key
971
+
972
+ Registration is public and takes one tool call. No account creation, no email verification, no dashboard:
973
+
974
+ ```
975
+ ep_register_entity(
976
+ entity_id="your-agent-or-service",
977
+ display_name="Your Agent or Service",
978
+ entity_type="agent",
979
+ description="What your entity does"
980
+ )
981
+ ```
982
+
983
+ The response includes your first API key (`ep_live_...`). Save it immediately — EP does not store it in recoverable form. Add it to your MCP server config as `EP_API_KEY` and you have full read/write access.
984
+
985
+ ---
986
+
987
+ ## Philosophy
988
+
989
+ Trust must never be more powerful than appeal. Every negative trust effect in EP — a downgraded confidence level, a blocked gate, a disputed receipt — must be explainable, challengeable, and reversible. This is why `ep_report_trust_issue` requires no authentication: a person harmed by a trust system should not need credentials to report the harm. It is why blocked trust gates include an `appeal_path`. It is why receipts are never deleted, only disputed — because erasing a record is not the same as correcting it.
990
+
991
+ This is not a product. It is infrastructure — the same way TCP/IP is not a product but a protocol that products run on. EP is open source (Apache-2.0) and designed to be a neutral standard: no lock-in, no platform dependency, no private moat. Agents, merchants, service providers, and software components should be able to build and maintain trust reputations that are portable, verifiable, and not owned by any single platform. The MCP server is the first interface layer. The protocol is the point.
992
+
993
+ ---
62
994
 
63
- ## License
995
+ ## Links
64
996
 
65
- Apache-2.0
997
+ - Homepage: [emiliaprotocol.ai](https://emiliaprotocol.ai)
998
+ - GitHub: [github.com/emiliaprotocol/emilia-protocol](https://github.com/emiliaprotocol/emilia-protocol)
999
+ - npm: [@emilia-protocol/mcp-server](https://www.npmjs.com/package/@emilia-protocol/mcp-server)
1000
+ - License: Apache-2.0