@apiosk/mcp 1.3.1 → 2.0.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.
Files changed (92) hide show
  1. package/README.md +84 -537
  2. package/assets/brand/apiosk-a-20260921.png +0 -0
  3. package/assets/brand/apple-touch-icon.png +0 -0
  4. package/assets/brand/favicon-dark.ico +0 -0
  5. package/assets/brand/favicon-light.ico +0 -0
  6. package/assets/brand/favicon.ico +0 -0
  7. package/assets/brand/icon-192.png +0 -0
  8. package/assets/brand/icon-512.png +0 -0
  9. package/assets/brand/icon-maskable-512.png +0 -0
  10. package/assets/brand/inter-OFL.txt +93 -0
  11. package/assets/brand/inter-latin-400-normal.woff2 +0 -0
  12. package/assets/brand/inter-latin-500-normal.woff2 +0 -0
  13. package/assets/brand/inter-latin-600-normal.woff2 +0 -0
  14. package/assets/brand/mark-20260905-transparent.svg +1 -0
  15. package/assets/brand/mark-20260918.svg +1 -0
  16. package/assets/brand/mark-black-20260918.svg +1 -0
  17. package/assets/brand/mark-dark-20260905-transparent.png +0 -0
  18. package/assets/brand/mark-dark-20260918.png +0 -0
  19. package/assets/brand/mark-dark-96.png +0 -0
  20. package/assets/brand/mark-light-20260905-transparent.png +0 -0
  21. package/assets/brand/mark-light-20260918.png +0 -0
  22. package/assets/brand/mark-light-96.png +0 -0
  23. package/assets/brand/wordmark-black-320.png +0 -0
  24. package/assets/brand/wordmark-white-320.png +0 -0
  25. package/docs/branding.md +11 -0
  26. package/docs/marketplace-submission-2026-04-08.md +4 -0
  27. package/docs/marketplace-submission-2026-08-20.md +157 -0
  28. package/docs/openai-plugin-submission-2026-09-05.md +143 -0
  29. package/docs/sepa-rail.md +13 -13
  30. package/dxt.json +26 -22
  31. package/index.mjs +3 -1
  32. package/logo-optimized-light.png +0 -0
  33. package/package.json +15 -13
  34. package/plugin/apiosk/.codex-plugin/plugin.json +45 -0
  35. package/plugin/apiosk/.mcp.json +8 -0
  36. package/plugin/apiosk/assets/icon-dark.png +0 -0
  37. package/plugin/apiosk/assets/icon.png +0 -0
  38. package/plugin/apiosk/assets/icon.svg +1 -0
  39. package/plugin/apiosk/assets/logo.png +0 -0
  40. package/plugin/apiosk/skills/apiosk/SKILL.md +33 -0
  41. package/plugin/apiosk/skills/apiosk/agents/openai.yaml +12 -0
  42. package/server.json +98 -9
  43. package/server.mjs +258 -71
  44. package/src/approval-feedback.mjs +21 -0
  45. package/src/brand-routes.mjs +28 -0
  46. package/src/create-server.mjs +168 -9
  47. package/src/display-money.mjs +20 -0
  48. package/src/display-text.mjs +67 -0
  49. package/src/gateway-client.mjs +42 -0
  50. package/src/gateway-v2-ask.mjs +50 -0
  51. package/src/gateway-v2-card-account.mjs +23 -0
  52. package/src/gateway-v2-card-actions.mjs +67 -0
  53. package/src/gateway-v2-card-answer-text.mjs +130 -0
  54. package/src/gateway-v2-card-answer.mjs +68 -0
  55. package/src/gateway-v2-card-blocks.mjs +166 -0
  56. package/src/gateway-v2-card-body.mjs +259 -0
  57. package/src/gateway-v2-card-budget.mjs +21 -0
  58. package/src/gateway-v2-card-cbs.mjs +56 -0
  59. package/src/gateway-v2-card-choices.mjs +4 -0
  60. package/src/gateway-v2-card-clarification.mjs +25 -0
  61. package/src/gateway-v2-card-compact.mjs +34 -0
  62. package/src/gateway-v2-card-events.mjs +41 -0
  63. package/src/gateway-v2-card-presentation.mjs +125 -0
  64. package/src/gateway-v2-card-research.mjs +63 -0
  65. package/src/gateway-v2-card-result.mjs +32 -0
  66. package/src/gateway-v2-card-search.mjs +39 -0
  67. package/src/gateway-v2-card-sources.mjs +32 -0
  68. package/src/gateway-v2-card-style.mjs +76 -0
  69. package/src/gateway-v2-card-verdict.mjs +66 -0
  70. package/src/gateway-v2-card.mjs +91 -0
  71. package/src/gateway-v2-contracts.json +66 -0
  72. package/src/gateway-v2-instructions.md +113 -0
  73. package/src/gateway-v2-recovery.mjs +18 -0
  74. package/src/gateway-v2-report-links.mjs +14 -0
  75. package/src/gateway-v2-workflows.mjs +17 -0
  76. package/src/gateway-v2.mjs +179 -0
  77. package/src/oauth.mjs +603 -364
  78. package/src/observability.mjs +210 -0
  79. package/src/result-presentation.mjs +9 -0
  80. package/src/runtime.mjs +24 -3091
  81. package/src/settlement-disclosure.mjs +26 -0
  82. package/src/source-groups.mjs +91 -0
  83. package/src/source-value-format.mjs +25 -0
  84. package/src/tool-result.mjs +20 -0
  85. package/src/ui-bridge.mjs +185 -0
  86. package/src/well-known-routes.mjs +132 -0
  87. package/src/funding-options.mjs +0 -255
  88. package/src/gateway-management.mjs +0 -107
  89. package/src/listing-metadata.mjs +0 -287
  90. package/src/local-config.mjs +0 -256
  91. package/src/payment-guidance.mjs +0 -307
  92. package/src/wallet-store.mjs +0 -476
