@solvapay/mcp 0.2.3 → 0.2.4
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/dist/{chunk-3VDAADZU.js → chunk-RWJ6GBM5.js} +10 -1
- package/dist/fetch/index.cjs +11 -2
- package/dist/fetch/index.d.cts +6 -6
- package/dist/fetch/index.d.ts +6 -6
- package/dist/fetch/index.js +4 -2
- package/dist/index.cjs +11 -2
- package/dist/index.d.cts +50 -11
- package/dist/index.d.ts +50 -11
- package/dist/index.js +4 -2
- package/package.json +3 -3
|
@@ -76,6 +76,15 @@ import {
|
|
|
76
76
|
buildSolvaPayDescriptors,
|
|
77
77
|
deriveIcons
|
|
78
78
|
} from "@solvapay/mcp-core";
|
|
79
|
+
function normaliseHideToolsByAudience(config) {
|
|
80
|
+
if (!config) return { audiences: void 0, options: {} };
|
|
81
|
+
if (Array.isArray(config)) return { audiences: config, options: {} };
|
|
82
|
+
const obj = config;
|
|
83
|
+
return {
|
|
84
|
+
audiences: obj.audiences,
|
|
85
|
+
options: obj.bypassWhen !== void 0 ? { bypassWhen: obj.bypassWhen } : {}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
79
88
|
function registerDescriptor(server, tool) {
|
|
80
89
|
const baseMeta = tool.meta ?? {};
|
|
81
90
|
const baseUi = baseMeta.ui ?? {};
|
|
@@ -139,7 +148,6 @@ function buildSolvaPayMcpServer(options) {
|
|
|
139
148
|
registerDocsResources = true,
|
|
140
149
|
serverName,
|
|
141
150
|
serverVersion = "1.0.0",
|
|
142
|
-
hideToolsByAudience: _hideToolsByAudience,
|
|
143
151
|
...descriptorOptions
|
|
144
152
|
} = options;
|
|
145
153
|
const descriptors = buildSolvaPayDescriptors(descriptorOptions);
|
|
@@ -206,6 +214,7 @@ function buildSolvaPayMcpServer(options) {
|
|
|
206
214
|
|
|
207
215
|
export {
|
|
208
216
|
applyHideToolsByAudience,
|
|
217
|
+
normaliseHideToolsByAudience,
|
|
209
218
|
buildSolvaPayMcpServer,
|
|
210
219
|
registerPayableTool
|
|
211
220
|
};
|
package/dist/fetch/index.cjs
CHANGED
|
@@ -518,6 +518,15 @@ function createSolvaPayMcpFetchHandler(options) {
|
|
|
518
518
|
var import_server = require("@modelcontextprotocol/ext-apps/server");
|
|
519
519
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
520
520
|
var import_mcp_core4 = require("@solvapay/mcp-core");
|
|
521
|
+
function normaliseHideToolsByAudience(config) {
|
|
522
|
+
if (!config) return { audiences: void 0, options: {} };
|
|
523
|
+
if (Array.isArray(config)) return { audiences: config, options: {} };
|
|
524
|
+
const obj = config;
|
|
525
|
+
return {
|
|
526
|
+
audiences: obj.audiences,
|
|
527
|
+
options: obj.bypassWhen !== void 0 ? { bypassWhen: obj.bypassWhen } : {}
|
|
528
|
+
};
|
|
529
|
+
}
|
|
521
530
|
function registerDescriptor(server, tool) {
|
|
522
531
|
const baseMeta = tool.meta ?? {};
|
|
523
532
|
const baseUi = baseMeta.ui ?? {};
|
|
@@ -581,7 +590,6 @@ function buildSolvaPayMcpServer(options) {
|
|
|
581
590
|
registerDocsResources = true,
|
|
582
591
|
serverName,
|
|
583
592
|
serverVersion = "1.0.0",
|
|
584
|
-
hideToolsByAudience: _hideToolsByAudience,
|
|
585
593
|
...descriptorOptions
|
|
586
594
|
} = options;
|
|
587
595
|
const descriptors = (0, import_mcp_core4.buildSolvaPayDescriptors)(descriptorOptions);
|
|
@@ -769,7 +777,8 @@ function createSolvaPayMcpFetch(options) {
|
|
|
769
777
|
};
|
|
770
778
|
additionalTools({ server, solvaPay, resourceUri, productRef, registerPayable });
|
|
771
779
|
}
|
|
772
|
-
|
|
780
|
+
const { audiences, options: filterOptions } = normaliseHideToolsByAudience(hideToolsByAudience);
|
|
781
|
+
(0, import_mcp_core4.applyHideToolsByAudience)(server, audiences, filterOptions);
|
|
773
782
|
return createSolvaPayMcpFetchHandler({
|
|
774
783
|
server,
|
|
775
784
|
publicBaseUrl,
|
package/dist/fetch/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { OAuthBridgePaths, BuildAuthInfoFromBearerOptions, BuildSolvaPayDescript
|
|
|
2
2
|
export { BuildAuthInfoFromBearerOptions, McpBearerAuthError, OAuthAuthorizationServerOptions, OAuthBridgePaths, buildAuthInfoFromBearer, getOAuthAuthorizationServerResponse, getOAuthProtectedResourceResponse } from '@solvapay/mcp-core';
|
|
3
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
4
|
import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
|
|
5
|
-
import { AdditionalToolsContext } from '../index.cjs';
|
|
5
|
+
import { AdditionalToolsContext, HideToolsByAudienceConfig } from '../index.cjs';
|
|
6
6
|
import '@modelcontextprotocol/sdk/server/zod-compat.js';
|
|
7
7
|
import '@solvapay/server';
|
|
8
8
|
|
|
@@ -207,11 +207,11 @@ interface CreateSolvaPayMcpFetchOptions extends Omit<BuildSolvaPayDescriptorsOpt
|
|
|
207
207
|
*/
|
|
208
208
|
additionalTools?: (ctx: AdditionalToolsContext) => void;
|
|
209
209
|
/**
|
|
210
|
-
* Hide tools whose `_meta.audience` matches one of these values
|
|
211
|
-
* `tools/list`. See `CreateSolvaPayMcpServerOptions` for the
|
|
212
|
-
* rationale.
|
|
210
|
+
* Hide tools whose `_meta.audience` matches one of these values
|
|
211
|
+
* from `tools/list`. See `CreateSolvaPayMcpServerOptions` for the
|
|
212
|
+
* full rationale and the ChatGPT auto-bypass behaviour.
|
|
213
213
|
*/
|
|
214
|
-
hideToolsByAudience?:
|
|
214
|
+
hideToolsByAudience?: HideToolsByAudienceConfig;
|
|
215
215
|
/**
|
|
216
216
|
* Register the slash-command prompts built from the descriptor
|
|
217
217
|
* bundle. Defaults to `true`.
|
|
@@ -235,4 +235,4 @@ interface CreateSolvaPayMcpFetchOptions extends Omit<BuildSolvaPayDescriptorsOpt
|
|
|
235
235
|
*/
|
|
236
236
|
declare function createSolvaPayMcpFetch(options: CreateSolvaPayMcpFetchOptions): (req: Request) => Promise<Response>;
|
|
237
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 };
|
|
238
|
+
export { AdditionalToolsContext, type CreateSolvaPayMcpFetchHandlerOptions, type CreateSolvaPayMcpFetchOptions, type FetchOAuthOptions, HideToolsByAudienceConfig, type McpHandlerMode, applyNativeCors, authChallenge, corsPreflight, createAuthorizationServerHandler, createOAuthAuthorizeHandler, createOAuthFetchRouter, createOAuthRegisterHandler, createOAuthRevokeHandler, createOAuthTokenHandler, createOpenidNotFoundHandler, createProtectedResourceHandler, createSolvaPayMcpFetch, createSolvaPayMcpFetchHandler, isNativeClientOrigin, resolveBearer };
|
package/dist/fetch/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { OAuthBridgePaths, BuildAuthInfoFromBearerOptions, BuildSolvaPayDescript
|
|
|
2
2
|
export { BuildAuthInfoFromBearerOptions, McpBearerAuthError, OAuthAuthorizationServerOptions, OAuthBridgePaths, buildAuthInfoFromBearer, getOAuthAuthorizationServerResponse, getOAuthProtectedResourceResponse } from '@solvapay/mcp-core';
|
|
3
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
4
|
import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
|
|
5
|
-
import { AdditionalToolsContext } from '../index.js';
|
|
5
|
+
import { AdditionalToolsContext, HideToolsByAudienceConfig } from '../index.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/server/zod-compat.js';
|
|
7
7
|
import '@solvapay/server';
|
|
8
8
|
|
|
@@ -207,11 +207,11 @@ interface CreateSolvaPayMcpFetchOptions extends Omit<BuildSolvaPayDescriptorsOpt
|
|
|
207
207
|
*/
|
|
208
208
|
additionalTools?: (ctx: AdditionalToolsContext) => void;
|
|
209
209
|
/**
|
|
210
|
-
* Hide tools whose `_meta.audience` matches one of these values
|
|
211
|
-
* `tools/list`. See `CreateSolvaPayMcpServerOptions` for the
|
|
212
|
-
* rationale.
|
|
210
|
+
* Hide tools whose `_meta.audience` matches one of these values
|
|
211
|
+
* from `tools/list`. See `CreateSolvaPayMcpServerOptions` for the
|
|
212
|
+
* full rationale and the ChatGPT auto-bypass behaviour.
|
|
213
213
|
*/
|
|
214
|
-
hideToolsByAudience?:
|
|
214
|
+
hideToolsByAudience?: HideToolsByAudienceConfig;
|
|
215
215
|
/**
|
|
216
216
|
* Register the slash-command prompts built from the descriptor
|
|
217
217
|
* bundle. Defaults to `true`.
|
|
@@ -235,4 +235,4 @@ interface CreateSolvaPayMcpFetchOptions extends Omit<BuildSolvaPayDescriptorsOpt
|
|
|
235
235
|
*/
|
|
236
236
|
declare function createSolvaPayMcpFetch(options: CreateSolvaPayMcpFetchOptions): (req: Request) => Promise<Response>;
|
|
237
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 };
|
|
238
|
+
export { AdditionalToolsContext, type CreateSolvaPayMcpFetchHandlerOptions, type CreateSolvaPayMcpFetchOptions, type FetchOAuthOptions, HideToolsByAudienceConfig, type McpHandlerMode, applyNativeCors, authChallenge, corsPreflight, createAuthorizationServerHandler, createOAuthAuthorizeHandler, createOAuthFetchRouter, createOAuthRegisterHandler, createOAuthRevokeHandler, createOAuthTokenHandler, createOpenidNotFoundHandler, createProtectedResourceHandler, createSolvaPayMcpFetch, createSolvaPayMcpFetchHandler, isNativeClientOrigin, resolveBearer };
|
package/dist/fetch/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyHideToolsByAudience,
|
|
3
3
|
buildSolvaPayMcpServer,
|
|
4
|
+
normaliseHideToolsByAudience,
|
|
4
5
|
registerPayableTool
|
|
5
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-RWJ6GBM5.js";
|
|
6
7
|
import {
|
|
7
8
|
toOAuthErrorBody
|
|
8
9
|
} from "../chunk-R3OMC7S2.js";
|
|
@@ -466,7 +467,8 @@ function createSolvaPayMcpFetch(options) {
|
|
|
466
467
|
};
|
|
467
468
|
additionalTools({ server, solvaPay, resourceUri, productRef, registerPayable });
|
|
468
469
|
}
|
|
469
|
-
|
|
470
|
+
const { audiences, options: filterOptions } = normaliseHideToolsByAudience(hideToolsByAudience);
|
|
471
|
+
applyHideToolsByAudience(server, audiences, filterOptions);
|
|
470
472
|
return createSolvaPayMcpFetchHandler({
|
|
471
473
|
server,
|
|
472
474
|
publicBaseUrl,
|
package/dist/index.cjs
CHANGED
|
@@ -29,6 +29,15 @@ module.exports = __toCommonJS(index_exports);
|
|
|
29
29
|
var import_server = require("@modelcontextprotocol/ext-apps/server");
|
|
30
30
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
31
31
|
var import_mcp_core = require("@solvapay/mcp-core");
|
|
32
|
+
function normaliseHideToolsByAudience(config) {
|
|
33
|
+
if (!config) return { audiences: void 0, options: {} };
|
|
34
|
+
if (Array.isArray(config)) return { audiences: config, options: {} };
|
|
35
|
+
const obj = config;
|
|
36
|
+
return {
|
|
37
|
+
audiences: obj.audiences,
|
|
38
|
+
options: obj.bypassWhen !== void 0 ? { bypassWhen: obj.bypassWhen } : {}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
32
41
|
function registerDescriptor(server, tool) {
|
|
33
42
|
const baseMeta = tool.meta ?? {};
|
|
34
43
|
const baseUi = baseMeta.ui ?? {};
|
|
@@ -92,7 +101,6 @@ function buildSolvaPayMcpServer(options) {
|
|
|
92
101
|
registerDocsResources = true,
|
|
93
102
|
serverName,
|
|
94
103
|
serverVersion = "1.0.0",
|
|
95
|
-
hideToolsByAudience: _hideToolsByAudience,
|
|
96
104
|
...descriptorOptions
|
|
97
105
|
} = options;
|
|
98
106
|
const descriptors = (0, import_mcp_core.buildSolvaPayDescriptors)(descriptorOptions);
|
|
@@ -252,7 +260,8 @@ function createSolvaPayMcpServer(options) {
|
|
|
252
260
|
};
|
|
253
261
|
additionalTools({ server, solvaPay, resourceUri, productRef, registerPayable });
|
|
254
262
|
}
|
|
255
|
-
|
|
263
|
+
const { audiences, options: filterOptions } = normaliseHideToolsByAudience(hideToolsByAudience);
|
|
264
|
+
(0, import_mcp_core.applyHideToolsByAudience)(server, audiences, filterOptions);
|
|
256
265
|
return server;
|
|
257
266
|
}
|
|
258
267
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { ZodRawShapeCompat, AnySchema, ShapeOutput, SchemaOutput } from '@modelcontextprotocol/sdk/server/zod-compat.js';
|
|
3
|
-
import { PayableHandler, BuildBootstrapPayloadFn, McpToolExtra, SolvaPayToolAnnotations, SolvaPayToolIcon, BuildSolvaPayDescriptorsOptions } from '@solvapay/mcp-core';
|
|
3
|
+
import { ApplyHideToolsByAudienceOptions, PayableHandler, BuildBootstrapPayloadFn, McpToolExtra, SolvaPayToolAnnotations, SolvaPayToolIcon, BuildSolvaPayDescriptorsOptions } from '@solvapay/mcp-core';
|
|
4
4
|
export { ContentBlock, CustomerSnapshot, NudgeSpec, PayableHandler, ResponseContext, ResponseOptions, ResponseResult } from '@solvapay/mcp-core';
|
|
5
5
|
import { SolvaPay } from '@solvapay/server';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Shared `McpServer` construction + descriptor-registration loop used
|
|
9
|
+
* by both the `.` entry (`createSolvaPayMcpServer` in `../server.ts`)
|
|
10
|
+
* and the `./fetch` entry (`createSolvaPayMcpFetch` in
|
|
11
|
+
* `../fetch/createSolvaPayMcpFetch.ts`).
|
|
12
|
+
*
|
|
13
|
+
* Lifted here so the two public factories stop duplicating the same
|
|
14
|
+
* 80-line registration wiring. Both entrypoints get the exact same
|
|
15
|
+
* server shape (11 tools + prompts + docs resource + UI resource)
|
|
16
|
+
* without importing from each other — Node consumers keep their
|
|
17
|
+
* existing import path, fetch-first consumers keep theirs, and the
|
|
18
|
+
* diff-risk from the previous sibling copies is gone.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
type HideToolsByAudienceConfig = readonly string[] | {
|
|
22
|
+
audiences: readonly string[];
|
|
23
|
+
bypassWhen?: ApplyHideToolsByAudienceOptions['bypassWhen'];
|
|
24
|
+
};
|
|
25
|
+
|
|
7
26
|
/**
|
|
8
27
|
* `registerPayableTool(server, name, options)` — one-liner for registering
|
|
9
28
|
* a paywall-protected MCP tool on the official `@modelcontextprotocol/sdk`
|
|
@@ -177,20 +196,40 @@ interface CreateSolvaPayMcpServerOptions extends BuildSolvaPayDescriptorsOptions
|
|
|
177
196
|
* tool whose `_meta.audience` matches one of these values. The
|
|
178
197
|
* tools stay `enabled: true` so `tools/call` still reaches their
|
|
179
198
|
* handlers — this option only affects the `tools/list` response
|
|
180
|
-
* shape. Pass `['ui']`
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* `
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
199
|
+
* shape. Pass `['ui']` to keep the LLM-facing catalogue narrow to
|
|
200
|
+
* the four intent tools (`upgrade` / `manage_account` /
|
|
201
|
+
* `activate_plan` / `topup`) plus your own merchant-registered
|
|
202
|
+
* data tools, while leaving the seven UI transport tools
|
|
203
|
+
* (`create_payment_intent`, etc.) callable for the SolvaPay
|
|
204
|
+
* iframe.
|
|
205
|
+
*
|
|
206
|
+
* # ChatGPT auto-bypass
|
|
207
|
+
*
|
|
208
|
+
* ChatGPT's Custom Connector gateway re-validates iframe-initiated
|
|
209
|
+
* `tools/call` against the cached `tools/list` catalog, so any
|
|
210
|
+
* tool hidden by this option becomes uncallable from the embedded
|
|
211
|
+
* iframe and surfaces in the UI as `MCP error -32000: MCP Resource
|
|
212
|
+
* not found`. To preserve the cleaner LLM catalog on every other
|
|
213
|
+
* host while keeping the iframe working on ChatGPT, the SDK
|
|
214
|
+
* auto-detects ChatGPT-originated `tools/list` requests (matching
|
|
215
|
+
* `request.headers['user-agent']` and the post-`initialize`
|
|
216
|
+
* `clientInfo.name` against `/openai-mcp/i`) and returns the full
|
|
217
|
+
* catalog to them. The detection is verified live against
|
|
218
|
+
* `openai-mcp/1.0.0 (ChatGPT)` and the broad pattern survives a UA
|
|
219
|
+
* version bump.
|
|
220
|
+
*
|
|
221
|
+
* To extend the bypass to a future iframe-capable host, pass the
|
|
222
|
+
* object form: `{ audiences: ['ui'], bypassWhen: ctx => … }`.
|
|
223
|
+
*
|
|
224
|
+
* To disable the bypass and apply the filter unconditionally
|
|
225
|
+
* (e.g. on a known text-only deployment), pass `{ audiences:
|
|
226
|
+
* ['ui'], bypassWhen: () => false }`.
|
|
188
227
|
*/
|
|
189
|
-
hideToolsByAudience?:
|
|
228
|
+
hideToolsByAudience?: HideToolsByAudienceConfig;
|
|
190
229
|
}
|
|
191
230
|
/**
|
|
192
231
|
* Build the MCP server and register the full SolvaPay tool surface.
|
|
193
232
|
*/
|
|
194
233
|
declare function createSolvaPayMcpServer(options: CreateSolvaPayMcpServerOptions): McpServer;
|
|
195
234
|
|
|
196
|
-
export { type AdditionalToolsContext, type CreateSolvaPayMcpServerOptions, type RegisterPayableToolOptions, createSolvaPayMcpServer, registerPayableTool };
|
|
235
|
+
export { type AdditionalToolsContext, type CreateSolvaPayMcpServerOptions, type HideToolsByAudienceConfig, type RegisterPayableToolOptions, createSolvaPayMcpServer, registerPayableTool };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { ZodRawShapeCompat, AnySchema, ShapeOutput, SchemaOutput } from '@modelcontextprotocol/sdk/server/zod-compat.js';
|
|
3
|
-
import { PayableHandler, BuildBootstrapPayloadFn, McpToolExtra, SolvaPayToolAnnotations, SolvaPayToolIcon, BuildSolvaPayDescriptorsOptions } from '@solvapay/mcp-core';
|
|
3
|
+
import { ApplyHideToolsByAudienceOptions, PayableHandler, BuildBootstrapPayloadFn, McpToolExtra, SolvaPayToolAnnotations, SolvaPayToolIcon, BuildSolvaPayDescriptorsOptions } from '@solvapay/mcp-core';
|
|
4
4
|
export { ContentBlock, CustomerSnapshot, NudgeSpec, PayableHandler, ResponseContext, ResponseOptions, ResponseResult } from '@solvapay/mcp-core';
|
|
5
5
|
import { SolvaPay } from '@solvapay/server';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Shared `McpServer` construction + descriptor-registration loop used
|
|
9
|
+
* by both the `.` entry (`createSolvaPayMcpServer` in `../server.ts`)
|
|
10
|
+
* and the `./fetch` entry (`createSolvaPayMcpFetch` in
|
|
11
|
+
* `../fetch/createSolvaPayMcpFetch.ts`).
|
|
12
|
+
*
|
|
13
|
+
* Lifted here so the two public factories stop duplicating the same
|
|
14
|
+
* 80-line registration wiring. Both entrypoints get the exact same
|
|
15
|
+
* server shape (11 tools + prompts + docs resource + UI resource)
|
|
16
|
+
* without importing from each other — Node consumers keep their
|
|
17
|
+
* existing import path, fetch-first consumers keep theirs, and the
|
|
18
|
+
* diff-risk from the previous sibling copies is gone.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
type HideToolsByAudienceConfig = readonly string[] | {
|
|
22
|
+
audiences: readonly string[];
|
|
23
|
+
bypassWhen?: ApplyHideToolsByAudienceOptions['bypassWhen'];
|
|
24
|
+
};
|
|
25
|
+
|
|
7
26
|
/**
|
|
8
27
|
* `registerPayableTool(server, name, options)` — one-liner for registering
|
|
9
28
|
* a paywall-protected MCP tool on the official `@modelcontextprotocol/sdk`
|
|
@@ -177,20 +196,40 @@ interface CreateSolvaPayMcpServerOptions extends BuildSolvaPayDescriptorsOptions
|
|
|
177
196
|
* tool whose `_meta.audience` matches one of these values. The
|
|
178
197
|
* tools stay `enabled: true` so `tools/call` still reaches their
|
|
179
198
|
* handlers — this option only affects the `tools/list` response
|
|
180
|
-
* shape. Pass `['ui']`
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* `
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
199
|
+
* shape. Pass `['ui']` to keep the LLM-facing catalogue narrow to
|
|
200
|
+
* the four intent tools (`upgrade` / `manage_account` /
|
|
201
|
+
* `activate_plan` / `topup`) plus your own merchant-registered
|
|
202
|
+
* data tools, while leaving the seven UI transport tools
|
|
203
|
+
* (`create_payment_intent`, etc.) callable for the SolvaPay
|
|
204
|
+
* iframe.
|
|
205
|
+
*
|
|
206
|
+
* # ChatGPT auto-bypass
|
|
207
|
+
*
|
|
208
|
+
* ChatGPT's Custom Connector gateway re-validates iframe-initiated
|
|
209
|
+
* `tools/call` against the cached `tools/list` catalog, so any
|
|
210
|
+
* tool hidden by this option becomes uncallable from the embedded
|
|
211
|
+
* iframe and surfaces in the UI as `MCP error -32000: MCP Resource
|
|
212
|
+
* not found`. To preserve the cleaner LLM catalog on every other
|
|
213
|
+
* host while keeping the iframe working on ChatGPT, the SDK
|
|
214
|
+
* auto-detects ChatGPT-originated `tools/list` requests (matching
|
|
215
|
+
* `request.headers['user-agent']` and the post-`initialize`
|
|
216
|
+
* `clientInfo.name` against `/openai-mcp/i`) and returns the full
|
|
217
|
+
* catalog to them. The detection is verified live against
|
|
218
|
+
* `openai-mcp/1.0.0 (ChatGPT)` and the broad pattern survives a UA
|
|
219
|
+
* version bump.
|
|
220
|
+
*
|
|
221
|
+
* To extend the bypass to a future iframe-capable host, pass the
|
|
222
|
+
* object form: `{ audiences: ['ui'], bypassWhen: ctx => … }`.
|
|
223
|
+
*
|
|
224
|
+
* To disable the bypass and apply the filter unconditionally
|
|
225
|
+
* (e.g. on a known text-only deployment), pass `{ audiences:
|
|
226
|
+
* ['ui'], bypassWhen: () => false }`.
|
|
188
227
|
*/
|
|
189
|
-
hideToolsByAudience?:
|
|
228
|
+
hideToolsByAudience?: HideToolsByAudienceConfig;
|
|
190
229
|
}
|
|
191
230
|
/**
|
|
192
231
|
* Build the MCP server and register the full SolvaPay tool surface.
|
|
193
232
|
*/
|
|
194
233
|
declare function createSolvaPayMcpServer(options: CreateSolvaPayMcpServerOptions): McpServer;
|
|
195
234
|
|
|
196
|
-
export { type AdditionalToolsContext, type CreateSolvaPayMcpServerOptions, type RegisterPayableToolOptions, createSolvaPayMcpServer, registerPayableTool };
|
|
235
|
+
export { type AdditionalToolsContext, type CreateSolvaPayMcpServerOptions, type HideToolsByAudienceConfig, type RegisterPayableToolOptions, createSolvaPayMcpServer, registerPayableTool };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyHideToolsByAudience,
|
|
3
3
|
buildSolvaPayMcpServer,
|
|
4
|
+
normaliseHideToolsByAudience,
|
|
4
5
|
registerPayableTool
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-RWJ6GBM5.js";
|
|
6
7
|
|
|
7
8
|
// src/server.ts
|
|
8
9
|
function createSolvaPayMcpServer(options) {
|
|
@@ -35,7 +36,8 @@ function createSolvaPayMcpServer(options) {
|
|
|
35
36
|
};
|
|
36
37
|
additionalTools({ server, solvaPay, resourceUri, productRef, registerPayable });
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
const { audiences, options: filterOptions } = normaliseHideToolsByAudience(hideToolsByAudience);
|
|
40
|
+
applyHideToolsByAudience(server, audiences, filterOptions);
|
|
39
41
|
return server;
|
|
40
42
|
}
|
|
41
43
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solvapay/mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Official @modelcontextprotocol/sdk + @modelcontextprotocol/ext-apps adapter for the SolvaPay MCP toolbox (createSolvaPayMcpServer, registerPayableTool) with ./fetch + ./express subpath exports for runtime-specific OAuth bridges.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@modelcontextprotocol/ext-apps": "^1.5.0",
|
|
44
44
|
"@modelcontextprotocol/sdk": "^1.28.0",
|
|
45
45
|
"zod": "^3.25.0 || ^4.0.0",
|
|
46
|
-
"@solvapay/mcp-core": "0.2.
|
|
46
|
+
"@solvapay/mcp-core": "0.2.4",
|
|
47
47
|
"@solvapay/server": "^1.0.11"
|
|
48
48
|
},
|
|
49
49
|
"peerDependenciesMeta": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"typescript": "^5.9.3",
|
|
59
59
|
"vitest": "^4.1.2",
|
|
60
60
|
"zod": "^4.3.6",
|
|
61
|
-
"@solvapay/mcp-core": "0.2.
|
|
61
|
+
"@solvapay/mcp-core": "0.2.4",
|
|
62
62
|
"@solvapay/server": "1.0.11",
|
|
63
63
|
"@solvapay/test-utils": "^0.0.0"
|
|
64
64
|
},
|