@solvapay/mcp 0.1.0 → 0.2.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.
@@ -0,0 +1,238 @@
1
+ import { OAuthBridgePaths, BuildAuthInfoFromBearerOptions, BuildSolvaPayDescriptorsOptions } from '@solvapay/mcp-core';
2
+ export { BuildAuthInfoFromBearerOptions, McpBearerAuthError, OAuthAuthorizationServerOptions, OAuthBridgePaths, buildAuthInfoFromBearer, getOAuthAuthorizationServerResponse, getOAuthProtectedResourceResponse } from '@solvapay/mcp-core';
3
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
5
+ import { AdditionalToolsContext } from '../index.cjs';
6
+ import '@modelcontextprotocol/sdk/server/zod-compat.js';
7
+ import '@solvapay/server';
8
+
9
+ /**
10
+ * Fetch-first OAuth bridge handlers.
11
+ *
12
+ * Each handler has the signature `(req: Request) => Promise<Response | null>`:
13
+ * it returns `Response` when the request matches the route, `null` when the
14
+ * handler doesn't want to claim the request (so the host can route
15
+ * elsewhere, e.g. to the MCP transport).
16
+ *
17
+ * Pure Web-standards: runs on Deno, Cloudflare Workers, Bun, Next edge,
18
+ * Supabase Edge, Node via the `undici`/`node:http` Web interop bridge —
19
+ * wherever `Request`, `Response`, and global `fetch` exist.
20
+ */
21
+
22
+ interface FetchOAuthOptions {
23
+ publicBaseUrl: string;
24
+ apiBaseUrl: string;
25
+ productRef: string;
26
+ protectedResourcePath?: string;
27
+ authorizationServerPath?: string;
28
+ oauthPaths?: OAuthBridgePaths;
29
+ }
30
+ type FetchHandler = (req: Request) => Promise<Response | null>;
31
+ declare function createProtectedResourceHandler(options: {
32
+ publicBaseUrl: string;
33
+ protectedResourcePath?: string;
34
+ }): FetchHandler;
35
+ declare function createAuthorizationServerHandler(options: {
36
+ publicBaseUrl: string;
37
+ authorizationServerPath?: string;
38
+ paths?: OAuthBridgePaths;
39
+ productRef: string;
40
+ }): FetchHandler;
41
+ declare function createOpenidNotFoundHandler(): FetchHandler;
42
+ declare function createOAuthRegisterHandler(options: {
43
+ apiBaseUrl: string;
44
+ productRef: string;
45
+ path?: string;
46
+ }): FetchHandler;
47
+ declare function createOAuthAuthorizeHandler(options: {
48
+ apiBaseUrl: string;
49
+ path?: string;
50
+ }): FetchHandler;
51
+ declare function createOAuthTokenHandler(options: {
52
+ apiBaseUrl: string;
53
+ path?: string;
54
+ }): FetchHandler;
55
+ declare function createOAuthRevokeHandler(options: {
56
+ apiBaseUrl: string;
57
+ path?: string;
58
+ }): FetchHandler;
59
+ /**
60
+ * Compose every OAuth handler into a single `(req) => Response | null`
61
+ * chain. Returns `null` when no handler matches so the caller can route
62
+ * to the MCP transport.
63
+ */
64
+ declare function createOAuthFetchRouter(options: FetchOAuthOptions): FetchHandler;
65
+
66
+ /**
67
+ * Native-scheme CORS preflight + 401 `WWW-Authenticate` helpers for MCP
68
+ * clients on Web-standards runtimes.
69
+ *
70
+ * MCP clients like Cursor, VS Code, and Claude Desktop attach native
71
+ * schemes to their DCR / OAuth flows (`cursor://…`, `vscode://…`,
72
+ * `vscode-webview://…`, `claude://…`). These origins don't carry
73
+ * credentials — mirroring them back in `Access-Control-Allow-Origin` is
74
+ * safer than a bare `*`.
75
+ */
76
+ /** Returns `true` when `origin` is a native MCP-client scheme we mirror. */
77
+ declare function isNativeClientOrigin(origin: string | null | undefined): boolean;
78
+ /** Adds CORS mirror headers to `headers` when the request origin is a native client scheme. */
79
+ declare function applyNativeCors(reqHeaders: Headers, resHeaders: Headers): void;
80
+ /** 204 preflight response with CORS mirror for native-scheme origins. */
81
+ declare function corsPreflight(req: Request): Response;
82
+ /**
83
+ * Produce a 401 JSON-RPC response + `WWW-Authenticate: Bearer
84
+ * resource_metadata="…"` pointing at the protected-resource discovery
85
+ * endpoint so MCP clients know where to discover the authorization
86
+ * server.
87
+ */
88
+ declare function authChallenge(req: Request, options: {
89
+ publicBaseUrl: string;
90
+ protectedResourcePath?: string;
91
+ jsonRpcId?: string | number | null;
92
+ }): Response;
93
+ /** Extract the raw bearer token from an `Authorization: Bearer <token>` header, or `null`. */
94
+ declare function resolveBearer(req: Request): string | null;
95
+
96
+ /**
97
+ * Turnkey fetch-first MCP handler: composes OAuth routing +
98
+ * `WebStandardStreamableHTTPServerTransport` + an `McpServer` into a
99
+ * single `(req: Request) => Promise<Response>`. Runs on any
100
+ * Web-standards runtime (Deno, Supabase Edge, Cloudflare Workers, Bun,
101
+ * Next edge, Vercel Functions, Node via undici/polyfilled Web APIs).
102
+ */
103
+
104
+ /**
105
+ * Transport wiring preset.
106
+ *
107
+ * - `'sse-stateful'` — default. SSE streaming + UUID `mcp-session-id`
108
+ * on initialize. Matches the original helper behaviour and is what
109
+ * Node / Express / Bun deployments expect.
110
+ * - `'json-stateless'` — `{ sessionIdGenerator: undefined,
111
+ * enableJsonResponse: true }`. Required on stateless fetch runtimes
112
+ * (Supabase Edge, Cloudflare Workers, Vercel Edge, Deno Deploy) that
113
+ * can't keep per-session state across invocations and need a
114
+ * single-JSON-response wire shape so the response body is assembled
115
+ * before the per-request transport is closed.
116
+ * - `'sse-stateless'` — SSE streaming without session IDs. Advanced /
117
+ * hypothetical; provided for symmetry. Most stateless runtimes want
118
+ * `'json-stateless'` instead (a cut SSE stream drops the response
119
+ * frame).
120
+ */
121
+ type McpHandlerMode = 'sse-stateful' | 'json-stateless' | 'sse-stateless';
122
+ interface CreateSolvaPayMcpFetchHandlerOptions {
123
+ server: McpServer;
124
+ publicBaseUrl: string;
125
+ apiBaseUrl: string;
126
+ productRef: string;
127
+ mcpPath?: string;
128
+ requireAuth?: boolean;
129
+ authInfo?: BuildAuthInfoFromBearerOptions;
130
+ protectedResourcePath?: string;
131
+ authorizationServerPath?: string;
132
+ oauthPaths?: OAuthBridgePaths;
133
+ /**
134
+ * Transport wiring preset. Defaults to `'sse-stateful'` to preserve
135
+ * the Node / Express / Bun behaviour of earlier versions. Stateless
136
+ * fetch runtimes (Supabase Edge, Cloudflare Workers, Vercel Edge)
137
+ * should pass `'json-stateless'`.
138
+ *
139
+ * Ignored when `buildTransport` is provided.
140
+ */
141
+ mode?: McpHandlerMode;
142
+ /**
143
+ * Escape hatch: bring your own transport builder. When provided,
144
+ * `mode` and `sessionIdGenerator` are ignored — the caller owns the
145
+ * transport's configuration. The handler still manages
146
+ * `server.connect(transport)` + `transport.close()` per request and
147
+ * serialises concurrent requests through the shared-server mutex.
148
+ */
149
+ buildTransport?: () => WebStandardStreamableHTTPServerTransport;
150
+ /**
151
+ * Optional session-id generator for the underlying
152
+ * `WebStandardStreamableHTTPServerTransport`. Only honoured in the
153
+ * default `'sse-stateful'` mode; ignored in stateless modes (which
154
+ * pass `sessionIdGenerator: undefined` to disable session tracking)
155
+ * and when `buildTransport` is provided.
156
+ *
157
+ * Defaults to `crypto.randomUUID`.
158
+ */
159
+ sessionIdGenerator?: () => string;
160
+ }
161
+ /**
162
+ * Build a `(req: Request) => Promise<Response>` that:
163
+ *
164
+ * 1. Serves `OPTIONS` preflight for native-scheme origins.
165
+ * 2. Serves every `.well-known/*` + `/oauth/*` route via
166
+ * {@link createOAuthFetchRouter}.
167
+ * 3. Enforces bearer-token auth on the MCP path (default `/mcp`) and
168
+ * returns `401 + WWW-Authenticate: Bearer resource_metadata="…"`
169
+ * when auth is missing.
170
+ * 4. Forwards the request to a fresh
171
+ * `WebStandardStreamableHTTPServerTransport` wired to the provided
172
+ * `McpServer`. The transport's `close()` runs in a `finally` block
173
+ * so the server's `_transport` slot is released for the next
174
+ * request; concurrent requests serialise through a shared mutex so
175
+ * two overlapping calls never double-connect the same `McpServer`.
176
+ *
177
+ * A fresh transport is created per request — that's the recommended
178
+ * pattern for stateless fetch runtimes (Workers, Deno, Supabase Edge).
179
+ * For long-lived session reuse, consume the low-level
180
+ * {@link createOAuthFetchRouter} + instantiate the transport yourself.
181
+ */
182
+ declare function createSolvaPayMcpFetchHandler(options: CreateSolvaPayMcpFetchHandlerOptions): (req: Request) => Promise<Response>;
183
+
184
+ /**
185
+ * `createSolvaPayMcpFetch` — descriptor-accepting unified factory for
186
+ * Web-standards runtimes. Collapses the two-step dance (build
187
+ * `McpServer` via `createSolvaPayMcpServer`, wrap in
188
+ * `createSolvaPayMcpFetchHandler`) into a single call so edge
189
+ * consumers (Supabase Edge, Cloudflare Workers, Vercel Edge, Deno,
190
+ * Bun) can import ONLY from `@solvapay/mcp/fetch`.
191
+ *
192
+ * The registration loop is shared with the root `.` entry via
193
+ * `../internal/buildMcpServer`. `AdditionalToolsContext` is
194
+ * re-exported from the root `@solvapay/mcp` entry so merchants can
195
+ * move the same `additionalTools` callback between
196
+ * `createSolvaPayMcpServer` and `createSolvaPayMcpFetch` without
197
+ * touching the handler's signature — including the bound
198
+ * `registerPayable` helper.
199
+ */
200
+
201
+ interface CreateSolvaPayMcpFetchOptions extends BuildSolvaPayDescriptorsOptions, Omit<CreateSolvaPayMcpFetchHandlerOptions, 'server'> {
202
+ /**
203
+ * Register non-SolvaPay tools on the freshly-built server. Receives
204
+ * `{ server, solvaPay, resourceUri, productRef, registerPayable }`
205
+ * — same shape as `createSolvaPayMcpServer`'s hook so merchant tool
206
+ * callbacks are portable between the two factories.
207
+ */
208
+ additionalTools?: (ctx: AdditionalToolsContext) => void;
209
+ /**
210
+ * Hide tools whose `_meta.audience` matches one of these values from
211
+ * `tools/list`. See `CreateSolvaPayMcpServerOptions` for the full
212
+ * rationale.
213
+ */
214
+ hideToolsByAudience?: string[];
215
+ /**
216
+ * Register the slash-command prompts built from the descriptor
217
+ * bundle. Defaults to `true`.
218
+ */
219
+ registerPrompts?: boolean;
220
+ /**
221
+ * Register the narrated `docs://solvapay/overview.md` resource so
222
+ * agents can `resources/read` before trying a tool. Defaults to `true`.
223
+ */
224
+ registerDocsResources?: boolean;
225
+ /** Overrides the default `McpServer` name. */
226
+ serverName?: string;
227
+ /** Overrides the default `McpServer` version. */
228
+ serverVersion?: string;
229
+ }
230
+ /**
231
+ * Build a fetch-first MCP handler with the full SolvaPay tool surface
232
+ * registered in-place. Returns a `(req: Request) => Promise<Response>`
233
+ * suitable for `Deno.serve`, `addEventListener('fetch', …)`, Cloudflare
234
+ * Workers' `fetch` export, or any other Web-standards runtime.
235
+ */
236
+ declare function createSolvaPayMcpFetch(options: CreateSolvaPayMcpFetchOptions): (req: Request) => Promise<Response>;
237
+
238
+ export { AdditionalToolsContext, type CreateSolvaPayMcpFetchHandlerOptions, type CreateSolvaPayMcpFetchOptions, type FetchOAuthOptions, type McpHandlerMode, applyNativeCors, authChallenge, corsPreflight, createAuthorizationServerHandler, createOAuthAuthorizeHandler, createOAuthFetchRouter, createOAuthRegisterHandler, createOAuthRevokeHandler, createOAuthTokenHandler, createOpenidNotFoundHandler, createProtectedResourceHandler, createSolvaPayMcpFetch, createSolvaPayMcpFetchHandler, isNativeClientOrigin, resolveBearer };
@@ -0,0 +1,238 @@
1
+ import { OAuthBridgePaths, BuildAuthInfoFromBearerOptions, BuildSolvaPayDescriptorsOptions } from '@solvapay/mcp-core';
2
+ export { BuildAuthInfoFromBearerOptions, McpBearerAuthError, OAuthAuthorizationServerOptions, OAuthBridgePaths, buildAuthInfoFromBearer, getOAuthAuthorizationServerResponse, getOAuthProtectedResourceResponse } from '@solvapay/mcp-core';
3
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
5
+ import { AdditionalToolsContext } from '../index.js';
6
+ import '@modelcontextprotocol/sdk/server/zod-compat.js';
7
+ import '@solvapay/server';
8
+
9
+ /**
10
+ * Fetch-first OAuth bridge handlers.
11
+ *
12
+ * Each handler has the signature `(req: Request) => Promise<Response | null>`:
13
+ * it returns `Response` when the request matches the route, `null` when the
14
+ * handler doesn't want to claim the request (so the host can route
15
+ * elsewhere, e.g. to the MCP transport).
16
+ *
17
+ * Pure Web-standards: runs on Deno, Cloudflare Workers, Bun, Next edge,
18
+ * Supabase Edge, Node via the `undici`/`node:http` Web interop bridge —
19
+ * wherever `Request`, `Response`, and global `fetch` exist.
20
+ */
21
+
22
+ interface FetchOAuthOptions {
23
+ publicBaseUrl: string;
24
+ apiBaseUrl: string;
25
+ productRef: string;
26
+ protectedResourcePath?: string;
27
+ authorizationServerPath?: string;
28
+ oauthPaths?: OAuthBridgePaths;
29
+ }
30
+ type FetchHandler = (req: Request) => Promise<Response | null>;
31
+ declare function createProtectedResourceHandler(options: {
32
+ publicBaseUrl: string;
33
+ protectedResourcePath?: string;
34
+ }): FetchHandler;
35
+ declare function createAuthorizationServerHandler(options: {
36
+ publicBaseUrl: string;
37
+ authorizationServerPath?: string;
38
+ paths?: OAuthBridgePaths;
39
+ productRef: string;
40
+ }): FetchHandler;
41
+ declare function createOpenidNotFoundHandler(): FetchHandler;
42
+ declare function createOAuthRegisterHandler(options: {
43
+ apiBaseUrl: string;
44
+ productRef: string;
45
+ path?: string;
46
+ }): FetchHandler;
47
+ declare function createOAuthAuthorizeHandler(options: {
48
+ apiBaseUrl: string;
49
+ path?: string;
50
+ }): FetchHandler;
51
+ declare function createOAuthTokenHandler(options: {
52
+ apiBaseUrl: string;
53
+ path?: string;
54
+ }): FetchHandler;
55
+ declare function createOAuthRevokeHandler(options: {
56
+ apiBaseUrl: string;
57
+ path?: string;
58
+ }): FetchHandler;
59
+ /**
60
+ * Compose every OAuth handler into a single `(req) => Response | null`
61
+ * chain. Returns `null` when no handler matches so the caller can route
62
+ * to the MCP transport.
63
+ */
64
+ declare function createOAuthFetchRouter(options: FetchOAuthOptions): FetchHandler;
65
+
66
+ /**
67
+ * Native-scheme CORS preflight + 401 `WWW-Authenticate` helpers for MCP
68
+ * clients on Web-standards runtimes.
69
+ *
70
+ * MCP clients like Cursor, VS Code, and Claude Desktop attach native
71
+ * schemes to their DCR / OAuth flows (`cursor://…`, `vscode://…`,
72
+ * `vscode-webview://…`, `claude://…`). These origins don't carry
73
+ * credentials — mirroring them back in `Access-Control-Allow-Origin` is
74
+ * safer than a bare `*`.
75
+ */
76
+ /** Returns `true` when `origin` is a native MCP-client scheme we mirror. */
77
+ declare function isNativeClientOrigin(origin: string | null | undefined): boolean;
78
+ /** Adds CORS mirror headers to `headers` when the request origin is a native client scheme. */
79
+ declare function applyNativeCors(reqHeaders: Headers, resHeaders: Headers): void;
80
+ /** 204 preflight response with CORS mirror for native-scheme origins. */
81
+ declare function corsPreflight(req: Request): Response;
82
+ /**
83
+ * Produce a 401 JSON-RPC response + `WWW-Authenticate: Bearer
84
+ * resource_metadata="…"` pointing at the protected-resource discovery
85
+ * endpoint so MCP clients know where to discover the authorization
86
+ * server.
87
+ */
88
+ declare function authChallenge(req: Request, options: {
89
+ publicBaseUrl: string;
90
+ protectedResourcePath?: string;
91
+ jsonRpcId?: string | number | null;
92
+ }): Response;
93
+ /** Extract the raw bearer token from an `Authorization: Bearer <token>` header, or `null`. */
94
+ declare function resolveBearer(req: Request): string | null;
95
+
96
+ /**
97
+ * Turnkey fetch-first MCP handler: composes OAuth routing +
98
+ * `WebStandardStreamableHTTPServerTransport` + an `McpServer` into a
99
+ * single `(req: Request) => Promise<Response>`. Runs on any
100
+ * Web-standards runtime (Deno, Supabase Edge, Cloudflare Workers, Bun,
101
+ * Next edge, Vercel Functions, Node via undici/polyfilled Web APIs).
102
+ */
103
+
104
+ /**
105
+ * Transport wiring preset.
106
+ *
107
+ * - `'sse-stateful'` — default. SSE streaming + UUID `mcp-session-id`
108
+ * on initialize. Matches the original helper behaviour and is what
109
+ * Node / Express / Bun deployments expect.
110
+ * - `'json-stateless'` — `{ sessionIdGenerator: undefined,
111
+ * enableJsonResponse: true }`. Required on stateless fetch runtimes
112
+ * (Supabase Edge, Cloudflare Workers, Vercel Edge, Deno Deploy) that
113
+ * can't keep per-session state across invocations and need a
114
+ * single-JSON-response wire shape so the response body is assembled
115
+ * before the per-request transport is closed.
116
+ * - `'sse-stateless'` — SSE streaming without session IDs. Advanced /
117
+ * hypothetical; provided for symmetry. Most stateless runtimes want
118
+ * `'json-stateless'` instead (a cut SSE stream drops the response
119
+ * frame).
120
+ */
121
+ type McpHandlerMode = 'sse-stateful' | 'json-stateless' | 'sse-stateless';
122
+ interface CreateSolvaPayMcpFetchHandlerOptions {
123
+ server: McpServer;
124
+ publicBaseUrl: string;
125
+ apiBaseUrl: string;
126
+ productRef: string;
127
+ mcpPath?: string;
128
+ requireAuth?: boolean;
129
+ authInfo?: BuildAuthInfoFromBearerOptions;
130
+ protectedResourcePath?: string;
131
+ authorizationServerPath?: string;
132
+ oauthPaths?: OAuthBridgePaths;
133
+ /**
134
+ * Transport wiring preset. Defaults to `'sse-stateful'` to preserve
135
+ * the Node / Express / Bun behaviour of earlier versions. Stateless
136
+ * fetch runtimes (Supabase Edge, Cloudflare Workers, Vercel Edge)
137
+ * should pass `'json-stateless'`.
138
+ *
139
+ * Ignored when `buildTransport` is provided.
140
+ */
141
+ mode?: McpHandlerMode;
142
+ /**
143
+ * Escape hatch: bring your own transport builder. When provided,
144
+ * `mode` and `sessionIdGenerator` are ignored — the caller owns the
145
+ * transport's configuration. The handler still manages
146
+ * `server.connect(transport)` + `transport.close()` per request and
147
+ * serialises concurrent requests through the shared-server mutex.
148
+ */
149
+ buildTransport?: () => WebStandardStreamableHTTPServerTransport;
150
+ /**
151
+ * Optional session-id generator for the underlying
152
+ * `WebStandardStreamableHTTPServerTransport`. Only honoured in the
153
+ * default `'sse-stateful'` mode; ignored in stateless modes (which
154
+ * pass `sessionIdGenerator: undefined` to disable session tracking)
155
+ * and when `buildTransport` is provided.
156
+ *
157
+ * Defaults to `crypto.randomUUID`.
158
+ */
159
+ sessionIdGenerator?: () => string;
160
+ }
161
+ /**
162
+ * Build a `(req: Request) => Promise<Response>` that:
163
+ *
164
+ * 1. Serves `OPTIONS` preflight for native-scheme origins.
165
+ * 2. Serves every `.well-known/*` + `/oauth/*` route via
166
+ * {@link createOAuthFetchRouter}.
167
+ * 3. Enforces bearer-token auth on the MCP path (default `/mcp`) and
168
+ * returns `401 + WWW-Authenticate: Bearer resource_metadata="…"`
169
+ * when auth is missing.
170
+ * 4. Forwards the request to a fresh
171
+ * `WebStandardStreamableHTTPServerTransport` wired to the provided
172
+ * `McpServer`. The transport's `close()` runs in a `finally` block
173
+ * so the server's `_transport` slot is released for the next
174
+ * request; concurrent requests serialise through a shared mutex so
175
+ * two overlapping calls never double-connect the same `McpServer`.
176
+ *
177
+ * A fresh transport is created per request — that's the recommended
178
+ * pattern for stateless fetch runtimes (Workers, Deno, Supabase Edge).
179
+ * For long-lived session reuse, consume the low-level
180
+ * {@link createOAuthFetchRouter} + instantiate the transport yourself.
181
+ */
182
+ declare function createSolvaPayMcpFetchHandler(options: CreateSolvaPayMcpFetchHandlerOptions): (req: Request) => Promise<Response>;
183
+
184
+ /**
185
+ * `createSolvaPayMcpFetch` — descriptor-accepting unified factory for
186
+ * Web-standards runtimes. Collapses the two-step dance (build
187
+ * `McpServer` via `createSolvaPayMcpServer`, wrap in
188
+ * `createSolvaPayMcpFetchHandler`) into a single call so edge
189
+ * consumers (Supabase Edge, Cloudflare Workers, Vercel Edge, Deno,
190
+ * Bun) can import ONLY from `@solvapay/mcp/fetch`.
191
+ *
192
+ * The registration loop is shared with the root `.` entry via
193
+ * `../internal/buildMcpServer`. `AdditionalToolsContext` is
194
+ * re-exported from the root `@solvapay/mcp` entry so merchants can
195
+ * move the same `additionalTools` callback between
196
+ * `createSolvaPayMcpServer` and `createSolvaPayMcpFetch` without
197
+ * touching the handler's signature — including the bound
198
+ * `registerPayable` helper.
199
+ */
200
+
201
+ interface CreateSolvaPayMcpFetchOptions extends BuildSolvaPayDescriptorsOptions, Omit<CreateSolvaPayMcpFetchHandlerOptions, 'server'> {
202
+ /**
203
+ * Register non-SolvaPay tools on the freshly-built server. Receives
204
+ * `{ server, solvaPay, resourceUri, productRef, registerPayable }`
205
+ * — same shape as `createSolvaPayMcpServer`'s hook so merchant tool
206
+ * callbacks are portable between the two factories.
207
+ */
208
+ additionalTools?: (ctx: AdditionalToolsContext) => void;
209
+ /**
210
+ * Hide tools whose `_meta.audience` matches one of these values from
211
+ * `tools/list`. See `CreateSolvaPayMcpServerOptions` for the full
212
+ * rationale.
213
+ */
214
+ hideToolsByAudience?: string[];
215
+ /**
216
+ * Register the slash-command prompts built from the descriptor
217
+ * bundle. Defaults to `true`.
218
+ */
219
+ registerPrompts?: boolean;
220
+ /**
221
+ * Register the narrated `docs://solvapay/overview.md` resource so
222
+ * agents can `resources/read` before trying a tool. Defaults to `true`.
223
+ */
224
+ registerDocsResources?: boolean;
225
+ /** Overrides the default `McpServer` name. */
226
+ serverName?: string;
227
+ /** Overrides the default `McpServer` version. */
228
+ serverVersion?: string;
229
+ }
230
+ /**
231
+ * Build a fetch-first MCP handler with the full SolvaPay tool surface
232
+ * registered in-place. Returns a `(req: Request) => Promise<Response>`
233
+ * suitable for `Deno.serve`, `addEventListener('fetch', …)`, Cloudflare
234
+ * Workers' `fetch` export, or any other Web-standards runtime.
235
+ */
236
+ declare function createSolvaPayMcpFetch(options: CreateSolvaPayMcpFetchOptions): (req: Request) => Promise<Response>;
237
+
238
+ export { AdditionalToolsContext, type CreateSolvaPayMcpFetchHandlerOptions, type CreateSolvaPayMcpFetchOptions, type FetchOAuthOptions, type McpHandlerMode, applyNativeCors, authChallenge, corsPreflight, createAuthorizationServerHandler, createOAuthAuthorizeHandler, createOAuthFetchRouter, createOAuthRegisterHandler, createOAuthRevokeHandler, createOAuthTokenHandler, createOpenidNotFoundHandler, createProtectedResourceHandler, createSolvaPayMcpFetch, createSolvaPayMcpFetchHandler, isNativeClientOrigin, resolveBearer };