package/README.md CHANGED
@@ -1,143 +1,103 @@
1
+ <!-- mcp-name: io.github.obcraft/apiosk-mcp -->
1
2
  <p align="center">
2
3
  <img src="https://apiosk.com/logo.svg" alt="Apiosk" width="120" />
3
4
  </p>
4
5
 
5
6
  # Apiosk MCP Server
6
7
 
7
- **AI-native payments for tools and APIs.** Discover, pay for, execute, and publish monetized APIs directly from your agent — over USDC/x402 or prepaid credits — through the Model Context Protocol.
8
+ [![smithery badge](https://smithery.ai/badge/olivier-fovn/apiosk)](https://smithery.ai/servers/olivier-fovn/apiosk)
8
9
 
9
- `payments` · `finance` · `x402` · `commerce` · `crypto`
10
+ **Verifiable data for your chatbot.** Ask a data question, review one plan and
11
+ one total price ceiling, approve it within your connected account's spending
12
+ limits, and receive source-backed results. Resume without buying the same work
13
+ twice.
10
14
 
11
15
  [![MCP Registry](https://img.shields.io/badge/MCP_Registry-io.github.obcraft%2Fapiosk--mcp-2ea44f)](https://registry.modelcontextprotocol.io)
12
16
  [![npm](https://img.shields.io/npm/v/@apiosk/mcp?label=npm%20%40apiosk%2Fmcp)](https://www.npmjs.com/package/@apiosk/mcp)
13
17
  [![PyPI](https://img.shields.io/pypi/v/apiosk-mcp?label=PyPI%20apiosk-mcp)](https://pypi.org/project/apiosk-mcp/)
14
18
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](#license)
15
19
 
16
- Official MCP server for discovering, paying for, and publishing Apiosk APIs.
20
+ - **Hosted endpoint:** `https://mcp.apiosk.com/mcp` (streamable HTTP; the host signs in with OAuth when it connects).
21
+ - **Local stdio package:** `npx -y @apiosk/mcp` or `uvx apiosk-mcp`.
22
+ - **Apiosk app:** [app.apiosk.com](https://app.apiosk.com) — connections, spending limits, balance and approvals.
17
23
 
18
- - **Listed in the [official MCP Registry](https://registry.modelcontextprotocol.io)** as `io.github.obcraft/apiosk-mcp`.
19
- - **Hosted endpoint:** `https://mcp.apiosk.com/mcp` (streamable HTTP, OAuth-protected for paid tools).
20
- - **Local stdio package:** `npx -y @apiosk/mcp` or `uvx apiosk-mcp` for wallet + publish tools.
24
+ ## 2.0: one runtime, Gateway v2
21
25
 
22
- ## Quick Start
26
+ Every tool speaks the Gateway v2 agent contract at `https://gateway.apiosk.com`,
27
+ for the hosted server and for stdio alike. The eleven 1.x tools (the one-shot
28
+ offer, compare, plan and job tools) called the agent gateway's `/v1/ask`,
29
+ `/v1/select`, `/v1/run`, `/v1/plans` and `/v1/jobs` routes, which now answer
30
+ `410 moved_to_gateway_v2`. Sign-in still goes through the agent gateway's OAuth
31
+ endpoints.
23
32
 
24
- ### Package names
33
+ ## The tools
25
34
 
26
- The scoped npm package is the canonical client SDK package:
35
+ | Tool | What it does | Gateway v2 route | Spends |
36
+ | --- | --- | --- | --- |
37
+ | `apiosk_sources` | Browse published data sources by name, category, sector, tag or capability. Paginated with `next_offset`. | `GET /v2/sources` | no |
38
+ | `apiosk_discover` | Plan a NEW data question: one plan with `proposal.max_total_atomic` as the total price ceiling, or the clarification it needs. A fixed company or tender dossier can be started with `workflow` instead of `question`. | `POST /v2/discover`, `POST /v2/workflows/{slug}/start` | no |
39
+ | `apiosk_search` | Search sources the way the Ask page does, with a `parsed_request` capability object the chatbot fills in itself (the Ask parser's schema). Returns ranked sources per capability; each runnable candidate carries `endpoint.inputs`, the exact input keys for `apiosk_prepare`. | `POST /v2/ask-v2/search` | no |
40
+ | `apiosk_prepare` | Prepare one searched endpoint with its filled-in `input`: the same task, price ceiling and approval card as `apiosk_discover`. | `POST /v2/ask-v2/prepare` | no |
41
+ | `apiosk_execute` | Continue the same task with a returned `next_actions` entry: supply input, select an entity, run an approved step, cancel. | `POST /v2/execute` | only an approved step |
42
+ | `apiosk_status` | Read a task's saved results, actual charges and status. Free and read-only; used for follow-ups and recovery. | `GET /v2/tasks/{id}` | no |
43
+ | `apiosk_approve` | **App-only.** Called by the interactive card when the person clicks Approve; approves that exact ceiling within the connection's spending limits and starts server execution. Never invoked by the model. | `POST /v2/approve` | yes, within the approved ceiling |
27
44
 
28
- ```bash
29
- npm install @apiosk/mcp
30
- ```
45
+ ### Approval
31
46
 
32
- It exposes the same CLI binaries as the legacy package:
47
+ The task's `context_view.approval_mode` decides where a person approves:
33
48
 
34
- ```bash
35
- npx -y @apiosk/mcp
36
- apiosk-mcp
37
- apiosk-mcp-server
38
- apiosk
39
- ```
49
+ - `chatbot` — the interactive card shows the plan and total and an **Approve**
50
+ button. One click approves the whole request within the connected account's
51
+ spending limits; the server then runs every step and streams the result into
52
+ the card (`context_view.events_url`).
53
+ - `app` — the person approves at `proposal.approval_url` in the Apiosk app. The
54
+ server continues automatically after approval; read progress with
55
+ `apiosk_status`.
40
56
 
41
- The previous public package name, `apiosk-mcp-server`, remains supported as a
42
- compatibility install path for existing MCP client configs.
57
+ A chat message, a tool permission or `approved: true` is never an approval.
58
+ Loading a card or recovering a task never approves or buys.
43
59
 
44
- For MCP registry submission forms, use:
60
+ ### Recovery
45
61
 
46
- - npm Package: `@apiosk/mcp`
47
- - PyPI Package: `apiosk-mcp`
48
- - Short Description: `Discover, pay for, execute, and publish Apiosk APIs through MCP.`
62
+ Every response carries `state.state_ref`. If state is lost or a response was
63
+ interrupted, call `apiosk_status` with `{"task_ref": "<state_ref>"}`. It reads
64
+ only; it never parses, approves or buys.
49
65
 
50
- The PyPI package is a launcher for the canonical npm package, so `uvx
51
- apiosk-mcp` starts the same MCP server as `npx -y @apiosk/mcp`.
66
+ The complete host contract the tools follow is served as the MCP resource
67
+ `apiosk://v2/host-contract` and in the server instructions.
52
68
 
53
- ### Local stdio package
69
+ ## Quick start
54
70
 
55
71
  ```bash
56
72
  npx -y @apiosk/mcp
57
73
  ```
58
74
 
59
- Python/uv users can install through PyPI:
60
-
61
- ```bash
62
- uvx apiosk-mcp
63
- ```
64
-
65
- The PyPI launcher requires Node.js 20+ and `npx` on `PATH`. By default it runs
66
- `npx -y @apiosk/mcp@1.3.1`; set `APIOSK_MCP_NPM_PACKAGE=@apiosk/mcp@next` to
67
- override the npm package spec.
68
-
69
- ### Publishing packages
70
-
71
- From this `mcp/` directory:
72
-
73
- ```bash
74
- npm run pack:check
75
- npm publish --access public
76
- ```
77
-
78
- ```bash
79
- python3 -m pip install --upgrade build twine
80
- python3 -m build
81
- python3 -m twine upload dist/apiosk_mcp-1.3.1*
82
- ```
83
-
84
- After both uploads are live, the MCP registry package fields are:
85
-
86
- ```text
87
- npm Package: @apiosk/mcp
88
- PyPI Package: apiosk-mcp
89
- Short Description: Discover, pay for, execute, and publish Apiosk APIs through MCP.
90
- ```
75
+ The PyPI package is a launcher for it, so `uvx apiosk-mcp` starts the same
76
+ server. Both expose the same CLI binaries: `apiosk-mcp`, `apiosk-mcp-server`
77
+ and `apiosk`.
91
78
 
92
- ### With automatic x402 payments from an env wallet
79
+ For stdio, set `APIOSK_CONNECT_TOKEN` to an Apiosk agent token
80
+ (`apk_access_…` from a connection made in the Apiosk app, or a legacy
81
+ `apk_live_…` agent key). Every tool acts for that connected account; without a
82
+ token the tools answer `unauthorized`. The hosted server uses OAuth instead.
93
83
 
94
- ```bash
95
- APIOSK_PRIVATE_KEY=0x... npx -y @apiosk/mcp
96
- ```
84
+ ## Agent configuration
97
85
 
98
- ### With dashboard-managed access
86
+ ### Claude Code
99
87
 
100
88
  ```bash
101
- APIOSK_CONNECT_TOKEN=... npx -y @apiosk/mcp
102
- ```
103
-
104
- After the MCP server is installed in Claude, Codex, or another client, the fastest first-run path in local stdio mode is:
105
-
106
- ```json
107
- { "wallet_label": "My Apiosk wallet" }
89
+ claude mcp add --transport http apiosk https://mcp.apiosk.com/mcp
108
90
  ```
109
91
 
110
- Call that through `apiosk_get_started`. It will create a local wallet when needed, or you can pass `connect_string` to save managed access locally and immediately run a discovery probe plus a small test call.
111
-
112
- ## Local Wallet Mode
113
-
114
- The local stdio package exposes wallet tools that let Claude or Codex:
115
-
116
- - create or import a wallet
117
- - show the wallet address
118
- - select the active wallet used for paid calls
119
- - reveal or save the private key when the user explicitly asks
120
- - publish and manage APIs without opening the dashboard
121
-
122
- The active wallet is mirrored to:
123
-
124
- - `~/.apiosk/wallet.json`
125
- - `~/.apiosk/wallet.txt`
126
-
127
- so older Apiosk scripts can reuse it.
128
-
129
- ## Agent Configuration
130
-
131
- ### Claude Desktop
132
-
133
- Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
92
+ ### Claude Desktop, Cursor, Windsurf, Cline, Continue, Goose
134
93
 
135
94
  ```json
136
95
  {
137
96
  "mcpServers": {
138
97
  "apiosk": {
139
98
  "command": "npx",
140
- "args": ["-y", "@apiosk/mcp"]
99
+ "args": ["-y", "@apiosk/mcp"],
100
+ "env": { "APIOSK_CONNECT_TOKEN": "apk_access_…" }
141
101
  }
142
102
  }
143
103
  }
@@ -145,27 +105,6 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
145
105
 
146
106
  ### VS Code
147
107
 
148
- Add the server with the CLI:
149
-
150
- ```bash
151
- code --add-mcp '{"name":"apiosk","command":"npx","args":["-y","@apiosk/mcp"]}'
152
- ```
153
-
154
- Or create `.vscode/mcp.json` in your workspace (VS Code uses a `servers` key):
155
-
156
- ```json
157
- {
158
- "servers": {
159
- "apiosk": {
160
- "command": "npx",
161
- "args": ["-y", "@apiosk/mcp"]
162
- }
163
- }
164
- }
165
- ```
166
-
167
- To use the hosted endpoint instead of the local package:
168
-
169
108
  ```json
170
109
  {
171
110
  "servers": {
@@ -177,464 +116,72 @@ To use the hosted endpoint instead of the local package:
177
116
  }
178
117
  ```
179
118
 
180
- ### Cursor
181
-
182
- ```json
183
- {
184
- "mcpServers": {
185
- "apiosk": {
186
- "command": "npx",
187
- "args": ["-y", "@apiosk/mcp"]
188
- }
189
- }
190
- }
191
- ```
192
-
193
- ### Windsurf
194
-
195
- ```json
196
- {
197
- "mcpServers": {
198
- "apiosk": {
199
- "command": "npx",
200
- "args": ["-y", "@apiosk/mcp"]
201
- }
202
- }
203
- }
204
- ```
205
-
206
- ### Claude Code
207
-
208
- Remote HTTP:
209
-
210
- ```bash
211
- claude mcp add --transport http apiosk https://mcp.apiosk.com/mcp
212
- ```
213
-
214
- Local stdio:
215
-
216
- ```json
217
- {
218
- "mcpServers": {
219
- "apiosk": {
220
- "command": "npx",
221
- "args": ["-y", "@apiosk/mcp"]
222
- }
223
- }
224
- }
225
- ```
226
-
227
- ### Cline / Continue / Goose
228
-
229
- ```json
230
- {
231
- "mcpServers": {
232
- "apiosk": {
233
- "command": "npx",
234
- "args": ["-y", "@apiosk/mcp"]
235
- }
236
- }
237
- }
238
- ```
239
-
240
- ### Using a local checkout
241
-
242
- ```json
243
- {
244
- "mcpServers": {
245
- "apiosk": {
246
- "command": "node",
247
- "args": ["/full/path/to/apiosk-mcp/index.mjs"]
248
- }
249
- }
250
- }
251
- ```
252
-
253
119
  ### ChatGPT and other remote MCP apps
254
120
 
255
- Use the hosted MCP endpoint:
256
-
257
- ```text
258
- https://mcp.apiosk.com/mcp
259
- ```
260
-
261
- Protected tools on the hosted server use OAuth. The remote MCP surface is fully
262
- capable — discovery, payment guidance, generic **and** dynamic per-API
263
- execution, prepaid credits, and managed agent-wallet CRUD. Public tools
264
- (discovery + guidance) work before authorization; paid execution and managed
265
- tools require OAuth. Publishing stays local/portal-only because it needs a
266
- client-side signing key the hosted server never holds.
267
-
268
- ## Provider MCP Monetization
269
-
270
- If you own an MCP server and want to sell its tools through Apiosk, keep payment
271
- logic out of your MCP. Apiosk is the paid edge.
272
-
273
- Provider requirements:
121
+ Use `https://mcp.apiosk.com/mcp`. The host starts OAuth when it connects;
122
+ sign-in and spending limits live in the Apiosk app.
274
123
 
275
- - Host your MCP over HTTPS, for example `https://tools.example.com/mcp`.
276
- - Support normal MCP `initialize`, `tools/list`, and `tools/call`.
277
- - Keep tool names stable; imported tools become paid operation ids.
278
- - Provide useful descriptions and JSON schemas; these become buyer-facing
279
- discovery metadata.
280
- - Protect the provider MCP with bearer auth or another upstream secret, then
281
- configure Apiosk to inject that secret so buyers cannot bypass the gateway.
282
-
283
- Provider portal flow:
284
-
285
- 1. Open the provider portal and choose `Import MCP`.
286
- 2. Enter the MCP URL and optional bearer token.
287
- 3. Apiosk scans `tools/list` and creates one paid action per selected tool.
288
- 4. Review tool paths, schemas, descriptions, and per-call prices.
289
- 5. Publish the draft after linking a payout wallet.
290
-
291
- Buyer-facing surfaces after publish:
292
-
293
- - Hosted Apiosk MCP: `https://mcp.apiosk.com/mcp`
294
- - Catalog search: `https://gateway.apiosk.com/v1/apis?search=<slug>`
295
- - Metadata: `GET https://gateway.apiosk.com/<slug>/metadata`
296
- - Execution: `POST https://gateway.apiosk.com/<slug>/execute`
297
-
298
- The traffic path is:
299
-
300
- ```text
301
- buyer agent -> Apiosk MCP/gateway -> payment rail -> provider MCP tools/call
302
- ```
303
-
304
- The provider MCP should reject direct unauthenticated traffic, but it should not
305
- return `402 Payment Required` or inspect `X-Payment`. Payment challenges,
306
- credits, x402 proof verification, and revenue splits are handled by Apiosk.
307
-
308
- ## Available Tools
309
-
310
- Static tools:
311
-
312
- - `apiosk_help`
313
- - `apiosk_payment_guide` — buyer + provider guide for paying through and publishing on the gateway
314
- - `apiosk_explore`
315
- - `apiosk_search`
316
- - `apiosk_get_api`
317
- - `apiosk_execute`
318
-
319
- Hosted remote MCP tools (in addition to dynamic per-API tools):
320
-
321
- - Discovery / guidance: `apiosk_help`, `apiosk_payment_guide`, `apiosk_search`, `apiosk_explore`, `apiosk_get_api`, `apiosk_metadata`, `apiosk_execute`, `apiosk_health`
322
- - Prepaid credits: `apiosk_buy_credits`, `apiosk_get_credits_status`
323
- - Managed wallets: `apiosk_list_wallets`, `apiosk_create_wallet`, `apiosk_update_wallet`, `apiosk_delete_wallet`, `apiosk_get_wallet_activity`, `apiosk_create_wallet_connect_string`, `apiosk_list_wallet_api_keys`, `apiosk_create_wallet_api_key`, `apiosk_update_wallet_api_key`, `apiosk_delete_wallet_api_key`
324
-
325
- Local wallet tools in stdio mode:
326
-
327
- - `apiosk_get_started`
328
- - `apiosk_wallet_list`
329
- - `apiosk_wallet_create`
330
- - `apiosk_configure`
331
- - `apiosk_wallet_select`
332
- - `apiosk_wallet_update`
333
- - `apiosk_wallet_delete`
334
- - `apiosk_wallet_reveal_secret`
335
- - `apiosk_wallet_save_secret`
336
-
337
- Publish tools in stdio mode:
338
-
339
- - `apiosk_publish_api`
340
- - `apiosk_list_my_apis`
341
- - `apiosk_update_api`
342
- - `apiosk_delete_api`
343
-
344
- Optional dashboard-managed wallet tools:
345
-
346
- - `apiosk_list_wallets`
347
- - `apiosk_create_wallet`
348
- - `apiosk_update_wallet`
349
- - `apiosk_delete_wallet`
350
- - `apiosk_get_wallet_activity`
351
- - `apiosk_create_wallet_connect_string`
352
- - `apiosk_list_wallet_api_keys`
353
- - `apiosk_create_wallet_api_key`
354
- - `apiosk_update_wallet_api_key`
355
- - `apiosk_delete_wallet_api_key`
356
-
357
- Dynamic tools:
358
-
359
- - local stdio mode still generates one dynamic tool per active Apiosk API slug from listing metadata
124
+ The OpenAI plugin package lives in `plugin/apiosk`. It combines this MCP server
125
+ with the `apiosk` skill (`plugin/apiosk/skills/apiosk`).
360
126
 
361
127
  ## Examples
362
128
 
363
- ### Explore
364
-
365
- ```json
366
- {}
367
- ```
368
-
369
- ```json
370
- { "listing_type": "dataset", "search": "weather", "limit": 5 }
371
- ```
372
-
373
- ### Search
374
-
375
- ```json
376
- { "search": "diff", "limit": 5 }
377
- ```
378
-
379
- Search, explore, and `apiosk_get_api` responses now embed a `payment` block that
380
- tells the agent exactly how to settle a paid call given the current auth — so an
381
- agent that finds, say, a weather API immediately knows whether it can pay and
382
- what to do next.
383
-
384
- ### Payment guide (buyer + provider)
385
-
386
- ```json
387
- {}
388
- ```
389
-
390
- ```json
391
- { "role": "provider" }
392
- ```
393
-
394
- ```json
395
- { "role": "buyer", "slug": "weather-now" }
396
- ```
397
-
398
- Returns a buyer guide (USDC/x402 or credits — tailored to the configured auth)
399
- and a provider guide (how to publish an API and get paid). Pass `slug` to scope
400
- buyer guidance to one listing, or `role` to pick a side.
401
-
402
- ### Create a local wallet
403
-
404
- ```json
405
- { "label": "Claude wallet" }
406
- ```
407
-
408
- The create response includes:
409
-
410
- - the wallet address
411
- - Base funding instructions
412
- - a QR image URL
413
- - a terminal QR block when QR rendering is enabled
414
- - a structured Apiosk control menu with wallet, funding, pay, publish, security, and local-data sections
415
-
416
- ### Get started in one step
417
-
418
- Create a local wallet automatically, discover the catalog, and run a test call:
419
-
420
- ```json
421
- {
422
- "wallet_label": "Starter wallet",
423
- "test_slug": "agent-json-diff",
424
- "test_input": {
425
- "before": { "ok": true },
426
- "after": { "ok": false }
427
- }
428
- }
429
- ```
430
-
431
- Or save a dashboard-managed connect string locally and verify it:
432
-
433
- ```json
434
- {
435
- "connect_string": "export APIO_GATEWAY_URL=https://gateway.apiosk.com\nexport APIO_CHAIN_ID=8453\nexport APIO_AGENT_WALLET_ADDRESS=0x...\nexport APIO_CONNECT_TOKEN=aw_...\nexport APIO_CONNECT_AUTHORIZATION=Bearer aw_...\nexport APIO_CONNECT_HEADER_NAME=X-Apiosk-Connect-Token",
436
- "test_slug": "agent-json-diff",
437
- "test_input": {
438
- "before": { "ok": true },
439
- "after": { "ok": false }
440
- },
441
- "create_wallet": false
442
- }
443
- ```
444
-
445
- The connect string identifies the buyer's managed wallet and connect token. The
446
- `APIO_WALLET_*` limits bound the USDC (x402) rail. The same connect token also
447
- settles over prepaid credits when USDC is unavailable — the gateway picks the
448
- rail per call. Call `apiosk_help` with `topic="rails"` for the full settlement
449
- model.
450
-
451
- ### Open the configure menu
452
-
453
129
  ```json
454
- { "section": "funding" }
130
+ { "name": "apiosk_sources", "arguments": { "capability": "eu.company.profile" } }
455
131
  ```
456
132
 
457
133
  ```json
458
- { "wallet_id": "...", "section": "funding", "funding_provider": "onramper" }
459
- ```
460
-
461
- ### Save a secret key backup
462
-
463
- ```json
464
- { "wallet_id": "..." }
465
- ```
466
-
467
- ### Publish an API
468
-
469
- ```json
470
- {
471
- "name": "My Weather API",
472
- "slug": "my-weather-api",
473
- "endpoint_url": "https://example.com",
474
- "price_usd": 0.01,
475
- "description": "Real-time weather data",
476
- "listing_group": "datasets"
477
- }
134
+ { "name": "apiosk_discover", "arguments": { "question": "Latest filed annual accounts for Mollie B.V. from KVK" } }
478
135
  ```
479
136
 
480
- ### Generic execute
481
-
482
137
  ```json
483
- {
484
- "slug": "agent-json-diff",
485
- "input": {
486
- "before": { "ok": true },
487
- "after": { "ok": false }
488
- }
489
- }
138
+ { "name": "apiosk_execute", "arguments": { "action_id": "<next_actions[].action_id>", "state": { "…": "the newest state, unchanged" }, "input": { "value": "…" } } }
490
139
  ```
491
140
 
492
- ### Dynamic tool call (local stdio only)
493
-
494
- If the server lists a dynamic tool named `agent-json-diff`, call it directly:
495
-
496
141
  ```json
497
- {
498
- "before": { "ok": true },
499
- "after": { "ok": false }
500
- }
501
- ```
502
-
503
- ## MacBook Air Test Script
504
-
505
- Run the safe default suite from a repo checkout:
506
-
507
- ```bash
508
- cd /Users/olivierbrinkman/Development/Apiosk/subs/mcp
509
- npm run test:macbook-air
510
- ```
511
-
512
- Default coverage:
513
-
514
- - runs `npm test`
515
- - runs the isolated fresh-environment smoke test
516
- - starts a local HTTP MCP server in a temp `APIOSK_HOME`
517
- - verifies `health`, `tools/list`, `apiosk_search`, `apiosk_explore`, and `apiosk_get_api`
518
- - creates a wallet, checks funding QR/configure output, and verifies secret export plus `wallet.json` and `wallet.txt`
519
- - verifies the hosted Fly deployment, OAuth metadata, protected-resource metadata, public discovery, and the unauthenticated OAuth challenge for protected tools
520
-
521
- Useful options:
522
-
523
- - `TARGET=local` to skip hosted checks
524
- - `TARGET=hosted` to skip local checks
525
- - `APIOSK_RUN_REMOTE_WALLET_TEST=1 APIOSK_MCP_BEARER_TOKEN=...` to verify an authenticated protected hosted call after the unauthenticated challenge check
526
- - `APIOSK_RUN_FUNDED_TESTS=1 APIOSK_TEST_PRIVATE_KEY=0x...` to import a funded wallet and run a real paid execute test
527
- - `APIOSK_RUN_FUNDED_TESTS=1 APIOSK_MCP_BEARER_TOKEN=... TARGET=hosted` to run a real paid execute test through the hosted OAuth path
528
- - `APIOSK_RUN_FUNDED_TESTS=1 APIOSK_RUN_PUBLISH_TEST=1 APIOSK_TEST_PRIVATE_KEY=0x... TARGET=local` to also test publish, list, update, and delete with a temporary listing
529
-
530
- Example funded run:
531
-
532
- ```bash
533
- cd /Users/olivierbrinkman/Development/Apiosk/subs/mcp
534
- APIOSK_RUN_FUNDED_TESTS=1 \
535
- APIOSK_TEST_PRIVATE_KEY=0x... \
536
- npm run test:macbook-air
142
+ { "name": "apiosk_status", "arguments": { "task_ref": "<state.state_ref>" } }
537
143
  ```
538
144
 
539
- ## Live URL Test Script
540
-
541
- Run a hosted-only test directly against the public MCP endpoint:
542
-
543
- ```bash
544
- cd /Users/olivierbrinkman/Development/Apiosk/subs/mcp
545
- npm run test:live
546
- ```
547
-
548
- Default live coverage:
549
-
550
- - checks `https://mcp.apiosk.com/health`
551
- - verifies the hosted tool surface
552
- - verifies `/.well-known/oauth-authorization-server`
553
- - verifies `/.well-known/oauth-protected-resource/mcp`
554
- - runs live `apiosk_explore`, `apiosk_metadata`, and `apiosk_health`
555
- - verifies that an unauthenticated protected MCP tool call returns the expected OAuth `401` challenge
556
-
557
- Optional live funded checks:
558
-
559
- - `APIOSK_RUN_REMOTE_WALLET_TEST=1 APIOSK_MCP_BEARER_TOKEN=... npm run test:live`
560
- - `APIOSK_RUN_FUNDED_TESTS=1 APIOSK_MCP_BEARER_TOKEN=... npm run test:live`
145
+ ## Environment variables
561
146
 
562
- The live hosted suite no longer imports a private key into the hosted MCP. Protected live checks now rely on a real hosted OAuth bearer token, which matches the ChatGPT-style remote MCP flow.
147
+ - `APIOSK_CONNECT_TOKEN` — stdio only: the Apiosk agent token sent as `Authorization: Bearer …` to Gateway v2. Hosted MCP obtains the token through OAuth.
148
+ - `APIOSK_GATEWAY_V2_URL` — the Gateway v2 origin. Defaults to `https://gateway.apiosk.com`; set only for a local (`http://127.0.0.1:…`) or staging gateway.
149
+ - `APIOSK_GATEWAY_URL` — the agent gateway used for hosted OAuth. Leave unset unless testing against staging.
150
+ - `APIOSK_MCP_OAUTH_SECRET` — signing secret for hosted OAuth codes, access tokens and refresh tokens.
151
+ - `APIOSK_MCP_PUBLIC_BASE_URL` — this server's own public URL.
563
152
 
564
- ## Environment Variables
153
+ This server holds no keys, prices nothing and moves no money: Gateway v2 plans,
154
+ prices, enforces the spending limits and executes.
565
155
 
566
- - `APIOSK_PRIVATE_KEY`: enables automatic x402 settlement and signed publish requests
567
- - `APIOSK_CONNECT_TOKEN`: attach a dashboard-managed connect token
568
- - `APIOSK_CONNECT_AUTHORIZATION`: attach a custom Authorization header
569
- - `APIOSK_CONNECT_HEADER_NAME`: override the connect-token header name
570
- - `APIOSK_WALLET_ADDRESS`: send a wallet address for wallet-aware flows
571
- - `APIOSK_X_PAYMENT`: attach a pre-built x402 proof manually
572
- - `APIOSK_GATEWAY`: override the gateway base URL
573
- - `APIOSK_CONTROL_PLANE_URL`: override the MCP-owned control-plane API base URL used for account, credits, and managed-wallet routes. Defaults to `https://mcp.apiosk.com`
574
- - `APIOSK_DASHBOARD_URL`: override the human-facing dashboard/app URL stored in local config and used in confirmation flows. Defaults to `https://dashboard.apiosk.com`
575
- - `APIOSK_DASHBOARD_JWT` or `APIOSK_USER_JWT`: unlock dashboard wallet routes
576
- - `APIOSK_ENABLE_LOCAL_WALLETS=true`: enable local wallet tools in HTTP server mode
577
- - `APIOSK_MCP_OAUTH_SECRET` or `APIOSK_MCP_AUTH_SECRET`: signing secret for hosted OAuth codes, access tokens, and refresh tokens
578
- - `APIOSK_MCP_BEARER_TOKEN`: optional hosted OAuth access token used by the live scripts for authenticated protected-tool checks
579
- - `APIOSK_HOME`: override the default `~/.apiosk` directory
580
- - `APIOSK_MCP_WALLET_STORE`: override the local wallet store path
156
+ ## Remote HTTP server
581
157
 
582
- ## Human-Funded Credits Flow
583
-
584
- In the local stdio package, MCP can now help a human top up Apiosk credits and then let the agent spend those credits later:
585
-
586
- 1. `apiosk_create_account` if the user needs a new Apiosk account
587
- 2. `apiosk_sign_in` to store a local dashboard session token
588
- 3. `apiosk_buy_credits` to create an Adyen checkout link
589
- 4. `apiosk_get_credits_status` after payment to reconcile the top-up and confirm the balance
590
-
591
- If signup does not return a session immediately, tell the user to confirm their email first and then call `apiosk_sign_in`.
592
-
593
- These calls now target the MCP-owned control-plane surface by default:
594
-
595
- - `https://mcp.apiosk.com/api/auth/mcp-sign-up`
596
- - `https://mcp.apiosk.com/api/auth/mcp-sign-in`
597
- - `https://mcp.apiosk.com/api/credits/topup`
598
- - `https://mcp.apiosk.com/api/credits/reconcile`
599
-
600
- ## Remote HTTP Server
601
-
602
- The public HTTP deployment is safe-by-default: local wallet and publish tools are disabled unless `APIOSK_ENABLE_LOCAL_WALLETS=true` is set on that server.
603
-
604
- Hosted OAuth metadata and authorization routes now live on the same host:
158
+ Hosted OAuth metadata and authorization routes live on the same host:
605
159
 
606
160
  - `https://mcp.apiosk.com/.well-known/oauth-authorization-server`
607
161
  - `https://mcp.apiosk.com/.well-known/oauth-protected-resource/mcp`
608
162
  - `https://mcp.apiosk.com/authorize`
609
163
  - `https://mcp.apiosk.com/token`
610
164
  - `https://mcp.apiosk.com/register`
611
-
612
- Test it:
165
+ - `https://mcp.apiosk.com/.well-known/mcp/server-card.json`
613
166
 
614
167
  ```bash
615
168
  curl https://mcp.apiosk.com/health
616
169
  ```
617
170
 
618
- ```bash
619
- curl https://mcp.apiosk.com/mcp \
620
- -H "Content-Type: application/json" \
621
- -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
622
- ```
623
-
624
171
  ## Development
625
172
 
626
173
  ```bash
627
174
  npm install
628
- npm run dev # HTTP server on :3000
629
- node index.mjs # stdio mode with local wallet tools enabled
175
+ npm test # node --test
176
+ npm run dev # HTTP server on :3000
177
+ node index.mjs # stdio
630
178
  ```
631
179
 
632
- Fresh-environment smoke test:
633
-
634
- ```bash
635
- cd /Users/olivierbrinkman/Development/Apiosk/subs/mcp
636
- npm run smoke:new-env
637
- ```
180
+ `test/surface.test.mjs` asserts the tool list by name and that the published
181
+ manifests (`dxt.json`, `server.json`, this file) and versions agree with it.
182
+ `src/gateway-v2-contracts.json` and `src/gateway-v2-instructions.md` are
183
+ generated from `gateway/contracts/` by `gateway/scripts/sync-contracts.mjs`; do
184
+ not edit them here.
638
185
 
639
186
  ## License
640
187