@solidus-network/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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Solidus Network
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing permissions
201
+ and limitations under the License.
package/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # @solidus-network/mcp
2
+
3
+ An [MCP](https://modelcontextprotocol.io) (Model Context Protocol) server that exposes Solidus as
4
+ **run-time tools an agent can call** — resolve a `did:solidus` DID, verify a credential, and
5
+ check/create/authorize a scoped spend mandate. Point any MCP-compatible client (Claude Code, Cursor,
6
+ Windsurf, or a custom agent loop) at it over stdio and those become ordinary tool calls.
7
+
8
+ ## Status — read this first
9
+
10
+ - **First release (0.1.0).** New package, testnet-grade.
11
+ - **Solidus L1 is testnet-only — there is no mainnet.** DIDs resolve as `did:solidus:testnet:<addr>`.
12
+ Treat anything you create through these tools (DIDs, credentials, mandates) as sandbox data, not a
13
+ durable production record.
14
+ - **Credential signing (BBS+) has no external security audit yet.** Do not protect production-grade
15
+ value with it.
16
+ - **`agent_pay` authorizes; it never settles.** Solidus is not a payment rail. The tool checks a
17
+ mandate and, if it's within scope, hands back a signed envelope for the caller to present to
18
+ *their own* rail (Moka, x402, whatever they already use). No money moves through this package or
19
+ through Solidus at any point.
20
+
21
+ ## Install / run
22
+
23
+ You don't install this globally — an MCP client launches it on demand:
24
+
25
+ ```bash
26
+ npx @solidus-network/mcp
27
+ ```
28
+
29
+ ### Claude Code (`.mcp.json`)
30
+
31
+ ```json
32
+ {
33
+ "mcpServers": {
34
+ "solidus": {
35
+ "command": "npx",
36
+ "args": ["-y", "@solidus-network/mcp"],
37
+ "env": {
38
+ "SOLIDUS_API_KEY": "<your operator key, only needed for create_mandate>"
39
+ }
40
+ }
41
+ }
42
+ }
43
+ ```
44
+
45
+ Any other MCP client (Cursor, Windsurf, a custom `StdioClientTransport`) works the same way — it's a
46
+ standard stdio MCP server, `command: npx`, `args: ["-y", "@solidus-network/mcp"]`.
47
+
48
+ ## Tools
49
+
50
+ 5 tools, 3 read (no side effects, no auth) and 2 write (side effects; a human should confirm the
51
+ terms before an agent calls them):
52
+
53
+ | Tool | Type | What it does |
54
+ |---|---|---|
55
+ | `resolve_did` | read | Resolve a `did:solidus` DID document from the Solidus chain. |
56
+ | `verify_credential` | read | Verify a Solidus verifiable credential by id against the chain. |
57
+ | `check_mandate` | read | Check whether a spend-mandate envelope authorizes a given amount/currency/rail. Pure — no auth, moves nothing. This is the counterparty refusal check. |
58
+ | `create_mandate` | write | Issue a scoped `spend_mandate` credential (bounded by `maxAmount`/`currency`/`rail`/`expiresAt`) for an agent, on behalf of a principal DID. Returns the checkable envelope — never the private key or credential bundle. |
59
+ | `agent_pay` | write | Authorize a payment under a mandate and return the envelope for the caller's own rail. **Settles nothing** — a refusal short-circuits and does no further work. |
60
+
61
+ ## Configuration
62
+
63
+ All optional except where noted; the server has working defaults for every read tool out of the box.
64
+
65
+ | Env var | Default | Used by |
66
+ |---|---|---|
67
+ | `SOLIDUS_RPC_URL` | `https://rpc.solidus.network` | `resolve_did`, `verify_credential` (chain SDK) |
68
+ | `SOLIDUS_AGENTS_URL` | `https://agents.solidus.network` | `check_mandate`, `create_mandate`, `agent_pay` (agents backend) |
69
+ | `SOLIDUS_API_KEY` | — | `create_mandate` only — an operator bearer token. The other four tools need no auth. |
70
+ | `SOLIDUS_SDK_MODE` | `testnet` | Chain SDK mode: `testnet` (public chain, no key needed for reads), `mainnet`, or `stub` (local Postgres-backed simulation for development — requires `SOLIDUS_STUB_DB_URL`, never point a real client at it). |
71
+
72
+ ## End-to-end example
73
+
74
+ A mandate bounds what an agent can spend; `check_mandate` is the refusal an agent's counterparty runs
75
+ before accepting a payment. This walks resolving a DID, hitting the refusal, then raising the mandate
76
+ and succeeding:
77
+
78
+ ```jsonc
79
+ // 1. Resolve the paying agent's DID
80
+ resolve_did({ "did": "did:solidus:testnet:<addr>" })
81
+ // → { "did": "did:solidus:testnet:<addr>", "document": { ... }, "resolved": true }
82
+
83
+ // 2. Issue a mandate capped at 500 TRY
84
+ create_mandate({
85
+ "agentId": "<agent-id>",
86
+ "principalDid": "did:solidus:testnet:<principal-addr>",
87
+ "maxAmount": "500",
88
+ "currency": "TRY",
89
+ "rail": "moka",
90
+ "expiresAt": "2026-08-01T00:00:00.000Z"
91
+ })
92
+ // → { "mandateId": "...", "envelope": "<base64url envelope>", "expiresAt": "2026-08-01T00:00:00.000Z" }
93
+
94
+ // 3. The counterparty checks a 750 TRY charge against it — over the cap, refused
95
+ check_mandate({ "envelope": "<envelope from step 2>", "amount": 750, "currency": "TRY", "rail": "moka" })
96
+ // → { "authorized": false, "reason": "amount exceeds mandate limit" }
97
+
98
+ // 4. Raise the mandate to 1000 TRY
99
+ create_mandate({ /* same as step 2, "maxAmount": "1000" */ })
100
+ // → { "mandateId": "...", "envelope": "<new envelope>", "expiresAt": "..." }
101
+
102
+ // 5. agent_pay authorizes the same 750 TRY charge under the raised mandate
103
+ agent_pay({ "envelope": "<envelope from step 4>", "amount": 750, "currency": "TRY", "rail": "moka" })
104
+ // → { "authorized": true, "envelope": "<same envelope>", "header": "x-solidus-mandate" }
105
+ ```
106
+
107
+ Step 5's `envelope` and `header` are what the caller sends to *their own* payment rail — Solidus's
108
+ part ends at authorization.
109
+
110
+ ## Trust boundary
111
+
112
+ This package is a thin adapter over [`@solidus-network/sdk`](https://www.npmjs.com/package/@solidus-network/sdk)
113
+ (chain reads) and [`@solidus-network/agent-identity`](https://www.npmjs.com/package/@solidus-network/agent-identity)
114
+ (mandates, credentials). It holds no issuer keys and does no cryptography of its own — credential
115
+ signing happens in the Solidus backend; trust in a credential is trust in the issuer key, not in this
116
+ code.
117
+
118
+ ## License
119
+
120
+ Apache-2.0
@@ -0,0 +1,24 @@
1
+ import type { Deps } from './deps.js';
2
+ export interface AgentPayArgs {
3
+ envelope: string;
4
+ amount: number | string;
5
+ currency: string;
6
+ rail: 'moka' | 'x402';
7
+ }
8
+ export interface AgentPayResult {
9
+ authorized: boolean;
10
+ reason?: string;
11
+ /** Present only when authorized — the SAME envelope, ready to present to the caller's own rail. */
12
+ envelope?: string;
13
+ /** The `X-Solidus-Mandate` header name to send the envelope under. */
14
+ header?: string;
15
+ }
16
+ /**
17
+ * Write tool: authorises a payment under a mandate. Solidus never settles
18
+ * money (see agent-identity's present.ts) — so this reuses `checkMandate`
19
+ * and, if authorised, hands back the envelope + header name for the caller
20
+ * to present to their own rail (Moka / x402). A refusal is returned
21
+ * unchanged and performs no further work.
22
+ */
23
+ export declare function agentPay(deps: Pick<Deps, 'agentsBaseUrl' | 'fetchImpl'>, args: AgentPayArgs): Promise<AgentPayResult>;
24
+ //# sourceMappingURL=agent-pay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-pay.d.ts","sourceRoot":"","sources":["../src/agent-pay.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,mGAAmG;IACnG,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CAAC,EAC/C,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,cAAc,CAAC,CAQzB"}
@@ -0,0 +1,17 @@
1
+ import { MANDATE_HEADER } from '@solidus-network/agent-identity/verify';
2
+ import { checkMandate } from './check-mandate.js';
3
+ /**
4
+ * Write tool: authorises a payment under a mandate. Solidus never settles
5
+ * money (see agent-identity's present.ts) — so this reuses `checkMandate`
6
+ * and, if authorised, hands back the envelope + header name for the caller
7
+ * to present to their own rail (Moka / x402). A refusal is returned
8
+ * unchanged and performs no further work.
9
+ */
10
+ export async function agentPay(deps, args) {
11
+ const outcome = await checkMandate(deps, args);
12
+ if (!outcome.authorized) {
13
+ return { authorized: false, reason: outcome.reason };
14
+ }
15
+ return { authorized: true, envelope: args.envelope, header: MANDATE_HEADER };
16
+ }
17
+ //# sourceMappingURL=agent-pay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-pay.js","sourceRoot":"","sources":["../src/agent-pay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAmBjD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,IAA+C,EAC/C,IAAkB;IAElB,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAE9C,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACxB,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAA;IACtD,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA;AAC9E,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { Deps } from './deps.js';
2
+ export interface CheckMandateArgs {
3
+ /** The `X-Solidus-Mandate` header value (base64url envelope). */
4
+ envelope: string;
5
+ amount: string | number;
6
+ currency: string;
7
+ rail: string;
8
+ }
9
+ export type MandateCheckOutcome = {
10
+ authorized: true;
11
+ agentDid: string;
12
+ principalDid: string;
13
+ maxAmount: string;
14
+ expiresAt: string;
15
+ verifiedAsOf: string;
16
+ } | {
17
+ authorized: false;
18
+ reason: string;
19
+ };
20
+ /**
21
+ * Read tool (pure, no auth): the counterparty check against
22
+ * `POST /v1/mandates/check`. The proof IS the credential — the backend
23
+ * requires no bearer token here. Passes the outcome through verbatim;
24
+ * this is the refusal that makes the whole product trustworthy.
25
+ */
26
+ export declare function checkMandate(deps: Pick<Deps, 'agentsBaseUrl' | 'fetchImpl'>, args: CheckMandateArgs): Promise<MandateCheckOutcome>;
27
+ //# sourceMappingURL=check-mandate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-mandate.d.ts","sourceRoot":"","sources":["../src/check-mandate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,WAAW,gBAAgB;IAC/B,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,MAAM,mBAAmB,GAC3B;IACE,UAAU,EAAE,IAAI,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;CACrB,GACD;IAAE,UAAU,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAEzC;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CAAC,EAC/C,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,mBAAmB,CAAC,CAY9B"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Read tool (pure, no auth): the counterparty check against
3
+ * `POST /v1/mandates/check`. The proof IS the credential — the backend
4
+ * requires no bearer token here. Passes the outcome through verbatim;
5
+ * this is the refusal that makes the whole product trustworthy.
6
+ */
7
+ export async function checkMandate(deps, args) {
8
+ const res = await deps.fetchImpl(`${deps.agentsBaseUrl}/v1/mandates/check`, {
9
+ method: 'POST',
10
+ headers: { 'content-type': 'application/json' },
11
+ body: JSON.stringify({
12
+ envelope: args.envelope,
13
+ amount: String(args.amount),
14
+ currency: args.currency,
15
+ rail: args.rail,
16
+ }),
17
+ });
18
+ return (await res.json());
19
+ }
20
+ //# sourceMappingURL=check-mandate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-mandate.js","sourceRoot":"","sources":["../src/check-mandate.ts"],"names":[],"mappings":"AAqBA;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAA+C,EAC/C,IAAsB;IAEtB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,aAAa,oBAAoB,EAAE;QAC1E,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;YAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;KACH,CAAC,CAAA;IACF,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAwB,CAAA;AAClD,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { Deps } from './deps.js';
2
+ export interface CreateMandateArgs {
3
+ agentId: string;
4
+ principalDid: string;
5
+ maxAmount: string;
6
+ currency: string;
7
+ rail: string;
8
+ expiresAt: string;
9
+ ap2IntentRef?: string;
10
+ }
11
+ export interface CreateMandateResult {
12
+ mandateId: string;
13
+ /** The `X-Solidus-Mandate` header value — feed this straight into `check_mandate`. */
14
+ envelope: string;
15
+ expiresAt: string | null;
16
+ }
17
+ /**
18
+ * Write tool: create a spend_mandate credential via `AgentIdentity.createMandate`,
19
+ * then derive the checkable envelope with `buildMandateHeader`. Returns only
20
+ * {mandateId, envelope, expiresAt} — never the credential bundle (signature,
21
+ * public key, raw message vector) that `createMandate` returns underneath.
22
+ */
23
+ export declare function createMandate(deps: Pick<Deps, 'agent'>, args: CreateMandateArgs): Promise<CreateMandateResult>;
24
+ //# sourceMappingURL=create-mandate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-mandate.d.ts","sourceRoot":"","sources":["../src/create-mandate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAA;IACjB,sFAAsF;IACtF,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,EACzB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,mBAAmB,CAAC,CAU9B"}
@@ -0,0 +1,18 @@
1
+ import { buildMandateHeader } from '@solidus-network/agent-identity';
2
+ /**
3
+ * Write tool: create a spend_mandate credential via `AgentIdentity.createMandate`,
4
+ * then derive the checkable envelope with `buildMandateHeader`. Returns only
5
+ * {mandateId, envelope, expiresAt} — never the credential bundle (signature,
6
+ * public key, raw message vector) that `createMandate` returns underneath.
7
+ */
8
+ export async function createMandate(deps, args) {
9
+ const { agentId, ...input } = args;
10
+ const result = await deps.agent.createMandate(agentId, input);
11
+ const header = await buildMandateHeader(result.bundle, { rail: args.rail, currency: args.currency }, {});
12
+ return {
13
+ mandateId: result.mandate.id,
14
+ envelope: header.value,
15
+ expiresAt: result.mandate.expiresAt,
16
+ };
17
+ }
18
+ //# sourceMappingURL=create-mandate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-mandate.js","sourceRoot":"","sources":["../src/create-mandate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAoB5D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAyB,EACzB,IAAuB;IAEvB,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAA;IAClC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC7D,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAA;IAExG,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE;QAC5B,QAAQ,EAAE,MAAM,CAAC,KAAK;QACtB,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS;KACpC,CAAA;AACH,CAAC"}
package/dist/deps.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ import { type SolidusSDK } from '@solidus-network/sdk';
2
+ import { type AgentIdentity } from '@solidus-network/agent-identity';
3
+ /**
4
+ * Injected dependencies every tool handler needs. Handlers are pure
5
+ * functions of `(deps, args)` — no handler reads `process.env` directly,
6
+ * which is what makes them unit-testable without a real network or chain.
7
+ */
8
+ export interface Deps {
9
+ sdk: SolidusSDK;
10
+ agent: AgentIdentity;
11
+ agentsBaseUrl: string;
12
+ /** Resolved chain RPC endpoint — exposed (like `agentsBaseUrl`) so the effective config is observable. */
13
+ rpcUrl: string;
14
+ fetchImpl: typeof fetch;
15
+ }
16
+ /**
17
+ * Build {@link Deps} from environment variables. Defaults the chain SDK to
18
+ * `testnet` mode. `stub` mode routes `did.resolve`/`credentials.verify`
19
+ * through a Postgres-backed simulation (`@solidus-network/sdk`'s `src/stub/*.ts`,
20
+ * requires `SOLIDUS_STUB_DB_URL`) — shipping that as the default would mean
21
+ * an installed server either crashes or returns simulated data while its
22
+ * tool description claims to resolve `did:solidus`. `createSdk` now makes
23
+ * the signer key lazy (only `did.create` needs one), so a read-only
24
+ * `testnet` chain client works with no key and no DB. Set
25
+ * `SOLIDUS_SDK_MODE=stub` explicitly to opt into stub mode for local dev.
26
+ */
27
+ export declare function buildDepsFromEnv(env: Record<string, string | undefined>): Deps;
28
+ //# sourceMappingURL=deps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAEjF;;;;GAIG;AACH,MAAM,WAAW,IAAI;IACnB,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,aAAa,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,0GAA0G;IAC1G,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,OAAO,KAAK,CAAA;CACxB;AAWD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,IAAI,CA0B9E"}
package/dist/deps.js ADDED
@@ -0,0 +1,46 @@
1
+ import { createSdk } from '@solidus-network/sdk';
2
+ import { createAgentIdentity } from '@solidus-network/agent-identity';
3
+ const DEFAULT_AGENTS_URL = 'https://agents.solidus.network';
4
+ /**
5
+ * Must be defaulted HERE, not left to the SDK. `@solidus-network/sdk` falls back to
6
+ * `http://127.0.0.1:9944` when no rpcUrl is given, so omitting this pointed a
7
+ * freshly-installed `npx @solidus-network/mcp` at the user's own localhost —
8
+ * every tool call died with "fetch failed".
9
+ */
10
+ const DEFAULT_RPC_URL = 'https://rpc.solidus.network';
11
+ /**
12
+ * Build {@link Deps} from environment variables. Defaults the chain SDK to
13
+ * `testnet` mode. `stub` mode routes `did.resolve`/`credentials.verify`
14
+ * through a Postgres-backed simulation (`@solidus-network/sdk`'s `src/stub/*.ts`,
15
+ * requires `SOLIDUS_STUB_DB_URL`) — shipping that as the default would mean
16
+ * an installed server either crashes or returns simulated data while its
17
+ * tool description claims to resolve `did:solidus`. `createSdk` now makes
18
+ * the signer key lazy (only `did.create` needs one), so a read-only
19
+ * `testnet` chain client works with no key and no DB. Set
20
+ * `SOLIDUS_SDK_MODE=stub` explicitly to opt into stub mode for local dev.
21
+ */
22
+ export function buildDepsFromEnv(env) {
23
+ const agentsBaseUrl = env['SOLIDUS_AGENTS_URL'] ?? DEFAULT_AGENTS_URL;
24
+ const rpcUrl = env['SOLIDUS_RPC_URL'] ?? DEFAULT_RPC_URL;
25
+ const mode = env['SOLIDUS_SDK_MODE'] ?? 'testnet';
26
+ const signerPrivateKey = env['SOLIDUS_SIGNER_KEY'];
27
+ const token = env['SOLIDUS_API_KEY'];
28
+ const sdk = createSdk({
29
+ mode,
30
+ ...(rpcUrl !== undefined ? { rpcUrl } : {}),
31
+ ...(signerPrivateKey !== undefined ? { signerPrivateKey } : {}),
32
+ });
33
+ const agent = createAgentIdentity({
34
+ baseUrl: agentsBaseUrl,
35
+ ...(token !== undefined ? { token } : {}),
36
+ ...(rpcUrl !== undefined ? { solidusRpcUrl: rpcUrl } : {}),
37
+ });
38
+ return {
39
+ sdk,
40
+ agent,
41
+ agentsBaseUrl,
42
+ rpcUrl,
43
+ fetchImpl: globalThis.fetch,
44
+ };
45
+ }
46
+ //# sourceMappingURL=deps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deps.js","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmB,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,mBAAmB,EAAsB,MAAM,yBAAyB,CAAA;AAgBjF,MAAM,kBAAkB,GAAG,gCAAgC,CAAA;AAC3D;;;;;GAKG;AACH,MAAM,eAAe,GAAG,6BAA6B,CAAA;AAErD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAuC;IACtE,MAAM,aAAa,GAAG,GAAG,CAAC,oBAAoB,CAAC,IAAI,kBAAkB,CAAA;IACrE,MAAM,MAAM,GAAG,GAAG,CAAC,iBAAiB,CAAC,IAAI,eAAe,CAAA;IACxD,MAAM,IAAI,GAAI,GAAG,CAAC,kBAAkB,CAAgD,IAAI,SAAS,CAAA;IACjG,MAAM,gBAAgB,GAAG,GAAG,CAAC,oBAAoB,CAAC,CAAA;IAClD,MAAM,KAAK,GAAG,GAAG,CAAC,iBAAiB,CAAC,CAAA;IAEpC,MAAM,GAAG,GAAG,SAAS,CAAC;QACpB,IAAI;QACJ,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,GAAG,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChE,CAAC,CAAA;IAEF,MAAM,KAAK,GAAG,mBAAmB,CAAC;QAChC,OAAO,EAAE,aAAa;QACtB,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3D,CAAC,CAAA;IAEF,OAAO;QACL,GAAG;QACH,KAAK;QACL,aAAa;QACb,MAAM;QACN,SAAS,EAAE,UAAU,CAAC,KAAK;KAC5B,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { buildDepsFromEnv } from './deps.js';
4
+ import { buildServer } from './server.js';
5
+ async function main() {
6
+ const deps = buildDepsFromEnv(process.env);
7
+ const server = buildServer(deps);
8
+ const transport = new StdioServerTransport();
9
+ await server.connect(transport);
10
+ }
11
+ main().catch((err) => {
12
+ console.error('solidus-mcp failed to start:', err);
13
+ process.exit(1);
14
+ });
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,KAAK,UAAU,IAAI;IACjB,MAAM,IAAI,GAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC1C,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAA;IAChC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAA;IAC5C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AACjC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAA;IAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { DIDDocument } from '@solidus-network/sdk';
2
+ import type { Deps } from './deps.js';
3
+ export interface ResolveDidResult {
4
+ did: string;
5
+ document: DIDDocument | null;
6
+ resolved: boolean;
7
+ }
8
+ /** Read tool: resolve a `did:solidus` DID document via the chain SDK. */
9
+ export declare function resolveDid(deps: Pick<Deps, 'sdk'>, args: {
10
+ did: string;
11
+ }): Promise<ResolveDidResult>;
12
+ //# sourceMappingURL=resolve-did.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-did.d.ts","sourceRoot":"","sources":["../src/resolve-did.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAA;IAC5B,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,yEAAyE;AACzE,wBAAsB,UAAU,CAC9B,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EACvB,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GACpB,OAAO,CAAC,gBAAgB,CAAC,CAG3B"}
@@ -0,0 +1,6 @@
1
+ /** Read tool: resolve a `did:solidus` DID document via the chain SDK. */
2
+ export async function resolveDid(deps, args) {
3
+ const document = await deps.sdk.did.resolve(args.did);
4
+ return { did: args.did, document, resolved: document !== null };
5
+ }
6
+ //# sourceMappingURL=resolve-did.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-did.js","sourceRoot":"","sources":["../src/resolve-did.ts"],"names":[],"mappings":"AASA,yEAAyE;AACzE,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAAuB,EACvB,IAAqB;IAErB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACrD,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,KAAK,IAAI,EAAE,CAAA;AACjE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { Deps } from './deps.js';
3
+ /**
4
+ * Build the Solidus MCP server: registers all five tools against the
5
+ * injected {@link Deps}. Pure factory — no env reads, no transport. The bin
6
+ * entrypoint (`index.ts`) supplies `Deps` and the stdio transport.
7
+ */
8
+ export declare function buildServer(deps: Deps): McpServer;
9
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAEnE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAYrC;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CA0GjD"}
package/dist/server.js ADDED
@@ -0,0 +1,88 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { z } from 'zod';
3
+ import { resolveDid } from './resolve-did.js';
4
+ import { verifyCredential } from './verify-credential.js';
5
+ import { checkMandate } from './check-mandate.js';
6
+ import { createMandate } from './create-mandate.js';
7
+ import { agentPay } from './agent-pay.js';
8
+ /** Wrap a handler's JSON-serializable result in the MCP tool-call content shape. */
9
+ function toolResult(value) {
10
+ return { content: [{ type: 'text', text: JSON.stringify(value) }] };
11
+ }
12
+ /**
13
+ * Build the Solidus MCP server: registers all five tools against the
14
+ * injected {@link Deps}. Pure factory — no env reads, no transport. The bin
15
+ * entrypoint (`index.ts`) supplies `Deps` and the stdio transport.
16
+ */
17
+ export function buildServer(deps) {
18
+ const server = new McpServer({ name: 'solidus', version: '0.1.0' });
19
+ server.registerTool('resolve_did', {
20
+ title: 'Resolve DID',
21
+ description: 'Resolve a did:solidus DID document from the Solidus chain. Read-only, no auth required. ' +
22
+ 'Returns {did, document, resolved} — document is null and resolved is false if the DID is not found.',
23
+ inputSchema: {
24
+ did: z.string().describe('The did:solidus DID to resolve, e.g. did:solidus:testnet:abc123.'),
25
+ },
26
+ }, async ({ did }) => toolResult(await resolveDid(deps, { did })));
27
+ server.registerTool('verify_credential', {
28
+ title: 'Verify Credential',
29
+ description: 'Verify a Solidus verifiable credential by id against the Solidus chain. Read-only, no auth ' +
30
+ 'required. Returns {vcId, result} where result is the chain verification outcome verbatim.',
31
+ inputSchema: {
32
+ vcId: z.string().describe('The verifiable credential id to verify.'),
33
+ },
34
+ }, async ({ vcId }) => toolResult(await verifyCredential(deps, { vcId })));
35
+ server.registerTool('check_mandate', {
36
+ title: 'Check Mandate',
37
+ description: 'Check whether a spend mandate envelope authorizes a payment of the given amount/currency/rail. ' +
38
+ 'Read-only and pure — performs no side effects, moves no money. This is the counterparty refusal ' +
39
+ 'check: returns {authorized:false, reason} when the mandate does not cover the request, or ' +
40
+ '{authorized:true, agentDid, principalDid, maxAmount, expiresAt, verifiedAsOf} when it does.',
41
+ inputSchema: {
42
+ envelope: z.string().describe('The X-Solidus-Mandate header value (base64url envelope).'),
43
+ amount: z.union([z.string(), z.number()]).describe('The payment amount to check against the mandate.'),
44
+ currency: z.string().describe('The payment currency, e.g. TRY, USD.'),
45
+ rail: z.string().describe("The payment rail, e.g. 'moka' or 'x402'."),
46
+ },
47
+ }, async ({ envelope, amount, currency, rail }) => toolResult(await checkMandate(deps, { envelope, amount, currency, rail })));
48
+ server.registerTool('create_mandate', {
49
+ title: 'Create Mandate',
50
+ description: 'Create a scoped spend_mandate credential for an agent, bounded by maxAmount/currency/rail/expiresAt, ' +
51
+ 'on behalf of a principal DID. WRITE tool — this issues a real credential; a human should confirm ' +
52
+ 'the terms before calling it. Returns only {mandateId, envelope, expiresAt} — never the private key ' +
53
+ 'or credential bundle. The returned envelope is what check_mandate and agent_pay consume.',
54
+ inputSchema: {
55
+ agentId: z.string().describe('The id of the agent the mandate is issued to.'),
56
+ principalDid: z.string().describe('The did:solidus of the human/principal the agent acts for.'),
57
+ maxAmount: z.string().describe('The maximum spend amount the mandate authorizes, as a string.'),
58
+ currency: z.string().describe('The mandate currency, e.g. TRY, USD.'),
59
+ rail: z.string().describe("The payment rail this mandate is scoped to, e.g. 'moka' or 'x402'."),
60
+ expiresAt: z.string().describe('Absolute ISO 8601 timestamp the mandate expires at.'),
61
+ ap2IntentRef: z.string().optional().describe('Optional AP2 intent reference to bind the mandate to.'),
62
+ },
63
+ }, async ({ agentId, principalDid, maxAmount, currency, rail, expiresAt, ap2IntentRef }) => toolResult(await createMandate(deps, {
64
+ agentId,
65
+ principalDid,
66
+ maxAmount,
67
+ currency,
68
+ rail,
69
+ expiresAt,
70
+ ...(ap2IntentRef !== undefined ? { ap2IntentRef } : {}),
71
+ })));
72
+ server.registerTool('agent_pay', {
73
+ title: 'Agent Pay',
74
+ description: 'Authorize a payment under a spend mandate and, if authorized, return the envelope for the caller ' +
75
+ 'to present to their OWN payment rail (Moka / x402). WRITE tool. This tool does NOT settle money — ' +
76
+ 'Solidus never moves funds — it only checks the mandate and hands back an authorized envelope + the ' +
77
+ 'X-Solidus-Mandate header name to send it under. A refused check returns {authorized:false, reason} ' +
78
+ 'and performs no further work.',
79
+ inputSchema: {
80
+ envelope: z.string().describe('The X-Solidus-Mandate header value (base64url envelope).'),
81
+ amount: z.union([z.string(), z.number()]).describe('The payment amount to authorize.'),
82
+ currency: z.string().describe('The payment currency, e.g. TRY, USD.'),
83
+ rail: z.enum(['moka', 'x402']).describe('The payment rail the caller will settle on.'),
84
+ },
85
+ }, async ({ envelope, amount, currency, rail }) => toolResult(await agentPay(deps, { envelope, amount, currency, rail })));
86
+ return server;
87
+ }
88
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,11 @@
1
+ import type { VerificationResult } from '@solidus-network/sdk';
2
+ import type { Deps } from './deps.js';
3
+ export interface VerifyCredentialResult {
4
+ vcId: string;
5
+ result: VerificationResult;
6
+ }
7
+ /** Read tool: verify a Solidus verifiable credential via the chain SDK. */
8
+ export declare function verifyCredential(deps: Pick<Deps, 'sdk'>, args: {
9
+ vcId: string;
10
+ }): Promise<VerifyCredentialResult>;
11
+ //# sourceMappingURL=verify-credential.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-credential.d.ts","sourceRoot":"","sources":["../src/verify-credential.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,kBAAkB,CAAA;CAC3B;AAED,2EAA2E;AAC3E,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EACvB,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GACrB,OAAO,CAAC,sBAAsB,CAAC,CAGjC"}
@@ -0,0 +1,6 @@
1
+ /** Read tool: verify a Solidus verifiable credential via the chain SDK. */
2
+ export async function verifyCredential(deps, args) {
3
+ const result = await deps.sdk.credentials.verify(args.vcId);
4
+ return { vcId: args.vcId, result };
5
+ }
6
+ //# sourceMappingURL=verify-credential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-credential.js","sourceRoot":"","sources":["../src/verify-credential.ts"],"names":[],"mappings":"AAQA,2EAA2E;AAC3E,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAAuB,EACvB,IAAsB;IAEtB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3D,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAA;AACpC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@solidus-network/mcp",
3
+ "version": "0.1.0",
4
+ "description": "Solidus MCP server — run-time agent tools: resolve did:solidus, verify credentials, check/create scoped spend mandates, and authorize payments against them.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "solidus-mcp": "./dist/index.js"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ "types": "./dist/index.d.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "dependencies": {
23
+ "@modelcontextprotocol/sdk": "^1.12.0",
24
+ "@solidus-network/agent-identity": "0.1.2",
25
+ "@solidus-network/sdk": "0.6.3",
26
+ "zod": "^3.22.4"
27
+ },
28
+ "keywords": [
29
+ "solidus",
30
+ "mcp",
31
+ "model-context-protocol",
32
+ "ai-agents",
33
+ "agent-tools",
34
+ "did",
35
+ "verifiable-credentials",
36
+ "spend-mandate",
37
+ "decentralized-identity"
38
+ ],
39
+ "author": "Solidus Network (https://solidus.network)",
40
+ "license": "Apache-2.0",
41
+ "homepage": "https://solidus.network",
42
+ "bugs": {
43
+ "url": "https://github.com/solidusnetwork/sdk/issues"
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/solidusnetwork/sdk.git",
48
+ "directory": "mcp"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ }
53
+ }