@imagekit/api-mcp 7.2.2 → 7.4.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/auth.d.mts +6 -0
- package/auth.d.mts.map +1 -0
- package/auth.d.ts +6 -0
- package/auth.d.ts.map +1 -0
- package/{headers.mjs → auth.js} +21 -2
- package/auth.js.map +1 -0
- package/{headers.js → auth.mjs} +16 -6
- package/auth.mjs.map +1 -0
- package/code-tool-paths.cjs +8 -0
- package/code-tool-paths.cjs.map +1 -0
- package/code-tool-paths.d.cts +2 -0
- package/code-tool-paths.d.cts.map +1 -0
- package/code-tool-types.d.mts.map +1 -1
- package/code-tool-types.d.ts.map +1 -1
- package/code-tool-worker.d.mts +5 -0
- package/code-tool-worker.d.mts.map +1 -0
- package/code-tool-worker.d.ts +5 -0
- package/code-tool-worker.d.ts.map +1 -0
- package/code-tool-worker.js +314 -0
- package/code-tool-worker.js.map +1 -0
- package/code-tool-worker.mjs +276 -0
- package/code-tool-worker.mjs.map +1 -0
- package/code-tool.d.mts +11 -2
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts +11 -2
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +285 -42
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +253 -43
- package/code-tool.mjs.map +1 -1
- package/docs-search-tool.d.mts +11 -3
- package/docs-search-tool.d.mts.map +1 -1
- package/docs-search-tool.d.ts +11 -3
- package/docs-search-tool.d.ts.map +1 -1
- package/docs-search-tool.js +58 -5
- package/docs-search-tool.js.map +1 -1
- package/docs-search-tool.mjs +57 -5
- package/docs-search-tool.mjs.map +1 -1
- package/http.d.mts +6 -3
- package/http.d.mts.map +1 -1
- package/http.d.ts +6 -3
- package/http.d.ts.map +1 -1
- package/http.js +130 -28
- package/http.js.map +1 -1
- package/http.mjs +130 -28
- package/http.mjs.map +1 -1
- package/index.js +17 -12
- package/index.js.map +1 -1
- package/index.mjs +17 -12
- package/index.mjs.map +1 -1
- package/instructions.d.mts +5 -0
- package/instructions.d.mts.map +1 -0
- package/instructions.d.ts +5 -0
- package/instructions.d.ts.map +1 -0
- package/instructions.js +61 -0
- package/instructions.js.map +1 -0
- package/instructions.mjs +55 -0
- package/instructions.mjs.map +1 -0
- package/local-docs-search.d.mts +28 -0
- package/local-docs-search.d.mts.map +1 -0
- package/local-docs-search.d.ts +28 -0
- package/local-docs-search.d.ts.map +1 -0
- package/local-docs-search.js +2807 -0
- package/local-docs-search.js.map +1 -0
- package/local-docs-search.mjs +2767 -0
- package/local-docs-search.mjs.map +1 -0
- package/logger.d.mts +7 -0
- package/logger.d.mts.map +1 -0
- package/logger.d.ts +7 -0
- package/logger.d.ts.map +1 -0
- package/logger.js +29 -0
- package/logger.js.map +1 -0
- package/logger.mjs +22 -0
- package/logger.mjs.map +1 -0
- package/methods.d.mts +10 -0
- package/methods.d.mts.map +1 -0
- package/methods.d.ts +10 -0
- package/methods.d.ts.map +1 -0
- package/methods.js +349 -0
- package/methods.js.map +1 -0
- package/methods.mjs +345 -0
- package/methods.mjs.map +1 -0
- package/options.d.mts +12 -0
- package/options.d.mts.map +1 -1
- package/options.d.ts +12 -0
- package/options.d.ts.map +1 -1
- package/options.js +81 -12
- package/options.js.map +1 -1
- package/options.mjs +81 -12
- package/options.mjs.map +1 -1
- package/package.json +89 -15
- package/server.d.mts +18 -11
- package/server.d.mts.map +1 -1
- package/server.d.ts +18 -11
- package/server.d.ts.map +1 -1
- package/server.js +89 -49
- package/server.js.map +1 -1
- package/server.mjs +88 -45
- package/server.mjs.map +1 -1
- package/src/{headers.ts → auth.ts} +18 -1
- package/src/code-tool-paths.cts +5 -0
- package/src/code-tool-types.ts +1 -0
- package/src/code-tool-worker.ts +327 -0
- package/src/code-tool.ts +339 -55
- package/src/docs-search-tool.ts +86 -7
- package/src/http.ts +154 -33
- package/src/index.ts +19 -13
- package/src/instructions.ts +83 -0
- package/src/local-docs-search.ts +3380 -0
- package/src/logger.ts +28 -0
- package/src/methods.ts +370 -0
- package/src/options.ts +105 -12
- package/src/server.ts +111 -57
- package/src/stdio.ts +9 -4
- package/src/types.ts +15 -4
- package/src/util.ts +25 -0
- package/stdio.d.mts +2 -1
- package/stdio.d.mts.map +1 -1
- package/stdio.d.ts +2 -1
- package/stdio.d.ts.map +1 -1
- package/stdio.js +8 -4
- package/stdio.js.map +1 -1
- package/stdio.mjs +8 -4
- package/stdio.mjs.map +1 -1
- package/types.d.mts +14 -1
- package/types.d.mts.map +1 -1
- package/types.d.ts +14 -1
- package/types.d.ts.map +1 -1
- package/types.js.map +1 -1
- package/types.mjs.map +1 -1
- package/util.d.mts +4 -0
- package/util.d.mts.map +1 -0
- package/util.d.ts +4 -0
- package/util.d.ts.map +1 -0
- package/util.js +30 -0
- package/util.js.map +1 -0
- package/util.mjs +24 -0
- package/util.mjs.map +1 -0
- package/headers.d.mts +0 -4
- package/headers.d.mts.map +0 -1
- package/headers.d.ts +0 -4
- package/headers.d.ts.map +0 -1
- package/headers.js.map +0 -1
- package/headers.mjs.map +0 -1
package/src/logger.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { pino, type Level, type Logger } from 'pino';
|
|
4
|
+
import pretty from 'pino-pretty';
|
|
5
|
+
|
|
6
|
+
let _logger: Logger | undefined;
|
|
7
|
+
|
|
8
|
+
export function configureLogger({ level, pretty: usePretty }: { level: Level; pretty: boolean }): void {
|
|
9
|
+
_logger = pino(
|
|
10
|
+
{
|
|
11
|
+
level,
|
|
12
|
+
timestamp: pino.stdTimeFunctions.isoTime,
|
|
13
|
+
formatters: {
|
|
14
|
+
level(label) {
|
|
15
|
+
return { level: label };
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
usePretty ? pretty({ colorize: true, levelFirst: true, destination: 2 }) : process.stderr,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getLogger(): Logger {
|
|
24
|
+
if (!_logger) {
|
|
25
|
+
throw new Error('Logger has not been configured. Call configureLogger() before using the logger.');
|
|
26
|
+
}
|
|
27
|
+
return _logger;
|
|
28
|
+
}
|
package/src/methods.ts
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { McpOptions } from './options';
|
|
4
|
+
|
|
5
|
+
export type SdkMethod = {
|
|
6
|
+
clientCallName: string;
|
|
7
|
+
fullyQualifiedName: string;
|
|
8
|
+
httpMethod?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'query';
|
|
9
|
+
httpPath?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const sdkMethods: SdkMethod[] = [
|
|
13
|
+
{
|
|
14
|
+
clientCallName: 'client.customMetadataFields.create',
|
|
15
|
+
fullyQualifiedName: 'customMetadataFields.create',
|
|
16
|
+
httpMethod: 'post',
|
|
17
|
+
httpPath: '/v1/customMetadataFields',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
clientCallName: 'client.customMetadataFields.update',
|
|
21
|
+
fullyQualifiedName: 'customMetadataFields.update',
|
|
22
|
+
httpMethod: 'patch',
|
|
23
|
+
httpPath: '/v1/customMetadataFields/{id}',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
clientCallName: 'client.customMetadataFields.list',
|
|
27
|
+
fullyQualifiedName: 'customMetadataFields.list',
|
|
28
|
+
httpMethod: 'get',
|
|
29
|
+
httpPath: '/v1/customMetadataFields',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
clientCallName: 'client.customMetadataFields.delete',
|
|
33
|
+
fullyQualifiedName: 'customMetadataFields.delete',
|
|
34
|
+
httpMethod: 'delete',
|
|
35
|
+
httpPath: '/v1/customMetadataFields/{id}',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
clientCallName: 'client.files.update',
|
|
39
|
+
fullyQualifiedName: 'files.update',
|
|
40
|
+
httpMethod: 'patch',
|
|
41
|
+
httpPath: '/v1/files/{fileId}/details',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
clientCallName: 'client.files.delete',
|
|
45
|
+
fullyQualifiedName: 'files.delete',
|
|
46
|
+
httpMethod: 'delete',
|
|
47
|
+
httpPath: '/v1/files/{fileId}',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
clientCallName: 'client.files.copy',
|
|
51
|
+
fullyQualifiedName: 'files.copy',
|
|
52
|
+
httpMethod: 'post',
|
|
53
|
+
httpPath: '/v1/files/copy',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
clientCallName: 'client.files.get',
|
|
57
|
+
fullyQualifiedName: 'files.get',
|
|
58
|
+
httpMethod: 'get',
|
|
59
|
+
httpPath: '/v1/files/{fileId}/details',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
clientCallName: 'client.files.move',
|
|
63
|
+
fullyQualifiedName: 'files.move',
|
|
64
|
+
httpMethod: 'post',
|
|
65
|
+
httpPath: '/v1/files/move',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
clientCallName: 'client.files.rename',
|
|
69
|
+
fullyQualifiedName: 'files.rename',
|
|
70
|
+
httpMethod: 'put',
|
|
71
|
+
httpPath: '/v1/files/rename',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
clientCallName: 'client.files.upload',
|
|
75
|
+
fullyQualifiedName: 'files.upload',
|
|
76
|
+
httpMethod: 'post',
|
|
77
|
+
httpPath: '/api/v1/files/upload',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
clientCallName: 'client.files.bulk.delete',
|
|
81
|
+
fullyQualifiedName: 'files.bulk.delete',
|
|
82
|
+
httpMethod: 'post',
|
|
83
|
+
httpPath: '/v1/files/batch/deleteByFileIds',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
clientCallName: 'client.files.bulk.addTags',
|
|
87
|
+
fullyQualifiedName: 'files.bulk.addTags',
|
|
88
|
+
httpMethod: 'post',
|
|
89
|
+
httpPath: '/v1/files/addTags',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
clientCallName: 'client.files.bulk.removeAITags',
|
|
93
|
+
fullyQualifiedName: 'files.bulk.removeAITags',
|
|
94
|
+
httpMethod: 'post',
|
|
95
|
+
httpPath: '/v1/files/removeAITags',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
clientCallName: 'client.files.bulk.removeTags',
|
|
99
|
+
fullyQualifiedName: 'files.bulk.removeTags',
|
|
100
|
+
httpMethod: 'post',
|
|
101
|
+
httpPath: '/v1/files/removeTags',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
clientCallName: 'client.files.versions.list',
|
|
105
|
+
fullyQualifiedName: 'files.versions.list',
|
|
106
|
+
httpMethod: 'get',
|
|
107
|
+
httpPath: '/v1/files/{fileId}/versions',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
clientCallName: 'client.files.versions.delete',
|
|
111
|
+
fullyQualifiedName: 'files.versions.delete',
|
|
112
|
+
httpMethod: 'delete',
|
|
113
|
+
httpPath: '/v1/files/{fileId}/versions/{versionId}',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
clientCallName: 'client.files.versions.get',
|
|
117
|
+
fullyQualifiedName: 'files.versions.get',
|
|
118
|
+
httpMethod: 'get',
|
|
119
|
+
httpPath: '/v1/files/{fileId}/versions/{versionId}',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
clientCallName: 'client.files.versions.restore',
|
|
123
|
+
fullyQualifiedName: 'files.versions.restore',
|
|
124
|
+
httpMethod: 'put',
|
|
125
|
+
httpPath: '/v1/files/{fileId}/versions/{versionId}/restore',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
clientCallName: 'client.files.metadata.get',
|
|
129
|
+
fullyQualifiedName: 'files.metadata.get',
|
|
130
|
+
httpMethod: 'get',
|
|
131
|
+
httpPath: '/v1/files/{fileId}/metadata',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
clientCallName: 'client.files.metadata.getFromURL',
|
|
135
|
+
fullyQualifiedName: 'files.metadata.getFromURL',
|
|
136
|
+
httpMethod: 'get',
|
|
137
|
+
httpPath: '/v1/metadata',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
clientCallName: 'client.savedExtensions.create',
|
|
141
|
+
fullyQualifiedName: 'savedExtensions.create',
|
|
142
|
+
httpMethod: 'post',
|
|
143
|
+
httpPath: '/v1/saved-extensions',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
clientCallName: 'client.savedExtensions.update',
|
|
147
|
+
fullyQualifiedName: 'savedExtensions.update',
|
|
148
|
+
httpMethod: 'patch',
|
|
149
|
+
httpPath: '/v1/saved-extensions/{id}',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
clientCallName: 'client.savedExtensions.list',
|
|
153
|
+
fullyQualifiedName: 'savedExtensions.list',
|
|
154
|
+
httpMethod: 'get',
|
|
155
|
+
httpPath: '/v1/saved-extensions',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
clientCallName: 'client.savedExtensions.delete',
|
|
159
|
+
fullyQualifiedName: 'savedExtensions.delete',
|
|
160
|
+
httpMethod: 'delete',
|
|
161
|
+
httpPath: '/v1/saved-extensions/{id}',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
clientCallName: 'client.savedExtensions.get',
|
|
165
|
+
fullyQualifiedName: 'savedExtensions.get',
|
|
166
|
+
httpMethod: 'get',
|
|
167
|
+
httpPath: '/v1/saved-extensions/{id}',
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
clientCallName: 'client.assets.list',
|
|
171
|
+
fullyQualifiedName: 'assets.list',
|
|
172
|
+
httpMethod: 'get',
|
|
173
|
+
httpPath: '/v1/files',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
clientCallName: 'client.cache.invalidation.create',
|
|
177
|
+
fullyQualifiedName: 'cache.invalidation.create',
|
|
178
|
+
httpMethod: 'post',
|
|
179
|
+
httpPath: '/v1/files/purge',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
clientCallName: 'client.cache.invalidation.get',
|
|
183
|
+
fullyQualifiedName: 'cache.invalidation.get',
|
|
184
|
+
httpMethod: 'get',
|
|
185
|
+
httpPath: '/v1/files/purge/{requestId}',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
clientCallName: 'client.folders.create',
|
|
189
|
+
fullyQualifiedName: 'folders.create',
|
|
190
|
+
httpMethod: 'post',
|
|
191
|
+
httpPath: '/v1/folder',
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
clientCallName: 'client.folders.delete',
|
|
195
|
+
fullyQualifiedName: 'folders.delete',
|
|
196
|
+
httpMethod: 'delete',
|
|
197
|
+
httpPath: '/v1/folder',
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
clientCallName: 'client.folders.copy',
|
|
201
|
+
fullyQualifiedName: 'folders.copy',
|
|
202
|
+
httpMethod: 'post',
|
|
203
|
+
httpPath: '/v1/bulkJobs/copyFolder',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
clientCallName: 'client.folders.move',
|
|
207
|
+
fullyQualifiedName: 'folders.move',
|
|
208
|
+
httpMethod: 'post',
|
|
209
|
+
httpPath: '/v1/bulkJobs/moveFolder',
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
clientCallName: 'client.folders.rename',
|
|
213
|
+
fullyQualifiedName: 'folders.rename',
|
|
214
|
+
httpMethod: 'post',
|
|
215
|
+
httpPath: '/v1/bulkJobs/renameFolder',
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
clientCallName: 'client.folders.job.get',
|
|
219
|
+
fullyQualifiedName: 'folders.job.get',
|
|
220
|
+
httpMethod: 'get',
|
|
221
|
+
httpPath: '/v1/bulkJobs/{jobId}',
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
clientCallName: 'client.accounts.usage.get',
|
|
225
|
+
fullyQualifiedName: 'accounts.usage.get',
|
|
226
|
+
httpMethod: 'get',
|
|
227
|
+
httpPath: '/v1/accounts/usage',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
clientCallName: 'client.accounts.origins.create',
|
|
231
|
+
fullyQualifiedName: 'accounts.origins.create',
|
|
232
|
+
httpMethod: 'post',
|
|
233
|
+
httpPath: '/v1/accounts/origins',
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
clientCallName: 'client.accounts.origins.update',
|
|
237
|
+
fullyQualifiedName: 'accounts.origins.update',
|
|
238
|
+
httpMethod: 'put',
|
|
239
|
+
httpPath: '/v1/accounts/origins/{id}',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
clientCallName: 'client.accounts.origins.list',
|
|
243
|
+
fullyQualifiedName: 'accounts.origins.list',
|
|
244
|
+
httpMethod: 'get',
|
|
245
|
+
httpPath: '/v1/accounts/origins',
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
clientCallName: 'client.accounts.origins.delete',
|
|
249
|
+
fullyQualifiedName: 'accounts.origins.delete',
|
|
250
|
+
httpMethod: 'delete',
|
|
251
|
+
httpPath: '/v1/accounts/origins/{id}',
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
clientCallName: 'client.accounts.origins.get',
|
|
255
|
+
fullyQualifiedName: 'accounts.origins.get',
|
|
256
|
+
httpMethod: 'get',
|
|
257
|
+
httpPath: '/v1/accounts/origins/{id}',
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
clientCallName: 'client.accounts.urlEndpoints.create',
|
|
261
|
+
fullyQualifiedName: 'accounts.urlEndpoints.create',
|
|
262
|
+
httpMethod: 'post',
|
|
263
|
+
httpPath: '/v1/accounts/url-endpoints',
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
clientCallName: 'client.accounts.urlEndpoints.update',
|
|
267
|
+
fullyQualifiedName: 'accounts.urlEndpoints.update',
|
|
268
|
+
httpMethod: 'put',
|
|
269
|
+
httpPath: '/v1/accounts/url-endpoints/{id}',
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
clientCallName: 'client.accounts.urlEndpoints.list',
|
|
273
|
+
fullyQualifiedName: 'accounts.urlEndpoints.list',
|
|
274
|
+
httpMethod: 'get',
|
|
275
|
+
httpPath: '/v1/accounts/url-endpoints',
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
clientCallName: 'client.accounts.urlEndpoints.delete',
|
|
279
|
+
fullyQualifiedName: 'accounts.urlEndpoints.delete',
|
|
280
|
+
httpMethod: 'delete',
|
|
281
|
+
httpPath: '/v1/accounts/url-endpoints/{id}',
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
clientCallName: 'client.accounts.urlEndpoints.get',
|
|
285
|
+
fullyQualifiedName: 'accounts.urlEndpoints.get',
|
|
286
|
+
httpMethod: 'get',
|
|
287
|
+
httpPath: '/v1/accounts/url-endpoints/{id}',
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
clientCallName: 'client.beta.v2.files.upload',
|
|
291
|
+
fullyQualifiedName: 'beta.v2.files.upload',
|
|
292
|
+
httpMethod: 'post',
|
|
293
|
+
httpPath: '/api/v2/files/upload',
|
|
294
|
+
},
|
|
295
|
+
{ clientCallName: 'client.webhooks.unsafeUnwrap', fullyQualifiedName: 'webhooks.unsafeUnwrap' },
|
|
296
|
+
{ clientCallName: 'client.webhooks.unwrap', fullyQualifiedName: 'webhooks.unwrap' },
|
|
297
|
+
];
|
|
298
|
+
|
|
299
|
+
function allowedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] | undefined {
|
|
300
|
+
if (!options) {
|
|
301
|
+
return undefined;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
let allowedMethods: SdkMethod[];
|
|
305
|
+
|
|
306
|
+
if (options.codeAllowHttpGets || options.codeAllowedMethods) {
|
|
307
|
+
// Start with nothing allowed and then add into it from options
|
|
308
|
+
let allowedMethodsSet = new Set<SdkMethod>();
|
|
309
|
+
|
|
310
|
+
if (options.codeAllowHttpGets) {
|
|
311
|
+
// Add all methods that map to an HTTP GET
|
|
312
|
+
sdkMethods
|
|
313
|
+
.filter((method) => method.httpMethod === 'get')
|
|
314
|
+
.forEach((method) => allowedMethodsSet.add(method));
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (options.codeAllowedMethods) {
|
|
318
|
+
// Add all methods that match any of the allowed regexps
|
|
319
|
+
const allowedRegexps = options.codeAllowedMethods.map((pattern) => {
|
|
320
|
+
try {
|
|
321
|
+
return new RegExp(pattern);
|
|
322
|
+
} catch (e) {
|
|
323
|
+
throw new Error(
|
|
324
|
+
`Invalid regex pattern for allowed method: "${pattern}": ${e instanceof Error ? e.message : e}`,
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
sdkMethods
|
|
330
|
+
.filter((method) => allowedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName)))
|
|
331
|
+
.forEach((method) => allowedMethodsSet.add(method));
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
allowedMethods = Array.from(allowedMethodsSet);
|
|
335
|
+
} else {
|
|
336
|
+
// Start with everything allowed
|
|
337
|
+
allowedMethods = [...sdkMethods];
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (options.codeBlockedMethods) {
|
|
341
|
+
// Filter down based on blocked regexps
|
|
342
|
+
const blockedRegexps = options.codeBlockedMethods.map((pattern) => {
|
|
343
|
+
try {
|
|
344
|
+
return new RegExp(pattern);
|
|
345
|
+
} catch (e) {
|
|
346
|
+
throw new Error(
|
|
347
|
+
`Invalid regex pattern for blocked method: "${pattern}": ${e instanceof Error ? e.message : e}`,
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
allowedMethods = allowedMethods.filter(
|
|
353
|
+
(method) => !blockedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName)),
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return allowedMethods;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export function blockedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] | undefined {
|
|
361
|
+
const allowedMethods = allowedMethodsForCodeTool(options);
|
|
362
|
+
if (!allowedMethods) {
|
|
363
|
+
return undefined;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const allowedSet = new Set(allowedMethods.map((method) => method.fullyQualifiedName));
|
|
367
|
+
|
|
368
|
+
// Return any methods that are not explicitly allowed
|
|
369
|
+
return sdkMethods.filter((method) => !allowedSet.has(method.fullyQualifiedName));
|
|
370
|
+
}
|
package/src/options.ts
CHANGED
|
@@ -1,46 +1,114 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
1
3
|
import qs from 'qs';
|
|
2
4
|
import yargs from 'yargs';
|
|
3
5
|
import { hideBin } from 'yargs/helpers';
|
|
4
6
|
import z from 'zod';
|
|
7
|
+
import { readEnv } from './util';
|
|
5
8
|
|
|
6
9
|
export type CLIOptions = McpOptions & {
|
|
10
|
+
debug: boolean;
|
|
11
|
+
logFormat: 'json' | 'pretty';
|
|
7
12
|
transport: 'stdio' | 'http';
|
|
8
13
|
port: number | undefined;
|
|
9
14
|
socket: string | undefined;
|
|
10
15
|
};
|
|
11
16
|
|
|
12
17
|
export type McpOptions = {
|
|
18
|
+
includeCodeTool?: boolean | undefined;
|
|
13
19
|
includeDocsTools?: boolean | undefined;
|
|
20
|
+
stainlessApiKey?: string | undefined;
|
|
21
|
+
docsSearchMode?: 'stainless-api' | 'local' | undefined;
|
|
22
|
+
docsDir?: string | undefined;
|
|
23
|
+
codeAllowHttpGets?: boolean | undefined;
|
|
24
|
+
codeAllowedMethods?: string[] | undefined;
|
|
25
|
+
codeBlockedMethods?: string[] | undefined;
|
|
26
|
+
codeExecutionMode: McpCodeExecutionMode;
|
|
27
|
+
customInstructionsPath?: string | undefined;
|
|
14
28
|
};
|
|
15
29
|
|
|
30
|
+
export type McpCodeExecutionMode = 'stainless-sandbox' | 'local';
|
|
31
|
+
|
|
16
32
|
export function parseCLIOptions(): CLIOptions {
|
|
17
33
|
const opts = yargs(hideBin(process.argv))
|
|
18
|
-
.option('
|
|
34
|
+
.option('code-allow-http-gets', {
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
description:
|
|
37
|
+
'Allow all code tool methods that map to HTTP GET operations. If all code-allow-* flags are unset, then everything is allowed.',
|
|
38
|
+
})
|
|
39
|
+
.option('code-allowed-methods', {
|
|
19
40
|
type: 'string',
|
|
20
41
|
array: true,
|
|
21
|
-
|
|
22
|
-
|
|
42
|
+
description:
|
|
43
|
+
'Methods to explicitly allow for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.',
|
|
23
44
|
})
|
|
24
|
-
.option('
|
|
45
|
+
.option('code-blocked-methods', {
|
|
25
46
|
type: 'string',
|
|
26
47
|
array: true,
|
|
27
|
-
|
|
28
|
-
|
|
48
|
+
description:
|
|
49
|
+
'Methods to explicitly block for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.',
|
|
29
50
|
})
|
|
30
|
-
.option('
|
|
51
|
+
.option('code-execution-mode', {
|
|
31
52
|
type: 'string',
|
|
32
|
-
choices: ['
|
|
33
|
-
default: '
|
|
34
|
-
description:
|
|
53
|
+
choices: ['stainless-sandbox', 'local'],
|
|
54
|
+
default: 'stainless-sandbox',
|
|
55
|
+
description:
|
|
56
|
+
"Where to run code execution in code tool; 'stainless-sandbox' will execute code in Stainless-hosted sandboxes whereas 'local' will execute code locally on the MCP server machine.",
|
|
57
|
+
})
|
|
58
|
+
.option('custom-instructions-path', {
|
|
59
|
+
type: 'string',
|
|
60
|
+
description: 'Path to custom instructions for the MCP server',
|
|
61
|
+
})
|
|
62
|
+
.option('debug', { type: 'boolean', description: 'Enable debug logging' })
|
|
63
|
+
.option('docs-dir', {
|
|
64
|
+
type: 'string',
|
|
65
|
+
description:
|
|
66
|
+
'Path to a directory of local documentation files (markdown/JSON) to include in local docs search.',
|
|
67
|
+
})
|
|
68
|
+
.option('docs-search-mode', {
|
|
69
|
+
type: 'string',
|
|
70
|
+
choices: ['stainless-api', 'local'],
|
|
71
|
+
default: 'stainless-api',
|
|
72
|
+
description:
|
|
73
|
+
"Where to search documentation; 'stainless-api' uses the Stainless-hosted search API whereas 'local' uses an in-memory search index built from embedded SDK method data and optional local docs files.",
|
|
74
|
+
})
|
|
75
|
+
.option('log-format', {
|
|
76
|
+
type: 'string',
|
|
77
|
+
choices: ['json', 'pretty'],
|
|
78
|
+
description: 'Format for log output; defaults to json unless tty is detected',
|
|
79
|
+
})
|
|
80
|
+
.option('no-tools', {
|
|
81
|
+
type: 'string',
|
|
82
|
+
array: true,
|
|
83
|
+
choices: ['code', 'docs'],
|
|
84
|
+
description: 'Tools to explicitly disable',
|
|
35
85
|
})
|
|
36
86
|
.option('port', {
|
|
37
87
|
type: 'number',
|
|
88
|
+
default: 3000,
|
|
38
89
|
description: 'Port to serve on if using http transport',
|
|
39
90
|
})
|
|
40
|
-
.option('socket', {
|
|
91
|
+
.option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
|
|
92
|
+
.option('stainless-api-key', {
|
|
93
|
+
type: 'string',
|
|
94
|
+
default: readEnv('STAINLESS_API_KEY'),
|
|
95
|
+
description:
|
|
96
|
+
'API key for Stainless. Used to authenticate requests to Stainless-hosted tools endpoints.',
|
|
97
|
+
})
|
|
98
|
+
.option('tools', {
|
|
99
|
+
type: 'string',
|
|
100
|
+
array: true,
|
|
101
|
+
choices: ['code', 'docs'],
|
|
102
|
+
description: 'Tools to explicitly enable',
|
|
103
|
+
})
|
|
104
|
+
.option('transport', {
|
|
41
105
|
type: 'string',
|
|
42
|
-
|
|
106
|
+
choices: ['stdio', 'http'],
|
|
107
|
+
default: 'stdio',
|
|
108
|
+
description: 'What transport to use; stdio for local servers or http for remote servers',
|
|
43
109
|
})
|
|
110
|
+
.env('MCP_SERVER')
|
|
111
|
+
.version(true)
|
|
44
112
|
.help();
|
|
45
113
|
|
|
46
114
|
const argv = opts.parseSync();
|
|
@@ -50,13 +118,29 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
50
118
|
: argv.tools?.includes(toolType) ? true
|
|
51
119
|
: undefined;
|
|
52
120
|
|
|
121
|
+
const includeCodeTool = shouldIncludeToolType('code');
|
|
53
122
|
const includeDocsTools = shouldIncludeToolType('docs');
|
|
54
123
|
|
|
55
124
|
const transport = argv.transport as 'stdio' | 'http';
|
|
125
|
+
const logFormat =
|
|
126
|
+
argv.logFormat ? (argv.logFormat as 'json' | 'pretty')
|
|
127
|
+
: process.stderr.isTTY ? 'pretty'
|
|
128
|
+
: 'json';
|
|
56
129
|
|
|
57
130
|
return {
|
|
131
|
+
...(includeCodeTool !== undefined && { includeCodeTool }),
|
|
58
132
|
...(includeDocsTools !== undefined && { includeDocsTools }),
|
|
133
|
+
debug: !!argv.debug,
|
|
134
|
+
stainlessApiKey: argv.stainlessApiKey,
|
|
135
|
+
docsSearchMode: argv.docsSearchMode as 'stainless-api' | 'local' | undefined,
|
|
136
|
+
docsDir: argv.docsDir,
|
|
137
|
+
codeAllowHttpGets: argv.codeAllowHttpGets,
|
|
138
|
+
codeAllowedMethods: argv.codeAllowedMethods,
|
|
139
|
+
codeBlockedMethods: argv.codeBlockedMethods,
|
|
140
|
+
codeExecutionMode: argv.codeExecutionMode as McpCodeExecutionMode,
|
|
141
|
+
customInstructionsPath: argv.customInstructionsPath,
|
|
59
142
|
transport,
|
|
143
|
+
logFormat,
|
|
60
144
|
port: argv.port,
|
|
61
145
|
socket: argv.socket,
|
|
62
146
|
};
|
|
@@ -81,12 +165,21 @@ export function parseQueryOptions(defaultOptions: McpOptions, query: unknown): M
|
|
|
81
165
|
const queryObject = typeof query === 'string' ? qs.parse(query) : query;
|
|
82
166
|
const queryOptions = QueryOptions.parse(queryObject);
|
|
83
167
|
|
|
168
|
+
let codeTool: boolean | undefined =
|
|
169
|
+
queryOptions.no_tools && queryOptions.no_tools?.includes('code') ? false
|
|
170
|
+
: queryOptions.tools?.includes('code') ? true
|
|
171
|
+
: defaultOptions.includeCodeTool;
|
|
172
|
+
|
|
84
173
|
let docsTools: boolean | undefined =
|
|
85
174
|
queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
|
|
86
175
|
: queryOptions.tools?.includes('docs') ? true
|
|
87
176
|
: defaultOptions.includeDocsTools;
|
|
88
177
|
|
|
89
178
|
return {
|
|
179
|
+
...(codeTool !== undefined && { includeCodeTool: codeTool }),
|
|
90
180
|
...(docsTools !== undefined && { includeDocsTools: docsTools }),
|
|
181
|
+
codeExecutionMode: defaultOptions.codeExecutionMode,
|
|
182
|
+
docsSearchMode: defaultOptions.docsSearchMode,
|
|
183
|
+
docsDir: defaultOptions.docsDir,
|
|
91
184
|
};
|
|
92
185
|
}
|