@2kw/ai-mcp-server 4.0.0-dev.2
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/LICENSE +19 -0
- package/README.md +123 -0
- package/dist/client.d.ts +14 -0
- package/dist/client.js +46 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.js +22 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +116 -0
- package/dist/mime.d.ts +2 -0
- package/dist/mime.js +56 -0
- package/dist/schema-compat.d.ts +11 -0
- package/dist/schema-compat.js +51 -0
- package/dist/tools/ai-gateway.d.ts +4 -0
- package/dist/tools/ai-gateway.js +107 -0
- package/dist/tools/analytics.d.ts +4 -0
- package/dist/tools/analytics.js +163 -0
- package/dist/tools/billing.d.ts +4 -0
- package/dist/tools/billing.js +76 -0
- package/dist/tools/conversion.d.ts +4 -0
- package/dist/tools/conversion.js +281 -0
- package/dist/tools/datasets.d.ts +4 -0
- package/dist/tools/datasets.js +200 -0
- package/dist/tools/docs.d.ts +4 -0
- package/dist/tools/docs.js +171 -0
- package/dist/tools/evaluators.d.ts +4 -0
- package/dist/tools/evaluators.js +140 -0
- package/dist/tools/experiments.d.ts +4 -0
- package/dist/tools/experiments.js +231 -0
- package/dist/tools/extraction.d.ts +4 -0
- package/dist/tools/extraction.js +245 -0
- package/dist/tools/prompts.d.ts +4 -0
- package/dist/tools/prompts.js +373 -0
- package/dist/tools/providers.d.ts +4 -0
- package/dist/tools/providers.js +148 -0
- package/dist/tools/schema-labels.d.ts +4 -0
- package/dist/tools/schema-labels.js +88 -0
- package/dist/tools/schema-testing.d.ts +4 -0
- package/dist/tools/schema-testing.js +96 -0
- package/dist/tools/schema-versions.d.ts +4 -0
- package/dist/tools/schema-versions.js +127 -0
- package/dist/tools/schemas.d.ts +4 -0
- package/dist/tools/schemas.js +136 -0
- package/dist/tools/scores.d.ts +4 -0
- package/dist/tools/scores.js +43 -0
- package/dist/tools/tracing.d.ts +4 -0
- package/dist/tools/tracing.js +124 -0
- package/dist/tools/transcription.d.ts +4 -0
- package/dist/tools/transcription.js +76 -0
- package/package.json +45 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { formatErrorForMcp } from "../errors.js";
|
|
3
|
+
export function register(server, client) {
|
|
4
|
+
// ── prompts ─────────────────────────────────────────────────────────────
|
|
5
|
+
server.tool("2kw_list_prompts", "List org prompts with optional name/type filter and pagination.", {
|
|
6
|
+
search: z.string().optional().describe("Filter by name"),
|
|
7
|
+
type: z.enum(["TEXT", "CHAT"]).optional().describe("Filter by type"),
|
|
8
|
+
page: z.number().int().min(0).optional(),
|
|
9
|
+
size: z.number().int().min(1).max(100).optional(),
|
|
10
|
+
sort: z.string().optional().describe("Sort field and direction"),
|
|
11
|
+
}, async (params) => {
|
|
12
|
+
try {
|
|
13
|
+
const { data } = await client.GET("/v1/prompts", {
|
|
14
|
+
params: {
|
|
15
|
+
query: {
|
|
16
|
+
search: params.search,
|
|
17
|
+
type: params.type,
|
|
18
|
+
pageable: {
|
|
19
|
+
page: params.page ?? 0,
|
|
20
|
+
size: params.size ?? 20,
|
|
21
|
+
sort: params.sort ? [params.sort] : undefined,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return {
|
|
32
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
33
|
+
isError: true,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
server.tool("2kw_get_prompt", "Get a single prompt by id, including its active version pointer.", { promptId: z.string() }, async (params) => {
|
|
38
|
+
try {
|
|
39
|
+
const { data } = await client.GET("/v1/prompts/{id}", {
|
|
40
|
+
params: { path: { id: params.promptId } },
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return {
|
|
48
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
49
|
+
isError: true,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
server.tool("2kw_create_prompt", "Create a new prompt (metadata only — add content via a prompt version).", {
|
|
54
|
+
name: z.string().min(1),
|
|
55
|
+
description: z.string().optional(),
|
|
56
|
+
type: z.enum(["TEXT", "CHAT"]).optional().describe("Prompt type (default TEXT)"),
|
|
57
|
+
}, async (params) => {
|
|
58
|
+
try {
|
|
59
|
+
const { data } = await client.POST("/v1/prompts", {
|
|
60
|
+
body: {
|
|
61
|
+
name: params.name,
|
|
62
|
+
description: params.description,
|
|
63
|
+
type: params.type ?? "TEXT",
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
return {
|
|
72
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
73
|
+
isError: true,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
server.tool("2kw_update_prompt", "Update prompt metadata (name, description, type).", {
|
|
78
|
+
promptId: z.string(),
|
|
79
|
+
name: z.string().optional(),
|
|
80
|
+
description: z.string().optional(),
|
|
81
|
+
type: z.enum(["TEXT", "CHAT"]).optional(),
|
|
82
|
+
}, async (params) => {
|
|
83
|
+
try {
|
|
84
|
+
const body = {};
|
|
85
|
+
if (params.name !== undefined)
|
|
86
|
+
body.name = params.name;
|
|
87
|
+
if (params.description !== undefined)
|
|
88
|
+
body.description = params.description;
|
|
89
|
+
if (params.type !== undefined)
|
|
90
|
+
body.type = params.type;
|
|
91
|
+
const { data } = await client.PUT("/v1/prompts/{id}", {
|
|
92
|
+
params: { path: { id: params.promptId } },
|
|
93
|
+
body: body,
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
return {
|
|
101
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
102
|
+
isError: true,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
server.tool("2kw_delete_prompt", "Delete a prompt and all its versions. Irreversible.", { promptId: z.string() }, async (params) => {
|
|
107
|
+
try {
|
|
108
|
+
await client.DELETE("/v1/prompts/{id}", {
|
|
109
|
+
params: { path: { id: params.promptId } },
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
content: [
|
|
113
|
+
{ type: "text", text: `Prompt ${params.promptId} deleted.` },
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
return {
|
|
119
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
120
|
+
isError: true,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
server.tool("2kw_resolve_prompt", "Resolve a prompt's active or labeled content — returns the version that would be used at runtime.", {
|
|
125
|
+
promptId: z.string(),
|
|
126
|
+
label: z.string().optional().describe("Label (e.g. 'production') — otherwise returns active"),
|
|
127
|
+
}, async (params) => {
|
|
128
|
+
try {
|
|
129
|
+
const { data } = await client.GET("/v1/prompts/{promptId}/resolve", {
|
|
130
|
+
params: {
|
|
131
|
+
path: { promptId: params.promptId },
|
|
132
|
+
query: { label: params.label },
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
return {
|
|
141
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
142
|
+
isError: true,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
server.tool("2kw_compile_prompt", "Render a prompt template with variable substitution. Pass variables as an object; unresolved placeholders will error.", {
|
|
147
|
+
promptId: z.string(),
|
|
148
|
+
variables: z.record(z.string(), z.unknown()).optional(),
|
|
149
|
+
versionId: z.string().optional().describe("Compile a specific version"),
|
|
150
|
+
label: z.string().optional().describe("Compile the version behind this label"),
|
|
151
|
+
}, async (params) => {
|
|
152
|
+
try {
|
|
153
|
+
const { data } = await client.POST("/v1/prompts/{promptId}/compile", {
|
|
154
|
+
params: { path: { promptId: params.promptId } },
|
|
155
|
+
body: {
|
|
156
|
+
variables: params.variables,
|
|
157
|
+
versionId: params.versionId,
|
|
158
|
+
label: params.label,
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
return {
|
|
162
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
return {
|
|
167
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
168
|
+
isError: true,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
server.tool("2kw_test_prompt", "Run a prompt against an LLM and return the completion — useful for smoke-testing template changes.", {
|
|
173
|
+
promptId: z.string(),
|
|
174
|
+
model: z.string().describe("provider/model, e.g. openai/gpt-4.1"),
|
|
175
|
+
content: z.string().optional().describe("Optional input text"),
|
|
176
|
+
variables: z.record(z.string(), z.unknown()).optional(),
|
|
177
|
+
versionId: z.string().optional(),
|
|
178
|
+
label: z.string().optional(),
|
|
179
|
+
}, async (params) => {
|
|
180
|
+
try {
|
|
181
|
+
const { data } = await client.POST("/v1/prompts/{promptId}/test", {
|
|
182
|
+
params: { path: { promptId: params.promptId } },
|
|
183
|
+
body: {
|
|
184
|
+
model: params.model,
|
|
185
|
+
content: params.content,
|
|
186
|
+
variables: params.variables,
|
|
187
|
+
versionId: params.versionId,
|
|
188
|
+
label: params.label,
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
return {
|
|
192
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
return {
|
|
197
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
198
|
+
isError: true,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
// ── versions ────────────────────────────────────────────────────────────
|
|
203
|
+
server.tool("2kw_list_prompt_versions", "List all versions of a prompt (most recent first).", {
|
|
204
|
+
promptId: z.string(),
|
|
205
|
+
page: z.number().int().min(0).optional(),
|
|
206
|
+
size: z.number().int().min(1).max(100).optional(),
|
|
207
|
+
}, async (params) => {
|
|
208
|
+
try {
|
|
209
|
+
const { data } = await client.GET("/v1/prompts/{promptId}/versions", {
|
|
210
|
+
params: {
|
|
211
|
+
path: { promptId: params.promptId },
|
|
212
|
+
query: {
|
|
213
|
+
pageable: { page: params.page ?? 0, size: params.size ?? 20 },
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
return {
|
|
218
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
return {
|
|
223
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
224
|
+
isError: true,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
server.tool("2kw_get_prompt_version", "Fetch a single prompt version by id, including its content.", { promptId: z.string(), versionId: z.string() }, async (params) => {
|
|
229
|
+
try {
|
|
230
|
+
const { data } = await client.GET("/v1/prompts/{promptId}/versions/{versionId}", {
|
|
231
|
+
params: {
|
|
232
|
+
path: { promptId: params.promptId, versionId: params.versionId },
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
return {
|
|
236
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
return {
|
|
241
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
242
|
+
isError: true,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
server.tool("2kw_create_prompt_version", "Create a new prompt version. The latest version is the implicit active one unless you activate a specific one.", {
|
|
247
|
+
promptId: z.string(),
|
|
248
|
+
content: z.string().describe("Prompt template content"),
|
|
249
|
+
changeDescription: z.string().optional(),
|
|
250
|
+
}, async (params) => {
|
|
251
|
+
try {
|
|
252
|
+
const { data } = await client.POST("/v1/prompts/{promptId}/versions", {
|
|
253
|
+
params: { path: { promptId: params.promptId } },
|
|
254
|
+
body: {
|
|
255
|
+
content: params.content,
|
|
256
|
+
changeDescription: params.changeDescription,
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
return {
|
|
260
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
return {
|
|
265
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
266
|
+
isError: true,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
server.tool("2kw_activate_prompt_version", "Mark a specific prompt version as active — new resolve/test calls with no label target this version.", { promptId: z.string(), versionId: z.string() }, async (params) => {
|
|
271
|
+
try {
|
|
272
|
+
const { data } = await client.PUT("/v1/prompts/{promptId}/versions/{versionId}/activate", {
|
|
273
|
+
params: {
|
|
274
|
+
path: { promptId: params.promptId, versionId: params.versionId },
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
return {
|
|
278
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
return {
|
|
283
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
284
|
+
isError: true,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
// ── labels ──────────────────────────────────────────────────────────────
|
|
289
|
+
server.tool("2kw_list_prompt_labels", "List labels defined on a prompt (e.g. production, staging) and which version each points to.", { promptId: z.string() }, async (params) => {
|
|
290
|
+
try {
|
|
291
|
+
const { data } = await client.GET("/v1/prompts/{promptId}/labels", {
|
|
292
|
+
params: { path: { promptId: params.promptId } },
|
|
293
|
+
});
|
|
294
|
+
return {
|
|
295
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
return {
|
|
300
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
301
|
+
isError: true,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
server.tool("2kw_create_prompt_label", "Label a prompt version (e.g. tag a version as 'production'). Labels are unique per prompt.", {
|
|
306
|
+
promptId: z.string(),
|
|
307
|
+
name: z.string().describe("Label name (e.g. 'production')"),
|
|
308
|
+
promptVersionId: z.string().describe("Version id the label should point to"),
|
|
309
|
+
}, async (params) => {
|
|
310
|
+
try {
|
|
311
|
+
const { data } = await client.POST("/v1/prompts/{promptId}/labels", {
|
|
312
|
+
params: { path: { promptId: params.promptId } },
|
|
313
|
+
body: { name: params.name, promptVersionId: params.promptVersionId },
|
|
314
|
+
});
|
|
315
|
+
return {
|
|
316
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
return {
|
|
321
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
322
|
+
isError: true,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
server.tool("2kw_update_prompt_label", "Move an existing label to a different prompt version — typical release cutover.", {
|
|
327
|
+
promptId: z.string(),
|
|
328
|
+
labelName: z.string(),
|
|
329
|
+
promptVersionId: z.string(),
|
|
330
|
+
}, async (params) => {
|
|
331
|
+
try {
|
|
332
|
+
const { data } = await client.PUT("/v1/prompts/{promptId}/labels/{labelName}", {
|
|
333
|
+
params: {
|
|
334
|
+
path: { promptId: params.promptId, labelName: params.labelName },
|
|
335
|
+
},
|
|
336
|
+
body: { promptVersionId: params.promptVersionId },
|
|
337
|
+
});
|
|
338
|
+
return {
|
|
339
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
return {
|
|
344
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
345
|
+
isError: true,
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
server.tool("2kw_delete_prompt_label", "Remove a label from a prompt. Does not affect the version it was pointing to.", { promptId: z.string(), labelName: z.string() }, async (params) => {
|
|
350
|
+
try {
|
|
351
|
+
await client.DELETE("/v1/prompts/{promptId}/labels/{labelName}", {
|
|
352
|
+
params: {
|
|
353
|
+
path: { promptId: params.promptId, labelName: params.labelName },
|
|
354
|
+
},
|
|
355
|
+
});
|
|
356
|
+
return {
|
|
357
|
+
content: [
|
|
358
|
+
{
|
|
359
|
+
type: "text",
|
|
360
|
+
text: `Label "${params.labelName}" deleted from prompt ${params.promptId}.`,
|
|
361
|
+
},
|
|
362
|
+
],
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
catch (error) {
|
|
366
|
+
return {
|
|
367
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
368
|
+
isError: true,
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { formatErrorForMcp } from "../errors.js";
|
|
3
|
+
const ProviderType = z.enum([
|
|
4
|
+
"OPENAI",
|
|
5
|
+
"AZURE_OPENAI",
|
|
6
|
+
"ANTHROPIC",
|
|
7
|
+
"XAI",
|
|
8
|
+
"MISTRAL",
|
|
9
|
+
"VERTEX_AI",
|
|
10
|
+
"OLLAMA",
|
|
11
|
+
]);
|
|
12
|
+
export function register(server, client) {
|
|
13
|
+
server.tool("2kw_list_providers", "List BYOK AI providers configured for the org (OpenAI, Azure, Anthropic, etc.).", {
|
|
14
|
+
search: z.string().optional(),
|
|
15
|
+
page: z.number().int().min(0).optional(),
|
|
16
|
+
size: z.number().int().min(1).max(100).optional(),
|
|
17
|
+
}, async (params) => {
|
|
18
|
+
try {
|
|
19
|
+
const { data } = await client.GET("/v1/providers", {
|
|
20
|
+
params: {
|
|
21
|
+
query: {
|
|
22
|
+
search: params.search,
|
|
23
|
+
pageable: { page: params.page ?? 0, size: params.size ?? 20 },
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
return {
|
|
33
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
34
|
+
isError: true,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
server.tool("2kw_get_provider", "Fetch a single provider record by id. API keys are redacted.", { id: z.string() }, async (params) => {
|
|
39
|
+
try {
|
|
40
|
+
const { data } = await client.GET("/v1/providers/{id}", {
|
|
41
|
+
params: { path: { id: params.id } },
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
return {
|
|
49
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
50
|
+
isError: true,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
server.tool("2kw_create_provider", "Register a new BYOK provider with credentials. Requires an API key belonging to the external provider.", {
|
|
55
|
+
name: z.string(),
|
|
56
|
+
provider: ProviderType.describe("Provider vendor type"),
|
|
57
|
+
apiKey: z.string().describe("Credential for the external provider"),
|
|
58
|
+
config: z
|
|
59
|
+
.record(z.string(), z.unknown())
|
|
60
|
+
.optional()
|
|
61
|
+
.describe("Provider-specific config (e.g. endpoint, region)"),
|
|
62
|
+
}, async (params) => {
|
|
63
|
+
try {
|
|
64
|
+
const { data } = await client.POST("/v1/providers", {
|
|
65
|
+
body: {
|
|
66
|
+
name: params.name,
|
|
67
|
+
provider: params.provider,
|
|
68
|
+
apiKey: params.apiKey,
|
|
69
|
+
config: params.config ?? {},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return {
|
|
78
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
79
|
+
isError: true,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
server.tool("2kw_update_provider", "Patch an existing provider. Only supplied fields are updated.", {
|
|
84
|
+
id: z.string(),
|
|
85
|
+
name: z.string().optional(),
|
|
86
|
+
provider: ProviderType.optional(),
|
|
87
|
+
enabled: z.boolean().optional(),
|
|
88
|
+
config: z.record(z.string(), z.unknown()).optional(),
|
|
89
|
+
}, async (params) => {
|
|
90
|
+
try {
|
|
91
|
+
const body = {};
|
|
92
|
+
if (params.name !== undefined)
|
|
93
|
+
body.name = params.name;
|
|
94
|
+
if (params.provider !== undefined)
|
|
95
|
+
body.provider = params.provider;
|
|
96
|
+
if (params.enabled !== undefined)
|
|
97
|
+
body.enabled = params.enabled;
|
|
98
|
+
if (params.config !== undefined)
|
|
99
|
+
body.config = params.config;
|
|
100
|
+
const { data } = await client.PATCH("/v1/providers/{id}", {
|
|
101
|
+
params: { path: { id: params.id } },
|
|
102
|
+
body: body,
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
return {
|
|
110
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
111
|
+
isError: true,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
server.tool("2kw_delete_provider", "Delete a provider. Existing extractions that used it keep their past records.", { id: z.string() }, async (params) => {
|
|
116
|
+
try {
|
|
117
|
+
await client.DELETE("/v1/providers/{id}", {
|
|
118
|
+
params: { path: { id: params.id } },
|
|
119
|
+
});
|
|
120
|
+
return {
|
|
121
|
+
content: [
|
|
122
|
+
{ type: "text", text: `Provider ${params.id} deleted.` },
|
|
123
|
+
],
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
return {
|
|
128
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
129
|
+
isError: true,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
server.tool("2kw_list_provider_models", "List every model exposed by every configured provider. Useful to discover which provider/model ids are valid for extractions, chat, and experiments.", {}, async () => {
|
|
134
|
+
try {
|
|
135
|
+
const { data } = await client.GET("/v1/providers/models");
|
|
136
|
+
return {
|
|
137
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
return {
|
|
142
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
143
|
+
isError: true,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=providers.js.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { formatErrorForMcp } from "../errors.js";
|
|
3
|
+
export function register(server, client) {
|
|
4
|
+
server.tool("2kw_list_schema_labels", "List labels defined on a schema (e.g. production, staging) and which version each points to.", { schemaId: z.string() }, async (params) => {
|
|
5
|
+
try {
|
|
6
|
+
const { data } = await client.GET("/v1/schemas/{schemaId}/labels", {
|
|
7
|
+
params: { path: { schemaId: params.schemaId } },
|
|
8
|
+
});
|
|
9
|
+
return {
|
|
10
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
return {
|
|
15
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
16
|
+
isError: true,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
server.tool("2kw_create_schema_label", "Label a schema version (e.g. tag as 'production'). Labels are unique per schema.", {
|
|
21
|
+
schemaId: z.string(),
|
|
22
|
+
name: z.string().describe("Label name"),
|
|
23
|
+
schemaVersionId: z.string().describe("Version id the label should point to"),
|
|
24
|
+
}, async (params) => {
|
|
25
|
+
try {
|
|
26
|
+
const { data } = await client.POST("/v1/schemas/{schemaId}/labels", {
|
|
27
|
+
params: { path: { schemaId: params.schemaId } },
|
|
28
|
+
body: { name: params.name, schemaVersionId: params.schemaVersionId },
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
37
|
+
isError: true,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
server.tool("2kw_update_schema_label", "Move an existing schema label to a different version — typical release cutover.", {
|
|
42
|
+
schemaId: z.string(),
|
|
43
|
+
labelName: z.string(),
|
|
44
|
+
schemaVersionId: z.string(),
|
|
45
|
+
}, async (params) => {
|
|
46
|
+
try {
|
|
47
|
+
const { data } = await client.PUT("/v1/schemas/{schemaId}/labels/{labelName}", {
|
|
48
|
+
params: {
|
|
49
|
+
path: { schemaId: params.schemaId, labelName: params.labelName },
|
|
50
|
+
},
|
|
51
|
+
body: { schemaVersionId: params.schemaVersionId },
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
return {
|
|
59
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
60
|
+
isError: true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
server.tool("2kw_delete_schema_label", "Remove a label from a schema. Does not affect the version it was pointing to.", { schemaId: z.string(), labelName: z.string() }, async (params) => {
|
|
65
|
+
try {
|
|
66
|
+
await client.DELETE("/v1/schemas/{schemaId}/labels/{labelName}", {
|
|
67
|
+
params: {
|
|
68
|
+
path: { schemaId: params.schemaId, labelName: params.labelName },
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
content: [
|
|
73
|
+
{
|
|
74
|
+
type: "text",
|
|
75
|
+
text: `Label "${params.labelName}" deleted from schema ${params.schemaId}.`,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return {
|
|
82
|
+
content: [{ type: "text", text: formatErrorForMcp(error) }],
|
|
83
|
+
isError: true,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=schema-labels.js.map
|