@arcpaylabs/somnia-mcp 0.1.0

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 ADDED
@@ -0,0 +1,48 @@
1
+ # ArcPay Somnia MCP
2
+
3
+ Local MCP server for ArcPay Somnia. It exposes safe developer tools for Somnia Testnet deployments, x402 payment gates, invoice IDs, claim hashes, privacy commitments, and repeatable demo paths.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g @arcpaylabs/somnia-mcp
9
+ ```
10
+
11
+ ## Claude Desktop
12
+
13
+ Add this to your Claude Desktop MCP config:
14
+
15
+ ```json
16
+ {
17
+ "mcpServers": {
18
+ "arcpay-somnia": {
19
+ "command": "arcpay-somnia-mcp"
20
+ }
21
+ }
22
+ }
23
+ ```
24
+
25
+ Restart Claude Desktop after editing the config.
26
+
27
+ ## Tools
28
+
29
+ - `get_deployment`
30
+ - `derive_agent_id`
31
+ - `derive_invoice_id`
32
+ - `derive_claim_hash`
33
+ - `derive_privacy_commitment`
34
+ - `privacy_intent_guide`
35
+ - `invoice_guide`
36
+ - `x402_guide`
37
+ - `demo_path`
38
+ - `smoke_commands`
39
+
40
+ ## Hosted Surfaces
41
+
42
+ - App: https://arcpay-somnia.vercel.app
43
+ - Docs: https://arcpay-somnia.vercel.app/docs/overview
44
+ - OpenAPI: https://arcpay-somnia.vercel.app/openapi.json
45
+ - llms.txt: https://arcpay-somnia.vercel.app/llms.txt
46
+ - x402: https://x402.20.208.46.195.nip.io
47
+
48
+ The MCP server does not sign transactions or mutate treasury state. It only returns deterministic IDs, integration guidance, and public deployment metadata.
@@ -0,0 +1,22 @@
1
+ {
2
+ "network": "somnia-testnet",
3
+ "chainId": 50312,
4
+ "deployer": "0xB883e76A4f6841E72cAF1C28ba00f78df974f448",
5
+ "deployedAt": "2026-05-23T07:20:15.023Z",
6
+ "contracts": {
7
+ "AgentRegistry": "0x350F8f29a5A10eE4d85642CE3AB72497982ee09D",
8
+ "TreasuryPolicy": "0x4c0f962e6555399f45C628DC7F77d4cC6171BB2A",
9
+ "AgentTreasury": "0x9dB9477D068A58154A54d10D1E5711A9E1fD9EA0",
10
+ "AgentOrderBook": "0x6A07886d465Bd64ED3264F4e824C1dF2884a7B45",
11
+ "OperatorControls": "0xb7b26AD2cCBf6613A43f2Db4a550eDF1D7dB8b32",
12
+ "SomniaAgentRiskOracle": "0xA5Ec905B95E5b166EF846849eaB8FDD1dB134D0C",
13
+ "AgentSpendCardVault": "0x0480E467bA12E33DA163FeA45a20C30133F84B93",
14
+ "SomniaPrivacyVault": "0x6948a15dED7F6708BD4DfD8c3Ee5314bC5B53D14",
15
+ "AgentInvoiceBook": "0x643De19f32B1d0c396Cf8B5cD677549c442Fbbf7",
16
+ "AgentReputationBook": "0xBB9aB7d9e2ad5205F390580119b139bce84C8096"
17
+ },
18
+ "somniaAgentPlatform": "0x037Bb9C718F3f7fe5eCBDB0b600D607b52706776",
19
+ "somniaRiskAgentId": "13174292974160097713",
20
+ "somUsdToken": "0x02b8316775057e2096471473663d51ceafbe3e3b",
21
+ "updatedAt": "2026-05-27T15:08:18.032Z"
22
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@arcpaylabs/somnia-mcp",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "MCP server for ArcPay Somnia contracts, x402, privacy intents, invoices, and demo flows.",
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "author": "Henry Sammarfo <jasonneil4040@gmail.com>",
9
+ "homepage": "https://arcpay-somnia.vercel.app/docs/mcp",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/ArcPayLabs/arcpay-somnia.git",
13
+ "directory": "apps/mcp"
14
+ },
15
+ "bin": {
16
+ "arcpay-somnia-mcp": "server.mjs"
17
+ },
18
+ "files": [
19
+ "README.md",
20
+ "server.mjs",
21
+ "deployment.json"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "scripts": {
27
+ "start": "node server.mjs",
28
+ "pack:dry": "npm pack --dry-run"
29
+ },
30
+ "dependencies": {
31
+ "@modelcontextprotocol/sdk": "^1.18.2",
32
+ "ethers": "^6.13.5",
33
+ "zod": "^3.25.76"
34
+ },
35
+ "overrides": {
36
+ "ws": "^8.20.1"
37
+ }
38
+ }
package/server.mjs ADDED
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env node
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
7
+ import { id, keccak256, toUtf8Bytes } from "ethers";
8
+ import { z } from "zod";
9
+
10
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
+ const root = path.resolve(__dirname, "../..");
12
+ const deploymentPath = path.join(root, "deployments", "somnia-testnet.json");
13
+ const packagedDeploymentPath = path.join(__dirname, "deployment.json");
14
+
15
+ function readDeployment() {
16
+ const file = fs.existsSync(deploymentPath) ? deploymentPath : packagedDeploymentPath;
17
+ return JSON.parse(fs.readFileSync(file, "utf8"));
18
+ }
19
+
20
+ const server = new McpServer({
21
+ name: "arcpay-somnia",
22
+ version: "0.1.0",
23
+ });
24
+
25
+ server.tool("get_deployment", "Return Somnia testnet contract addresses and network metadata.", {}, async () => ({
26
+ content: [{ type: "text", text: JSON.stringify(readDeployment(), null, 2) }],
27
+ }));
28
+
29
+ server.tool("derive_agent_id", "Derive the bytes32 agent id used by AgentRegistry.", {
30
+ slug: z.string().min(1),
31
+ }, async ({ slug }) => ({
32
+ content: [{ type: "text", text: id(slug) }],
33
+ }));
34
+
35
+ server.tool("derive_invoice_id", "Derive the bytes32 invoice id used by AgentInvoiceBook.", {
36
+ publicId: z.string().min(1),
37
+ }, async ({ publicId }) => ({
38
+ content: [{ type: "text", text: keccak256(toUtf8Bytes(publicId)) }],
39
+ }));
40
+
41
+ server.tool("derive_claim_hash", "Derive the on-chain claim-code hash for OperatorControls.", {
42
+ code: z.string().min(1),
43
+ }, async ({ code }) => ({
44
+ content: [{ type: "text", text: keccak256(toUtf8Bytes(code)) }],
45
+ }));
46
+
47
+ server.tool("derive_privacy_commitment", "Derive a Privacy Intent commitment or nullifier from secret text.", {
48
+ secret: z.string().min(1),
49
+ }, async ({ secret }) => ({
50
+ content: [{ type: "text", text: keccak256(toUtf8Bytes(secret)) }],
51
+ }));
52
+
53
+ server.tool("privacy_intent_guide", "Return builder instructions for integrating ArcPay Privacy Intents on Somnia.", {}, async () => {
54
+ const deployment = readDeployment();
55
+ return {
56
+ content: [{
57
+ type: "text",
58
+ text: [
59
+ "ArcPay Privacy Intents for Somnia",
60
+ `Vault: ${deployment.contracts.SomniaPrivacyVault}`,
61
+ `SOMUSD: ${deployment.somUsdToken}`,
62
+ "commitment = keccak256(secret)",
63
+ "nullifier = keccak256(releaseSecret)",
64
+ "SOMUSD flow: approve vault, then createTokenIntent(commitment, SOMUSD, amount, encryptedMemoUri).",
65
+ "STT flow: createNativeIntent(commitment, encryptedMemoUri) with msg.value.",
66
+ "Release: releaseIntent(commitment, nullifier, recipient).",
67
+ "Boundary: this hides metadata/recipient during intent phase, not a full shielded pool.",
68
+ ].join("\n"),
69
+ }],
70
+ };
71
+ });
72
+
73
+ server.tool("invoice_guide", "Return builder instructions for ArcPay STT/SOMUSD invoices on Somnia.", {}, async () => {
74
+ const deployment = readDeployment();
75
+ return {
76
+ content: [{
77
+ type: "text",
78
+ text: [
79
+ "ArcPay Somnia Invoices",
80
+ `InvoiceBook: ${deployment.contracts.AgentInvoiceBook}`,
81
+ `SOMUSD: ${deployment.somUsdToken}`,
82
+ "invoiceId = keccak256(publicInvoiceId)",
83
+ "Create STT invoice: createInvoice(invoiceId, payerOrZero, address(0), amountWei, metadataUri).",
84
+ "Create SOMUSD invoice: createInvoice(invoiceId, payerOrZero, SOMUSD, amountBaseUnits, metadataUri).",
85
+ "Pay STT: payNativeInvoice(invoiceId) with exact msg.value.",
86
+ "Pay SOMUSD: approve InvoiceBook, then payTokenInvoice(invoiceId).",
87
+ "Cancel unpaid: issuer calls cancelInvoice(invoiceId).",
88
+ "Proof: npm run smoke:live includes on-chain invoice settlement.",
89
+ ].join("\n"),
90
+ }],
91
+ };
92
+ });
93
+
94
+ server.tool("x402_guide", "Return builder instructions for the ArcPay Somnia x402 payment-gated agent server.", {}, async () => {
95
+ const deployment = readDeployment();
96
+ return {
97
+ content: [{
98
+ type: "text",
99
+ text: [
100
+ "ArcPay Somnia x402",
101
+ `OrderBook: ${deployment.contracts.AgentOrderBook}`,
102
+ `Registry: ${deployment.contracts.AgentRegistry}`,
103
+ "Run: npm run x402",
104
+ "Protected resource: GET /agent/:slug/work",
105
+ "No order returns HTTP 402 with exact STT payment requirements.",
106
+ "Pay by calling AgentOrderBook.createOrder(agentId, requestUri) with quoted msg.value.",
107
+ "Verify: POST /x402/verify with { orderId, agentSlug }.",
108
+ "Unlock: GET /agent/:slug/work?orderId=... after Fulfilled or Settled.",
109
+ "Proof: npm run smoke:x402.",
110
+ ].join("\n"),
111
+ }],
112
+ };
113
+ });
114
+
115
+ server.tool("demo_path", "Return the operator demo path for ArcPay Somnia.", {}, async () => ({
116
+ content: [{
117
+ type: "text",
118
+ text: [
119
+ "Connect an EVM wallet to Somnia Testnet.",
120
+ "Register an agent on /agents.",
121
+ "Set policy and allowlist the agent on /policies.",
122
+ "Create and settle an escrowed agent order on /orders.",
123
+ "Create/redeem claim codes and trigger webhook breaker on /operator.",
124
+ "Request and fulfill risk oracle result on /oracle.",
125
+ "Create and release encrypted Privacy Intents with nullifiers on /privacy.",
126
+ "Create, pay, cancel, and sync STT/SOMUSD invoices on /invoices.",
127
+ "Show /audit and /proofs.",
128
+ ].join("\n"),
129
+ }],
130
+ }));
131
+
132
+ server.tool("smoke_commands", "Return the verification commands operators can run locally and against Somnia testnet.", {}, async () => ({
133
+ content: [{
134
+ type: "text",
135
+ text: [
136
+ "npm run build:frontend",
137
+ "npm test",
138
+ "npm run check:worker",
139
+ "npm run check:x402",
140
+ "npm run smoke:auth",
141
+ "npm run smoke:live",
142
+ "npm run smoke:x402",
143
+ ].join("\n"),
144
+ }],
145
+ }));
146
+
147
+ const transport = new StdioServerTransport();
148
+ await server.connect(transport);