@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.
- package/README.md +35 -9
- package/dist/chunk-3VDAADZU.js +211 -0
- package/dist/express/index.cjs +504 -0
- package/dist/express/index.d.cts +65 -0
- package/dist/express/index.d.ts +65 -0
- package/dist/express/index.js +481 -0
- package/dist/fetch/index.cjs +787 -0
- package/dist/fetch/index.d.cts +238 -0
- package/dist/fetch/index.d.ts +238 -0
- package/dist/fetch/index.js +565 -0
- package/dist/index.cjs +116 -75
- package/dist/index.d.cts +46 -30
- package/dist/index.d.ts +46 -30
- package/dist/index.js +14 -171
- package/package.json +16 -7
package/dist/index.js
CHANGED
|
@@ -1,130 +1,10 @@
|
|
|
1
|
-
// src/server.ts
|
|
2
|
-
import {
|
|
3
|
-
registerAppResource,
|
|
4
|
-
registerAppTool as registerAppTool2,
|
|
5
|
-
RESOURCE_MIME_TYPE
|
|
6
|
-
} from "@modelcontextprotocol/ext-apps/server";
|
|
7
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
-
import {
|
|
9
|
-
buildSolvaPayDescriptors
|
|
10
|
-
} from "@solvapay/mcp-core";
|
|
11
|
-
|
|
12
|
-
// src/registerPayableTool.ts
|
|
13
|
-
import { registerAppTool } from "@modelcontextprotocol/ext-apps/server";
|
|
14
1
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
solvaPay,
|
|
20
|
-
resourceUri,
|
|
21
|
-
schema,
|
|
22
|
-
product,
|
|
23
|
-
title,
|
|
24
|
-
description,
|
|
25
|
-
handler,
|
|
26
|
-
buildBootstrap,
|
|
27
|
-
getCustomerRef,
|
|
28
|
-
meta,
|
|
29
|
-
annotations,
|
|
30
|
-
icons
|
|
31
|
-
} = options;
|
|
32
|
-
const protectedHandler = buildPayableHandler(
|
|
33
|
-
solvaPay,
|
|
34
|
-
{ product, resourceUri, buildBootstrap, getCustomerRef },
|
|
35
|
-
handler
|
|
36
|
-
);
|
|
37
|
-
const baseMeta = meta ?? {};
|
|
38
|
-
const baseUi = baseMeta.ui ?? {};
|
|
39
|
-
const hasIcons = icons !== void 0 && icons.length > 0;
|
|
40
|
-
const mergedUi = {
|
|
41
|
-
resourceUri,
|
|
42
|
-
...baseUi,
|
|
43
|
-
...hasIcons ? { icons } : {}
|
|
44
|
-
};
|
|
45
|
-
const toolMeta = { ...baseMeta, ui: mergedUi };
|
|
46
|
-
const effectiveAnnotations = {
|
|
47
|
-
readOnlyHint: true,
|
|
48
|
-
openWorldHint: true,
|
|
49
|
-
...annotations
|
|
50
|
-
};
|
|
51
|
-
return registerAppTool(
|
|
52
|
-
server,
|
|
53
|
-
name,
|
|
54
|
-
// Note: `registerAppTool`'s config type is stricter than ours —
|
|
55
|
-
// casting so `title` / `description` stay optional and the input
|
|
56
|
-
// schema flows through correctly at the registration layer.
|
|
57
|
-
{
|
|
58
|
-
...title !== void 0 ? { title } : {},
|
|
59
|
-
...description !== void 0 ? { description } : {},
|
|
60
|
-
...schema !== void 0 ? { inputSchema: schema } : {},
|
|
61
|
-
_meta: toolMeta,
|
|
62
|
-
annotations: effectiveAnnotations,
|
|
63
|
-
...icons !== void 0 && icons.length > 0 ? { icons } : {}
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
-
},
|
|
66
|
-
async (args, extra) => await protectedHandler(args, extra)
|
|
67
|
-
);
|
|
68
|
-
}
|
|
2
|
+
applyHideToolsByAudience,
|
|
3
|
+
buildSolvaPayMcpServer,
|
|
4
|
+
registerPayableTool
|
|
5
|
+
} from "./chunk-3VDAADZU.js";
|
|
69
6
|
|
|
70
7
|
// src/server.ts
|
|
71
|
-
function registerDescriptor(server, tool) {
|
|
72
|
-
const baseMeta = tool.meta ?? {};
|
|
73
|
-
const baseUi = baseMeta.ui ?? {};
|
|
74
|
-
const metaWithIcons = tool.icons && tool.icons.length > 0 ? { ...baseMeta, ui: { ...baseUi, icons: tool.icons } } : baseMeta;
|
|
75
|
-
registerAppTool2(
|
|
76
|
-
server,
|
|
77
|
-
tool.name,
|
|
78
|
-
{
|
|
79
|
-
...tool.title !== void 0 ? { title: tool.title } : {},
|
|
80
|
-
description: tool.description,
|
|
81
|
-
inputSchema: tool.inputSchema,
|
|
82
|
-
_meta: metaWithIcons,
|
|
83
|
-
...tool.annotations !== void 0 ? { annotations: tool.annotations } : {},
|
|
84
|
-
...tool.icons !== void 0 ? { icons: tool.icons } : {}
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
-
},
|
|
87
|
-
// `SolvaPayCallToolResult` is a structural subset of the official
|
|
88
|
-
// SDK's `CallToolResult`; cast to erase the extra-narrow `resource`
|
|
89
|
-
// block typing the SDK expects on `{ type: 'resource' }` content.
|
|
90
|
-
async (args, extra) => await tool.handler(
|
|
91
|
-
args,
|
|
92
|
-
extra
|
|
93
|
-
)
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
function registerPromptDescriptor(server, prompt) {
|
|
97
|
-
const config = { description: prompt.description };
|
|
98
|
-
if (prompt.title !== void 0) config.title = prompt.title;
|
|
99
|
-
if (prompt.argsSchema !== void 0) config.argsSchema = prompt.argsSchema;
|
|
100
|
-
server.registerPrompt(
|
|
101
|
-
prompt.name,
|
|
102
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
-
config,
|
|
104
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
|
-
async (args) => await prompt.handler(args ?? {})
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
function registerDocsResource(server, docs) {
|
|
109
|
-
server.registerResource(
|
|
110
|
-
docs.name,
|
|
111
|
-
docs.uri,
|
|
112
|
-
{
|
|
113
|
-
...docs.title !== void 0 ? { title: docs.title } : {},
|
|
114
|
-
description: docs.description,
|
|
115
|
-
mimeType: docs.mimeType
|
|
116
|
-
},
|
|
117
|
-
async () => ({
|
|
118
|
-
contents: [
|
|
119
|
-
{
|
|
120
|
-
uri: docs.uri,
|
|
121
|
-
mimeType: docs.mimeType,
|
|
122
|
-
text: await docs.readBody()
|
|
123
|
-
}
|
|
124
|
-
]
|
|
125
|
-
})
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
8
|
function createSolvaPayMcpServer(options) {
|
|
129
9
|
const {
|
|
130
10
|
additionalTools,
|
|
@@ -132,67 +12,30 @@ function createSolvaPayMcpServer(options) {
|
|
|
132
12
|
registerDocsResources = true,
|
|
133
13
|
serverName,
|
|
134
14
|
serverVersion = "1.0.0",
|
|
15
|
+
hideToolsByAudience,
|
|
135
16
|
...descriptorOptions
|
|
136
17
|
} = options;
|
|
137
|
-
const {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
for (const prompt of prompts) {
|
|
145
|
-
registerPromptDescriptor(server, prompt);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
if (registerDocsResources) {
|
|
149
|
-
for (const docs of docsResources) {
|
|
150
|
-
registerDocsResource(server, docs);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
registerAppResource(
|
|
154
|
-
server,
|
|
155
|
-
resource.uri,
|
|
156
|
-
resource.uri,
|
|
157
|
-
{
|
|
158
|
-
mimeType: RESOURCE_MIME_TYPE,
|
|
159
|
-
_meta: {
|
|
160
|
-
ui: {
|
|
161
|
-
csp: resource.csp,
|
|
162
|
-
prefersBorder: true
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
async () => ({
|
|
167
|
-
contents: [
|
|
168
|
-
{
|
|
169
|
-
uri: resource.uri,
|
|
170
|
-
mimeType: RESOURCE_MIME_TYPE,
|
|
171
|
-
text: await resource.readHtml(),
|
|
172
|
-
_meta: {
|
|
173
|
-
ui: {
|
|
174
|
-
csp: resource.csp,
|
|
175
|
-
prefersBorder: true
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
]
|
|
180
|
-
})
|
|
181
|
-
);
|
|
18
|
+
const { server, descriptors } = buildSolvaPayMcpServer({
|
|
19
|
+
...descriptorOptions,
|
|
20
|
+
registerPrompts,
|
|
21
|
+
registerDocsResources,
|
|
22
|
+
...serverName !== void 0 ? { serverName } : {},
|
|
23
|
+
serverVersion
|
|
24
|
+
});
|
|
182
25
|
if (additionalTools) {
|
|
183
26
|
const { solvaPay, productRef, resourceUri } = descriptorOptions;
|
|
184
27
|
const registerPayable = (name, opts) => {
|
|
185
28
|
registerPayableTool(server, name, {
|
|
186
29
|
solvaPay,
|
|
187
|
-
resourceUri,
|
|
188
30
|
...opts,
|
|
189
31
|
product: opts.product ?? productRef,
|
|
190
|
-
buildBootstrap: opts.buildBootstrap ?? buildBootstrapPayload
|
|
32
|
+
buildBootstrap: opts.buildBootstrap ?? descriptors.buildBootstrapPayload
|
|
191
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
192
34
|
});
|
|
193
35
|
};
|
|
194
36
|
additionalTools({ server, solvaPay, resourceUri, productRef, registerPayable });
|
|
195
37
|
}
|
|
38
|
+
applyHideToolsByAudience(server, hideToolsByAudience);
|
|
196
39
|
return server;
|
|
197
40
|
}
|
|
198
41
|
export {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solvapay/mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Official @modelcontextprotocol/sdk + @modelcontextprotocol/ext-apps adapter for the SolvaPay MCP toolbox (createSolvaPayMcpServer, registerPayableTool).",
|
|
3
|
+
"version": "0.2.0",
|
|
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",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -11,6 +11,16 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.js",
|
|
13
13
|
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./fetch": {
|
|
16
|
+
"types": "./dist/fetch/index.d.ts",
|
|
17
|
+
"import": "./dist/fetch/index.js",
|
|
18
|
+
"require": "./dist/fetch/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./express": {
|
|
21
|
+
"types": "./dist/express/index.d.ts",
|
|
22
|
+
"import": "./dist/express/index.js",
|
|
23
|
+
"require": "./dist/express/index.cjs"
|
|
14
24
|
}
|
|
15
25
|
},
|
|
16
26
|
"files": [
|
|
@@ -29,14 +39,12 @@
|
|
|
29
39
|
"node": ">=18.17"
|
|
30
40
|
},
|
|
31
41
|
"sideEffects": false,
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"@solvapay/mcp-core": "0.1.0"
|
|
34
|
-
},
|
|
35
42
|
"peerDependencies": {
|
|
36
43
|
"@modelcontextprotocol/ext-apps": "^1.5.0",
|
|
37
44
|
"@modelcontextprotocol/sdk": "^1.28.0",
|
|
38
45
|
"zod": "^3.25.0 || ^4.0.0",
|
|
39
|
-
"@solvapay/
|
|
46
|
+
"@solvapay/mcp-core": "0.2.0",
|
|
47
|
+
"@solvapay/server": "^1.0.8"
|
|
40
48
|
},
|
|
41
49
|
"peerDependenciesMeta": {
|
|
42
50
|
"zod": {
|
|
@@ -50,7 +58,8 @@
|
|
|
50
58
|
"typescript": "^5.9.3",
|
|
51
59
|
"vitest": "^4.1.2",
|
|
52
60
|
"zod": "^4.3.6",
|
|
53
|
-
"@solvapay/
|
|
61
|
+
"@solvapay/mcp-core": "0.2.0",
|
|
62
|
+
"@solvapay/server": "1.0.8",
|
|
54
63
|
"@solvapay/test-utils": "^0.0.0"
|
|
55
64
|
},
|
|
56
65
|
"scripts": {
|