@getaccord/mcp 0.0.0-stage → 0.5.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.
- package/LICENSE +202 -0
- package/README.md +103 -2
- package/dist/brand.js +9 -0
- package/dist/brand.js.map +1 -0
- package/dist/server.js +311 -0
- package/dist/server.js.map +1 -0
- package/dist/settings.js +32 -0
- package/dist/settings.js.map +1 -0
- package/package.json +40 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,104 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @getaccord/mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Accord MCP server. Lets any MCP client (Claude Code, Claude Desktop, Cursor, an Agent SDK agent) pay several sellers at once as tools, all or nothing, under the same limits as the SDK. Test mode.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx -y @getaccord/mcp
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The bin is `accord-mcp`; `npx @getaccord/cli mcp` runs the same server.
|
|
10
|
+
|
|
11
|
+
## Tools
|
|
12
|
+
|
|
13
|
+
| Tool | Does |
|
|
14
|
+
|---|---|
|
|
15
|
+
| `get_spending_limits` | Money available, weekly budget, paid, held, left |
|
|
16
|
+
| `start_purchase` | Opens a purchase: total budget, `all` (everyone or nobody) or `each` |
|
|
17
|
+
| `place_holds` | Holds money with one or more sellers in one step |
|
|
18
|
+
| `get_delivered_work`, `accept_work`, `reject_work` | Check delivered work before paying |
|
|
19
|
+
| `complete_purchase` | Pays everyone in one step, or nobody; returns the public record link |
|
|
20
|
+
| `cancel_purchase` | Releases every hold |
|
|
21
|
+
| `quote_x402_url` | Reads an x402 seller's price (Accord option only) |
|
|
22
|
+
| `fetch_x402_resource` | Pays an x402 seller inside a purchase and fetches what it sells |
|
|
23
|
+
|
|
24
|
+
Amounts are in dollars. A refusal (seller not allowed, over the weekly limit, waiting for a person's sign-off) comes back as a tool error that quotes the rule, so the model can tell the user.
|
|
25
|
+
|
|
26
|
+
## The key
|
|
27
|
+
|
|
28
|
+
The server reads the agent key from `ACCORD_AGENT_KEY`, or from the file named by `ACCORD_KEY_FILE` (a `.env` from `init`, or just the key), or from `./.env`. No tool takes the key and no tool returns it, so the model never sees it.
|
|
29
|
+
|
|
30
|
+
## Get a key
|
|
31
|
+
|
|
32
|
+
Give the server its own test key, in its own folder, so the samples you run on your main key don't use up its week or its sign-off allowance:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
mkdir -p ~/accord-mcp && cd ~/accord-mcp && npx @getaccord/cli init
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
That writes the agent key to `~/accord-mcp/.env` and the owner token to `~/.accord/` (never to `.env`). The server never reads the owner token, so there is no tool for raising limits, allowing sellers or approving a purchase that waits for sign-off: the agent can't approve its own spending. The owner does that from the CLI (`accord allow`, `accord revoke`) or, in test mode, with `accord.test.approve(intentId)` from the SDK.
|
|
39
|
+
|
|
40
|
+
In the snippets below, replace `/Users/you` with your home folder (`echo $HOME`). Tools show up under the server name `accord` (in Claude Code, `mcp__accord__get_spending_limits` and so on).
|
|
41
|
+
|
|
42
|
+
## Claude Code
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
claude mcp add accord -e ACCORD_KEY_FILE="$HOME/accord-mcp/.env" -- npx -y @getaccord/mcp
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Add `--scope user` to have it in every project.
|
|
49
|
+
|
|
50
|
+
## Claude Desktop
|
|
51
|
+
|
|
52
|
+
Settings → Developer → Edit Config opens `claude_desktop_config.json` (on macOS, `~/Library/Application Support/Claude/claude_desktop_config.json`). Add:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"mcpServers": {
|
|
57
|
+
"accord": {
|
|
58
|
+
"command": "npx",
|
|
59
|
+
"args": ["-y", "@getaccord/mcp"],
|
|
60
|
+
"env": { "ACCORD_KEY_FILE": "/Users/you/accord-mcp/.env" }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Then quit and reopen Claude Desktop.
|
|
67
|
+
|
|
68
|
+
## Cursor
|
|
69
|
+
|
|
70
|
+
In `~/.cursor/mcp.json` (every project) or `.cursor/mcp.json` (one project):
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"mcpServers": {
|
|
75
|
+
"accord": {
|
|
76
|
+
"command": "npx",
|
|
77
|
+
"args": ["-y", "@getaccord/mcp"],
|
|
78
|
+
"env": { "ACCORD_KEY_FILE": "/Users/you/accord-mcp/.env" }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## From this repo
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
claude mcp add accord -e ACCORD_KEY_FILE="$HOME/accord-mcp/.env" -- node --conditions=accord-source /path/to/repo/packages/mcp/src/server.ts
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
After `npm run build`, `node packages/mcp/dist/server.js` works without the flag.
|
|
91
|
+
|
|
92
|
+
## Injection sample
|
|
93
|
+
|
|
94
|
+
`examples/mcp-injection/agent.ts`: an agent works through an office inbox with three plausible injections, paying only through this server. The key allows $2,000 a week, needs a person's sign-off once unapproved spending passes $1,000 in 24 hours, and may not pay quickpay.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm run mcp-injection -- --scripted
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`--scripted` is a compromised model that follows every injection, with no API key. Without it, Claude runs the same inbox (needs `ANTHROPIC_API_KEY`); `--runs 5` repeats it and tallies what the model tried and what the service did; `--verbose` shows each tool call.
|
|
101
|
+
|
|
102
|
+
In the scripted run, payments to quickpay are refused, and the invoice split into $475 payments pays once; the next would take the day's unapproved spending past $1,000, so the rest wait for a person.
|
|
103
|
+
|
|
104
|
+
The product name and server name live in `src/brand.ts`; the service host comes from the SDK (override with `ACCORD_URL`).
|
package/dist/brand.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Every user-visible product name in this package comes from here, so a
|
|
2
|
+
// rename is a change to this file only. The service host comes from the SDK
|
|
3
|
+
// (its DEFAULT_URL), overridable with ACCORD_URL.
|
|
4
|
+
/** The product's name, as tool descriptions say it to the model. */
|
|
5
|
+
export const PRODUCT_NAME = 'Accord';
|
|
6
|
+
/** The MCP server's name, as clients show it (and prefix its tools with). */
|
|
7
|
+
export const SERVER_NAME = 'accord';
|
|
8
|
+
export const SERVER_VERSION = '0.5.1';
|
|
9
|
+
//# sourceMappingURL=brand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand.js","sourceRoot":"","sources":["../src/brand.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,4EAA4E;AAC5E,kDAAkD;AAElD,oEAAoE;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AAErC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC;AAEpC,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// MCP server: lets any MCP client (Claude Code, Claude Desktop, Cursor, an
|
|
3
|
+
// Agent SDK agent) pay sellers through the service as tools.
|
|
4
|
+
//
|
|
5
|
+
// The agent key comes from the environment or a local file, never from a tool
|
|
6
|
+
// argument, and is never echoed back. Every limit on that key (weekly budget,
|
|
7
|
+
// allowed sellers, approval threshold, expiry) is enforced by the service, so
|
|
8
|
+
// the model connected here can never do more than the key allows.
|
|
9
|
+
//
|
|
10
|
+
// ACCORD_AGENT_KEY the key itself, or
|
|
11
|
+
// ACCORD_KEY_FILE a file holding it (a .env with ACCORD_AGENT_KEY=..., or just the key)
|
|
12
|
+
// ACCORD_URL the service (defaults to the hosted test service)
|
|
13
|
+
//
|
|
14
|
+
// The service comes from the same place as the key: ACCORD_URL in the
|
|
15
|
+
// environment, else the ACCORD_URL line of the file the key was read from, else
|
|
16
|
+
// the hosted test service. A .env in the client's working folder (Claude Code
|
|
17
|
+
// starts servers in the user's project) never points a key file's key at
|
|
18
|
+
// another service.
|
|
19
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
20
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
21
|
+
import { z } from 'zod';
|
|
22
|
+
import { Accord, AccordError } from '@getaccord/sdk';
|
|
23
|
+
import * as x402 from '@getaccord/sdk/x402';
|
|
24
|
+
import { PRODUCT_NAME, SERVER_NAME, SERVER_VERSION } from "./brand.js";
|
|
25
|
+
import { loadSettings } from "./settings.js";
|
|
26
|
+
// --- The agent key: loaded once, never exposed through a tool ---
|
|
27
|
+
let KEY;
|
|
28
|
+
let URL_;
|
|
29
|
+
try {
|
|
30
|
+
({ key: KEY, url: URL_ } = loadSettings());
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
// stdout belongs to the MCP protocol; explain on stderr and stop.
|
|
34
|
+
console.error(`${SERVER_NAME}: ${e.message}`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
// The SDK's x402 helpers read ACCORD_URL from the environment; give them the same service.
|
|
38
|
+
process.env.ACCORD_URL = URL_;
|
|
39
|
+
const accord = new Accord({ url: URL_ });
|
|
40
|
+
// Purchases opened in this session, by the handle given to the model.
|
|
41
|
+
const purchases = new Map();
|
|
42
|
+
// x402: offers quoted in this session (by URL), and each completed purchase's commit digest.
|
|
43
|
+
const offers = new Map();
|
|
44
|
+
const commits = new Map();
|
|
45
|
+
let counter = 0;
|
|
46
|
+
// --- Formatting ---
|
|
47
|
+
const cents = (usd) => Math.round(usd * 100);
|
|
48
|
+
const usd = (c) => `$${(c / 100).toLocaleString('en-US', { minimumFractionDigits: 2 })}`;
|
|
49
|
+
const ok = (text) => ({ content: [{ type: 'text', text }] });
|
|
50
|
+
/** A refusal or failure, as a tool result that quotes the rule. Never a crash. */
|
|
51
|
+
function refused(e) {
|
|
52
|
+
const err = e;
|
|
53
|
+
const detail = String(err?.message ?? e).replace(/^\w+: /, '');
|
|
54
|
+
const rules = {
|
|
55
|
+
limit_exceeded: "Refused by this agent key's weekly spending limit. Nothing was paid.",
|
|
56
|
+
seller_not_allowed: "Refused: this agent key isn't allowed to pay that seller. Nothing was paid.",
|
|
57
|
+
awaiting_approval: "Waiting for a person's sign-off. No money was drawn.",
|
|
58
|
+
old_version: 'This agent key was made for an earlier version of the service and no longer works.',
|
|
59
|
+
results_pending: 'Delivered work needs an accept or reject decision before completing.',
|
|
60
|
+
key_revoked: 'Refused: this agent key has been revoked. Nothing was paid.',
|
|
61
|
+
key_expired: 'Refused: this agent key has expired. Nothing was paid.',
|
|
62
|
+
over_budget: "Refused: the holds would exceed this purchase's budget. Nothing was paid.",
|
|
63
|
+
insufficient_balance: "Refused: the account behind this key doesn't have enough money. Nothing was paid.",
|
|
64
|
+
unknown_seller: 'Refused: there is no seller by that name. Nothing was paid.',
|
|
65
|
+
seller_inactive: 'Refused: that seller has stopped accepting payments. Nothing was paid.',
|
|
66
|
+
unknown_agent: 'This agent key is not registered with the service.',
|
|
67
|
+
unknown_purchase: 'There is no purchase by that id in this session.',
|
|
68
|
+
x402_no_accord_option: `Not paid: that seller doesn't accept ${PRODUCT_NAME} payments.`,
|
|
69
|
+
no_holds: 'Nothing to complete: this purchase has no holds (place_holds first, or it was refused).',
|
|
70
|
+
};
|
|
71
|
+
const notPolicy = ['unknown_purchase', 'no_holds', 'results_pending'];
|
|
72
|
+
const code = err?.code ?? '';
|
|
73
|
+
const lead = rules[code] ?? `Refused (${code || 'error'}).`;
|
|
74
|
+
// Plain words for the model: no internal ids, no developer instructions.
|
|
75
|
+
// Sign-off: the service's reason with its numbers, without the SDK's developer hint.
|
|
76
|
+
// Splitting the purchase doesn't avoid it: unapproved spending is added up over 24 hours.
|
|
77
|
+
const rule = code === 'awaiting_approval'
|
|
78
|
+
? `${detail.split(' Place holds again')[0].replace(/\bintent 0x[0-9a-f]{16,}\b/gi, 'this purchase')} Ask the user to approve it; splitting the purchase won't avoid this.`
|
|
79
|
+
: code === 'old_version'
|
|
80
|
+
? 'Ask the user to make a new test key (npx @getaccord/cli init --force) and restart this server.'
|
|
81
|
+
: detail.replace(/\bintent 0x[0-9a-f]{16,}\b/gi, 'this purchase');
|
|
82
|
+
const policy = code in rules && !notPolicy.includes(code);
|
|
83
|
+
return {
|
|
84
|
+
isError: true,
|
|
85
|
+
content: [
|
|
86
|
+
{
|
|
87
|
+
type: 'text',
|
|
88
|
+
text: `${lead}\nRule: ${rule}` +
|
|
89
|
+
(policy ? `\nThese limits are enforced by ${PRODUCT_NAME}, not by you; don't try to work around them. Tell the user what was refused and why.` : ''),
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function purchase(id) {
|
|
95
|
+
const p = purchases.get(id);
|
|
96
|
+
if (!p)
|
|
97
|
+
throw Object.assign(new Error(`No purchase "${id}" in this session. Start one with start_purchase.`), { code: 'unknown_purchase' });
|
|
98
|
+
return p;
|
|
99
|
+
}
|
|
100
|
+
function describe(s) {
|
|
101
|
+
const lines = s.holds.map((h) => ` #${h.index} ${h.seller}: ${usd(h.amount)} (${h.type}) — ${h.state}${h.result ? `\n delivered: ${h.result.slice(0, 400)}` : ''}`);
|
|
102
|
+
return [
|
|
103
|
+
`Status: ${s.status}. Paid ${usd(s.paid)} of a ${usd(s.budget)} budget (${s.mode === 'all' ? 'all sellers or none' : 'each ready seller'}).`,
|
|
104
|
+
...lines,
|
|
105
|
+
`Public record: ${s.proofUrl}`,
|
|
106
|
+
].join('\n');
|
|
107
|
+
}
|
|
108
|
+
// --- Server and tools ---
|
|
109
|
+
const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION });
|
|
110
|
+
server.registerTool('get_spending_limits', {
|
|
111
|
+
title: 'Check spending limits',
|
|
112
|
+
description: `What this agent key may still spend through ${PRODUCT_NAME}: the money available, the weekly budget, how much of it is ` +
|
|
113
|
+
'already paid or held, and whether the key is revoked. Check this before planning a purchase. Amounts are in US dollars.',
|
|
114
|
+
annotations: { readOnlyHint: true },
|
|
115
|
+
}, async () => {
|
|
116
|
+
try {
|
|
117
|
+
const b = await accord.balance(KEY);
|
|
118
|
+
const left = Math.max(0, b.weekly.budget - b.weekly.spent - b.weekly.held);
|
|
119
|
+
return ok([
|
|
120
|
+
`Available: ${usd(b.available)}`,
|
|
121
|
+
`Weekly budget: ${usd(b.weekly.budget)} — paid ${usd(b.weekly.spent)}, held ${usd(b.weekly.held)}, left ${usd(left)}`,
|
|
122
|
+
...(b.signOff
|
|
123
|
+
? [
|
|
124
|
+
`Without a person's sign-off: ${usd(b.signOff.unapprovedLast24h)} of ${usd(b.signOff.limit)} used in the last 24 hours (${usd(b.signOff.left)} left). ` +
|
|
125
|
+
'A purchase that would go past it waits for approval.',
|
|
126
|
+
]
|
|
127
|
+
: []),
|
|
128
|
+
b.revoked ? 'This key is REVOKED: no new payments.' : 'Key is active.',
|
|
129
|
+
'Sellers outside the allowed list are refused.',
|
|
130
|
+
].join('\n'));
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
return refused(e);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
server.registerTool('start_purchase', {
|
|
137
|
+
title: 'Start a purchase',
|
|
138
|
+
description: 'Start a purchase that may involve several sellers (an "intent"). Nothing is paid yet. Choose the most it may cost in ' +
|
|
139
|
+
'total (budget_usd). mode "all" pays every seller or none (use it when the parts only make sense together, like a ' +
|
|
140
|
+
'flight, hotel and car); mode "each" pays each seller that delivers and releases the rest. Returns a purchase_id for the other tools.',
|
|
141
|
+
inputSchema: {
|
|
142
|
+
budget_usd: z.number().positive().describe('The most this purchase may cost in total, in US dollars.'),
|
|
143
|
+
mode: z.enum(['all', 'each']).default('all').describe('"all": every seller or none. "each": pay whoever delivers.'),
|
|
144
|
+
expires_in_minutes: z.number().int().min(1).max(60).default(15).describe('Unanswered holds are released after this.'),
|
|
145
|
+
},
|
|
146
|
+
}, async ({ budget_usd, mode, expires_in_minutes }) => {
|
|
147
|
+
try {
|
|
148
|
+
const intent = await accord.intent({ key: KEY, budget: cents(budget_usd), mode, expiresIn: `${expires_in_minutes}m` });
|
|
149
|
+
const id = `purchase_${++counter}`;
|
|
150
|
+
purchases.set(id, intent);
|
|
151
|
+
return ok(`Started ${id}: up to ${usd(cents(budget_usd))}, mode "${mode}". Next: place_holds.`);
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
return refused(e);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
server.registerTool('place_holds', {
|
|
158
|
+
title: 'Hold money with sellers',
|
|
159
|
+
description: 'Lock money with one or more sellers for a purchase, all in one step. The money is held, not paid: it moves only when the ' +
|
|
160
|
+
'purchase is completed, and comes back if it is cancelled or a seller declines. type "reserve" is for things the seller ' +
|
|
161
|
+
'supplies once paid (tickets, rooms, goods); type "deliver" is for work you check before paying (research, data, designs). ' +
|
|
162
|
+
'The service refuses sellers this key may not pay and amounts over its limits.',
|
|
163
|
+
inputSchema: {
|
|
164
|
+
purchase_id: z.string().describe('From start_purchase.'),
|
|
165
|
+
holds: z
|
|
166
|
+
.array(z.object({
|
|
167
|
+
seller: z.string().describe('The seller to pay, by name.'),
|
|
168
|
+
amount_usd: z.number().positive().describe('Amount in US dollars.'),
|
|
169
|
+
type: z.enum(['reserve', 'deliver']).default('reserve'),
|
|
170
|
+
note: z.string().max(200).default('').describe('What is being bought, in a few words.'),
|
|
171
|
+
}))
|
|
172
|
+
.min(1),
|
|
173
|
+
},
|
|
174
|
+
}, async ({ purchase_id, holds }) => {
|
|
175
|
+
try {
|
|
176
|
+
const intent = purchase(purchase_id);
|
|
177
|
+
// Placed in the same tick, so they go out together in one step.
|
|
178
|
+
const placed = await Promise.all(holds.map((h) => intent.hold(h.seller, { amount: cents(h.amount_usd), type: h.type, ref: h.note })));
|
|
179
|
+
return ok(`Held ${usd(placed.reduce((s, h) => s + h.amount, 0))} with ${placed.map((h) => `${h.seller} (#${h.index})`).join(', ')}. ` +
|
|
180
|
+
'Nothing is paid yet. Next: complete_purchase (or get_delivered_work first for "deliver" holds).');
|
|
181
|
+
}
|
|
182
|
+
catch (e) {
|
|
183
|
+
return refused(e);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
server.registerTool('get_delivered_work', {
|
|
187
|
+
title: 'Read delivered work',
|
|
188
|
+
description: 'For "deliver" holds: wait for the sellers to deliver, then show what each one delivered so you can check it. ' +
|
|
189
|
+
'Accept good work with accept_work and reject poor work with reject_work before completing the purchase.',
|
|
190
|
+
inputSchema: { purchase_id: z.string() },
|
|
191
|
+
annotations: { readOnlyHint: true },
|
|
192
|
+
}, async ({ purchase_id }) => {
|
|
193
|
+
try {
|
|
194
|
+
const results = await purchase(purchase_id).results();
|
|
195
|
+
if (results.length === 0)
|
|
196
|
+
return ok('No delivered work waiting for a decision.');
|
|
197
|
+
return ok(results.map((r) => `#${r.index} ${r.seller} (${usd(r.amount)}): ${r.result ?? '(empty)'}`).join('\n'));
|
|
198
|
+
}
|
|
199
|
+
catch (e) {
|
|
200
|
+
return refused(e);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
for (const [name, verb] of [
|
|
204
|
+
['accept_work', 'accept'],
|
|
205
|
+
['reject_work', 'reject'],
|
|
206
|
+
]) {
|
|
207
|
+
server.registerTool(name, {
|
|
208
|
+
title: verb === 'accept' ? 'Accept delivered work' : 'Reject delivered work',
|
|
209
|
+
description: verb === 'accept'
|
|
210
|
+
? 'Accept a seller\'s delivered work: that seller will be paid when the purchase is completed.'
|
|
211
|
+
: 'Reject a seller\'s delivered work: its held money goes back and that seller is not paid.',
|
|
212
|
+
inputSchema: { purchase_id: z.string(), hold_number: z.number().int().min(0).describe('The # shown by get_delivered_work.') },
|
|
213
|
+
}, async ({ purchase_id, hold_number }) => {
|
|
214
|
+
try {
|
|
215
|
+
const intent = purchase(purchase_id);
|
|
216
|
+
await (verb === 'accept' ? intent.accept(hold_number) : intent.reject(hold_number));
|
|
217
|
+
return ok(verb === 'accept' ? `Accepted #${hold_number}.` : `Rejected #${hold_number}; its money is back.`);
|
|
218
|
+
}
|
|
219
|
+
catch (e) {
|
|
220
|
+
return refused(e);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
server.registerTool('complete_purchase', {
|
|
225
|
+
title: 'Complete the purchase',
|
|
226
|
+
description: 'Wait for every seller to answer, then pay them in one step. In mode "all", if any seller declines or does not answer in ' +
|
|
227
|
+
'time, nobody is paid and every hold is released. Returns what was paid and a public record anyone can check.',
|
|
228
|
+
inputSchema: { purchase_id: z.string() },
|
|
229
|
+
}, async ({ purchase_id }) => {
|
|
230
|
+
try {
|
|
231
|
+
const r = await purchase(purchase_id).commit();
|
|
232
|
+
if (r.digest)
|
|
233
|
+
commits.set(purchase_id, r.digest);
|
|
234
|
+
const head = r.status === 'committed'
|
|
235
|
+
? `Completed: paid ${usd(r.paid)} in one step.`
|
|
236
|
+
: r.status === 'awaiting_approval'
|
|
237
|
+
? 'Waiting for a human approval; nothing was paid.'
|
|
238
|
+
: `Not completed (${r.status}): ${r.reason ?? ''}. Every hold was released; nobody was paid.`;
|
|
239
|
+
return ok(`${head}\n${describe(r.intent)}`);
|
|
240
|
+
}
|
|
241
|
+
catch (e) {
|
|
242
|
+
return refused(e);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
server.registerTool('cancel_purchase', {
|
|
246
|
+
title: 'Cancel the purchase',
|
|
247
|
+
description: 'Call the purchase off. Every held dollar goes back and nobody is paid.',
|
|
248
|
+
inputSchema: { purchase_id: z.string() },
|
|
249
|
+
}, async ({ purchase_id }) => {
|
|
250
|
+
try {
|
|
251
|
+
const r = await purchase(purchase_id).abort();
|
|
252
|
+
return ok(`Cancelled: every hold released, nobody paid.\n${describe(r.intent)}`);
|
|
253
|
+
}
|
|
254
|
+
catch (e) {
|
|
255
|
+
// Nothing was ever held (e.g. the holds were refused): nothing to release.
|
|
256
|
+
if (e.code === 'not_opened' || e.code === 'no_holds') {
|
|
257
|
+
purchases.delete(purchase_id);
|
|
258
|
+
return ok('Cancelled: nothing was held for this purchase, so nothing needed releasing. Nobody was paid.');
|
|
259
|
+
}
|
|
260
|
+
return refused(e);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
// === x402 sellers: web resources that ask for payment (HTTP 402) ===
|
|
264
|
+
server.registerTool('quote_x402_url', {
|
|
265
|
+
title: 'Price a paid web resource',
|
|
266
|
+
description: `Asks a URL that charges per request (x402) what it costs, without paying. If it accepts ${PRODUCT_NAME} payments, returns ` +
|
|
267
|
+
'the seller name and price to use with place_holds, so it can be bought in one step together with other sellers. ' +
|
|
268
|
+
`If it does not accept ${PRODUCT_NAME} payments, nothing is paid and you should tell the user.`,
|
|
269
|
+
inputSchema: { url: z.string().url().describe('The paid URL.') },
|
|
270
|
+
annotations: { readOnlyHint: true },
|
|
271
|
+
}, async ({ url }) => {
|
|
272
|
+
try {
|
|
273
|
+
const offer = await x402.quote(url);
|
|
274
|
+
if (!offer)
|
|
275
|
+
return ok(`${url} did not ask for payment: no purchase needed.`);
|
|
276
|
+
offers.set(url, offer);
|
|
277
|
+
const lines = offer.holds.map((h) => ` seller "${h.seller}", amount_usd ${(h.cents / 100).toFixed(2)}`);
|
|
278
|
+
return ok([`${url} costs ${usd(offer.cents)}. To buy it, start_purchase, then place_holds with:`, ...lines, 'then complete_purchase, then fetch_x402_resource.'].join('\n'));
|
|
279
|
+
}
|
|
280
|
+
catch (e) {
|
|
281
|
+
return refused(e);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
server.registerTool('fetch_x402_resource', {
|
|
285
|
+
title: 'Fetch a paid web resource',
|
|
286
|
+
description: 'After complete_purchase paid for a URL priced with quote_x402_url, fetches it with the proof of payment and returns what it sent back.',
|
|
287
|
+
inputSchema: { purchase_id: z.string(), url: z.string().url() },
|
|
288
|
+
}, async ({ purchase_id, url }) => {
|
|
289
|
+
try {
|
|
290
|
+
const offer = offers.get(url);
|
|
291
|
+
if (!offer)
|
|
292
|
+
return ok(`Price ${url} with quote_x402_url first.`);
|
|
293
|
+
const intent = purchase(purchase_id);
|
|
294
|
+
const digest = commits.get(purchase_id);
|
|
295
|
+
if (!digest)
|
|
296
|
+
return ok('That purchase has not been completed and paid yet.');
|
|
297
|
+
const state = await intent.state();
|
|
298
|
+
const indexes = offer.holds.map((h) => state.holds.find((x) => x.seller === h.seller && x.state === 'paid')?.index);
|
|
299
|
+
if (indexes.some((i) => i === undefined))
|
|
300
|
+
return ok(`That purchase did not pay ${url}'s seller.`);
|
|
301
|
+
// Sign the proof with the key that paid (never a key from the working folder).
|
|
302
|
+
const res = await x402.fetchPaid(offer, intent.id, digest, indexes, {}, { key: KEY });
|
|
303
|
+
const text = (await res.text()).slice(0, 4000);
|
|
304
|
+
return res.ok ? ok(`HTTP ${res.status}\n${text}`) : { isError: true, content: [{ type: 'text', text: `The seller refused the proof (HTTP ${res.status}).\n${text}` }] };
|
|
305
|
+
}
|
|
306
|
+
catch (e) {
|
|
307
|
+
return refused(e);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
await server.connect(new StdioServerTransport());
|
|
311
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +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,CAAC,KAAK,EAAE,MAAM,CAAC,EAAG,EAAE,MAAM,EAAE,OAAmB,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QACnG,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAC/C,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,GAAG,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,sCAAsC,GAAG,CAAC,MAAM,OAAO,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;IACnL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACH,CAAC,CACF,CAAC;AAEF,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC"}
|
package/dist/settings.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// The agent key and the service it belongs to, read from one source, so a .env in
|
|
2
|
+
// the client's working folder never points a key file's key at another service.
|
|
3
|
+
// Never reads the owner token.
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
import { DEFAULT_URL } from '@getaccord/sdk';
|
|
6
|
+
const unquote = (v) => v.trim().replace(/^["']|["']$/g, '');
|
|
7
|
+
const lineOf = (text, name) => {
|
|
8
|
+
const line = text.split('\n').find((l) => l.startsWith(`${name}=`));
|
|
9
|
+
return line ? unquote(line.slice(name.length + 1)) || undefined : undefined;
|
|
10
|
+
};
|
|
11
|
+
/** The key and its service, both from one source. */
|
|
12
|
+
export function loadSettings(env = process.env, read = (f) => readFileSync(f, 'utf8')) {
|
|
13
|
+
const url = (fromFile) => env.ACCORD_URL || fromFile || DEFAULT_URL;
|
|
14
|
+
if (env.ACCORD_AGENT_KEY)
|
|
15
|
+
return { key: env.ACCORD_AGENT_KEY.trim(), url: url() };
|
|
16
|
+
if (env.ACCORD_KEY_FILE) {
|
|
17
|
+
const text = read(env.ACCORD_KEY_FILE);
|
|
18
|
+
return { key: lineOf(text, 'ACCORD_AGENT_KEY') ?? unquote(text), url: url(lineOf(text, 'ACCORD_URL')) };
|
|
19
|
+
}
|
|
20
|
+
let text = '';
|
|
21
|
+
try {
|
|
22
|
+
text = read('.env');
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// no .env in the working directory
|
|
26
|
+
}
|
|
27
|
+
const key = lineOf(text, 'ACCORD_AGENT_KEY');
|
|
28
|
+
if (key)
|
|
29
|
+
return { key, url: url(lineOf(text, 'ACCORD_URL')) };
|
|
30
|
+
throw new Error('No agent key: set ACCORD_AGENT_KEY or ACCORD_KEY_FILE (run `npx @getaccord/cli init`).');
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,gFAAgF;AAChF,+BAA+B;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;AACpE,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE;IAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,IAA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AC,CAAC,EAAE,CAAC;IAC9D,MAAM,IAAI,KAAK,CAAC,wFAAwF,CAAC,CAAC;AAC5G,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getaccord/mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "Accord MCP server: lets Claude Code, Claude Desktop, Cursor or any MCP client pay sellers through Accord as tools, under the agent key's limits. Test mode.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"mcp",
|
|
9
|
+
"agents",
|
|
10
|
+
"payments",
|
|
11
|
+
"atomic",
|
|
12
|
+
"x402"
|
|
13
|
+
],
|
|
14
|
+
"bin": {
|
|
15
|
+
"accord-mcp": "dist/server.js"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"accord-source": "./src/server.ts",
|
|
20
|
+
"default": "./dist/server.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=20"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && chmod +x dist/server.js"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@getaccord/sdk": "^0.5.0",
|
|
39
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
40
|
+
"zod": "^4.6.7"
|
|
41
|
+
}
|
|
42
|
+
}
|