@2kw/ai-mcp-server 6.3.0-dev.8 → 6.3.0-dev.89
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 +3 -1
- package/dist/client.d.ts +9 -2
- package/dist/client.js +15 -1
- package/dist/index.js +5 -53
- package/dist/lib/agent-decide.d.ts +54 -0
- package/dist/lib/agent-decide.js +124 -0
- package/dist/lib/agent-run.d.ts +124 -0
- package/dist/lib/agent-run.js +260 -0
- package/dist/tools/agents.js +77 -2
- package/dist/tools/ai-gateway.js +25 -11
- package/dist/tools/conversations.js +26 -0
- package/dist/tools/experiments.js +2 -2
- package/dist/tools/index.d.ts +21 -0
- package/dist/tools/index.js +190 -0
- package/dist/tools/knowledge.js +7 -23
- package/dist/tools/memory.d.ts +9 -0
- package/dist/tools/memory.js +43 -0
- package/dist/tools/tracing.js +10 -2
- package/package.json +3 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import * as agents from "./agents.js";
|
|
2
|
+
import * as aiGateway from "./ai-gateway.js";
|
|
3
|
+
import * as analytics from "./analytics.js";
|
|
4
|
+
import * as annotationQueues from "./annotation-queues.js";
|
|
5
|
+
import * as billing from "./billing.js";
|
|
6
|
+
import * as conversations from "./conversations.js";
|
|
7
|
+
import * as conversion from "./conversion.js";
|
|
8
|
+
import * as datasets from "./datasets.js";
|
|
9
|
+
import * as docs from "./docs.js";
|
|
10
|
+
import * as evaluators from "./evaluators.js";
|
|
11
|
+
import * as experiments from "./experiments.js";
|
|
12
|
+
import * as extraction from "./extraction.js";
|
|
13
|
+
import * as files from "./files.js";
|
|
14
|
+
import * as knowledge from "./knowledge.js";
|
|
15
|
+
import * as memory from "./memory.js";
|
|
16
|
+
import * as plugins from "./plugins.js";
|
|
17
|
+
import * as prompts from "./prompts.js";
|
|
18
|
+
import * as providers from "./providers.js";
|
|
19
|
+
import * as schemaLabels from "./schema-labels.js";
|
|
20
|
+
import * as schemaTesting from "./schema-testing.js";
|
|
21
|
+
import * as schemaVersions from "./schema-versions.js";
|
|
22
|
+
import * as schemas from "./schemas.js";
|
|
23
|
+
import * as scores from "./scores.js";
|
|
24
|
+
import * as skills from "./skills.js";
|
|
25
|
+
import * as tracing from "./tracing.js";
|
|
26
|
+
import * as transcription from "./transcription.js";
|
|
27
|
+
/** Every tool module, in the order the docs page lists them. A new module must be added here. */
|
|
28
|
+
export const TOOL_GROUPS = [
|
|
29
|
+
{
|
|
30
|
+
id: "ai-gateway",
|
|
31
|
+
title: "AI Gateway",
|
|
32
|
+
summary: "Call models through the gateway — chat completions, the Responses endpoint (including stored agents) and the model list.",
|
|
33
|
+
register: (s, d) => aiGateway.register(s, d.client),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "agents",
|
|
37
|
+
title: "Agents",
|
|
38
|
+
summary: "Manage agents, their versions, labels and tool catalogs, and decide paused approvals. See [Running agents](#running-agents).",
|
|
39
|
+
register: (s, d) => agents.register(s, d.client),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "conversations",
|
|
43
|
+
title: "Conversations",
|
|
44
|
+
summary: "Create, read, rename and delete conversations, list their items and cancel a running turn.",
|
|
45
|
+
register: (s, d) => conversations.register(s, d.client),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "memory",
|
|
49
|
+
title: "Memory",
|
|
50
|
+
summary: "Read and edit your own agent memory, and see or erase a member's memory as an admin.",
|
|
51
|
+
register: (s, d) => memory.register(s, d.client),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "knowledge",
|
|
55
|
+
title: "Knowledge Bases",
|
|
56
|
+
summary: "Manage knowledge bases and their documents, search them and resolve citations.",
|
|
57
|
+
register: (s, d) => knowledge.register(s, d.client),
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "files",
|
|
61
|
+
title: "Files",
|
|
62
|
+
summary: "Upload, list, download and delete files.",
|
|
63
|
+
register: (s, d) => files.register(s, d.client),
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "skills",
|
|
67
|
+
title: "Skills",
|
|
68
|
+
summary: "Import, read, resolve and delete skills, with their versions and labels.",
|
|
69
|
+
register: (s, d) => skills.register(s, d.client),
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: "plugins",
|
|
73
|
+
title: "Plugins",
|
|
74
|
+
summary: "Install, sync, update and remove plugins.",
|
|
75
|
+
register: (s, d) => plugins.register(s, d.client),
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "prompts",
|
|
79
|
+
title: "Prompts",
|
|
80
|
+
summary: "Manage prompts, their versions and labels, and resolve, compile or test them.",
|
|
81
|
+
register: (s, d) => prompts.register(s, d.client),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: "schemas",
|
|
85
|
+
title: "Schemas",
|
|
86
|
+
summary: "Define extraction schemas within your organization.",
|
|
87
|
+
register: (s, d) => schemas.register(s, d.client),
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: "schema-versions",
|
|
91
|
+
title: "Schema Versions",
|
|
92
|
+
summary: "Manage versioned snapshots of schema definitions.",
|
|
93
|
+
register: (s, d) => schemaVersions.register(s, d.client),
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: "schema-labels",
|
|
97
|
+
title: "Schema Labels",
|
|
98
|
+
summary: "Point named labels at schema versions.",
|
|
99
|
+
register: (s, d) => schemaLabels.register(s, d.client),
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: "schema-testing",
|
|
103
|
+
title: "Schema Testing",
|
|
104
|
+
summary: "Validate schemas and test extractions without persisting data.",
|
|
105
|
+
register: (s, d) => schemaTesting.register(s, d.client),
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: "extraction",
|
|
109
|
+
title: "Extractions",
|
|
110
|
+
summary: "Extract structured data from text using schemas and AI models.",
|
|
111
|
+
register: (s, d) => extraction.register(s, d.client),
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: "conversion",
|
|
115
|
+
title: "Document Conversion",
|
|
116
|
+
summary: "Convert documents (PDF, DOCX and more) to Markdown, text, HTML or JSON.",
|
|
117
|
+
register: (s, d) => conversion.register(s, d.client),
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: "transcription",
|
|
121
|
+
title: "Audio Transcription",
|
|
122
|
+
summary: "Transcribe audio files using AI models.",
|
|
123
|
+
register: (s, d) => transcription.register(s, d.client),
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: "datasets",
|
|
127
|
+
title: "Datasets",
|
|
128
|
+
summary: "Manage evaluation datasets, their versions and items.",
|
|
129
|
+
register: (s, d) => datasets.register(s, d.client),
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: "experiments",
|
|
133
|
+
title: "Experiments",
|
|
134
|
+
summary: "Run experiments over datasets, compare variants and track regressions against a baseline.",
|
|
135
|
+
register: (s, d) => experiments.register(s, d.client),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: "evaluators",
|
|
139
|
+
title: "Evaluators",
|
|
140
|
+
summary: "List evaluator types and manage evaluator templates.",
|
|
141
|
+
register: (s, d) => evaluators.register(s, d.client),
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: "scores",
|
|
145
|
+
title: "Scores",
|
|
146
|
+
summary: "Record and list human scores.",
|
|
147
|
+
register: (s, d) => scores.register(s, d.client),
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
id: "annotation-queues",
|
|
151
|
+
title: "Annotation Queues",
|
|
152
|
+
summary: "Manage annotation queues and work through their items.",
|
|
153
|
+
register: (s, d) => annotationQueues.register(s, d.client),
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: "tracing",
|
|
157
|
+
title: "Tracing",
|
|
158
|
+
summary: "Read traces and trace sessions, and change the tracing settings.",
|
|
159
|
+
register: (s, d) => tracing.register(s, d.client),
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
id: "analytics",
|
|
163
|
+
title: "Analytics",
|
|
164
|
+
summary: "Usage, error and quality analytics for your organization.",
|
|
165
|
+
register: (s, d) => analytics.register(s, d.client),
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: "providers",
|
|
169
|
+
title: "Providers",
|
|
170
|
+
summary: "Manage AI providers and list their models.",
|
|
171
|
+
register: (s, d) => providers.register(s, d.client),
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
id: "billing",
|
|
175
|
+
title: "Billing",
|
|
176
|
+
summary: "Read your billing tier and limits, and check available budget.",
|
|
177
|
+
register: (s, d) => billing.register(s, d.client),
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
id: "docs",
|
|
181
|
+
title: "API Documentation",
|
|
182
|
+
summary: "Browse the backend's OpenAPI documentation by section.",
|
|
183
|
+
register: (s, d) => docs.register(s, d.client, d.baseUrl, d.apiKey),
|
|
184
|
+
},
|
|
185
|
+
];
|
|
186
|
+
export function registerAllTools(server, deps) {
|
|
187
|
+
for (const group of TOOL_GROUPS)
|
|
188
|
+
group.register(server, deps);
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=index.js.map
|
package/dist/tools/knowledge.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { basename } from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { formatErrorForMcp } from "../errors.js";
|
|
5
5
|
import { getMimeType } from "../mime.js";
|
|
6
6
|
const ChunkingStrategy = z.enum(["AUTO", "FIXED", "HIERARCHICAL", "CUSTOM"]);
|
|
7
7
|
const DocumentStatus = z.enum(["PENDING", "PARSING", "CHUNKING", "EMBEDDING", "READY", "ERROR"]);
|
|
@@ -203,29 +203,13 @@ export function register(server, client) {
|
|
|
203
203
|
const filename = basename(filePath);
|
|
204
204
|
formData.append("files", new Blob([buffer], { type: getMimeType(filename) }), filename);
|
|
205
205
|
}
|
|
206
|
-
const {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
206
|
+
const { data } = await client.POST("/v1/knowledge-bases/{knowledgeBaseId}/documents", {
|
|
207
|
+
params: { path: { knowledgeBaseId } },
|
|
208
|
+
// Provide placeholder body for type checking; actual payload comes from bodySerializer
|
|
209
|
+
body: { files: [] },
|
|
210
|
+
bodySerializer: () => formData,
|
|
211
211
|
});
|
|
212
|
-
|
|
213
|
-
let body;
|
|
214
|
-
try {
|
|
215
|
-
body = await res.json();
|
|
216
|
-
}
|
|
217
|
-
catch {
|
|
218
|
-
body = {
|
|
219
|
-
error: res.statusText,
|
|
220
|
-
message: `HTTP ${res.status}: ${res.statusText}`,
|
|
221
|
-
status: res.status,
|
|
222
|
-
timestamp: new Date().toISOString(),
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
throw new BackboneApiError(body);
|
|
226
|
-
}
|
|
227
|
-
const data = (await res.json());
|
|
228
|
-
const lines = data.map((r) => r.error
|
|
212
|
+
const lines = (data ?? []).map((r) => r.error
|
|
229
213
|
? `- ${r.filename}: rejected — ${r.error}`
|
|
230
214
|
: `- ${r.filename}: accepted, documentId=${r.upload?.document?.id}, versionId=${r.upload?.acceptedVersion?.id}, status=${r.upload?.acceptedVersion?.status}`);
|
|
231
215
|
return {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { ApiClient } from "../client.js";
|
|
3
|
+
/**
|
|
4
|
+
* Agent memory of organization members (agent memory spec §7.1, §7.4). The "my" tools act on
|
|
5
|
+
* the API key owner's own memory; the member tools are for ADMIN and OWNER keys and never
|
|
6
|
+
* show paths or content.
|
|
7
|
+
*/
|
|
8
|
+
export declare function register(server: McpServer, client: ApiClient): void;
|
|
9
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { formatErrorForMcp } from "../errors.js";
|
|
3
|
+
async function reply(action) {
|
|
4
|
+
try {
|
|
5
|
+
const data = await action();
|
|
6
|
+
return {
|
|
7
|
+
content: [{ type: "text", text: data === undefined ? "Done." : JSON.stringify(data, null, 2) }],
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
return { content: [{ type: "text", text: formatErrorForMcp(error) }], isError: true };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const path = z.string().min(1).describe("Memory path, /memories or below, e.g. /memories/preferences.md");
|
|
15
|
+
/**
|
|
16
|
+
* Agent memory of organization members (agent memory spec §7.1, §7.4). The "my" tools act on
|
|
17
|
+
* the API key owner's own memory; the member tools are for ADMIN and OWNER keys and never
|
|
18
|
+
* show paths or content.
|
|
19
|
+
*/
|
|
20
|
+
export function register(server, client) {
|
|
21
|
+
server.tool("2kw_list_my_memory_files", "List the files in your agent memory (the API key owner's), ordered by path, without content.", {}, async () => reply(async () => (await client.GET("/v1/memories/me/files")).data));
|
|
22
|
+
server.tool("2kw_read_my_memory_file", "Read one of your agent memory files: the raw content, its version (for ifMatchVersion) and which agent wrote it last.", { path }, async ({ path }) => reply(async () => (await client.GET("/v1/memories/me/file", { params: { query: { path } } })).data));
|
|
23
|
+
server.tool("2kw_write_my_memory_file", "Create or replace one of your agent memory files with the complete content. Pass ifMatchVersion (the version from 2kw_read_my_memory_file) to refuse the write if the file changed since. Credentials are refused; files are limited to 32 KB.", {
|
|
24
|
+
path,
|
|
25
|
+
content: z.string().describe("The complete UTF-8 text content of the file"),
|
|
26
|
+
ifMatchVersion: z.number().int().min(0).optional().describe("Only replace the file if it still has this version"),
|
|
27
|
+
}, async ({ path, content, ifMatchVersion }) => reply(async () => (await client.PUT("/v1/memories/me/file", {
|
|
28
|
+
params: { query: { path } },
|
|
29
|
+
body: { content },
|
|
30
|
+
headers: ifMatchVersion === undefined ? undefined : { "If-Match": `"${ifMatchVersion}"` },
|
|
31
|
+
})).data));
|
|
32
|
+
server.tool("2kw_delete_my_memory_file", "Delete one of your agent memory files, or a directory with everything below it. Irreversible.", { path }, async ({ path }) => reply(async () => {
|
|
33
|
+
await client.DELETE("/v1/memories/me/file", { params: { query: { path } } });
|
|
34
|
+
}));
|
|
35
|
+
server.tool("2kw_forget_my_memory", "Delete your whole agent memory. Irreversible: confirm with the user before calling.", {}, async () => reply(async () => {
|
|
36
|
+
await client.DELETE("/v1/memories/me");
|
|
37
|
+
}));
|
|
38
|
+
server.tool("2kw_list_member_memory_usage", "Agent memory totals per organization member: file count, total bytes and last write. Never paths or content. Needs an ADMIN or OWNER key.", {}, async () => reply(async () => (await client.GET("/v1/memories/users")).data));
|
|
39
|
+
server.tool("2kw_erase_member_memory", "Erase one member's whole agent memory in this organization. Irreversible: confirm with the user before calling. Needs an ADMIN or OWNER key.", { userId: z.string().min(1).describe("The member's user id, from 2kw_list_member_memory_usage") }, async ({ userId }) => reply(async () => {
|
|
40
|
+
await client.DELETE("/v1/memories/users/{userId}", { params: { path: { userId } } });
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=memory.js.map
|
package/dist/tools/tracing.js
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { formatErrorForMcp } from "../errors.js";
|
|
3
3
|
export function register(server, client) {
|
|
4
4
|
// ── settings ────────────────────────────────────────────────────────────
|
|
5
|
-
server.tool("2kw_get_tracing_settings", "Return the org's tracing settings
|
|
5
|
+
server.tool("2kw_get_tracing_settings", "Return the org's tracing settings: includePrompts / includeCompletions (whether raw prompt and completion content are persisted on ingested spans; false by default) and trace retention: retentionDays (the org's choice, null = follow the plan), planRetentionDays and effectiveRetentionDays.", {}, async () => {
|
|
6
6
|
try {
|
|
7
7
|
const { data } = await client.GET("/v1/tracing/settings");
|
|
8
8
|
return {
|
|
@@ -16,7 +16,7 @@ export function register(server, client) {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
server.tool("2kw_update_tracing_settings", "Update the org's tracing settings. Admin-only. Omit a field to leave it at its current value — the tool reads the current setting first and merges.", {
|
|
19
|
+
server.tool("2kw_update_tracing_settings", "Update the org's tracing settings. Admin-only. Omit a field to leave it at its current value — the tool reads the current setting first and merges. Shortening retentionDays deletes older traces at the next daily sweep.", {
|
|
20
20
|
includePrompts: z
|
|
21
21
|
.boolean()
|
|
22
22
|
.optional()
|
|
@@ -25,12 +25,20 @@ export function register(server, client) {
|
|
|
25
25
|
.boolean()
|
|
26
26
|
.optional()
|
|
27
27
|
.describe("Retain completion content on ingested spans (default false)"),
|
|
28
|
+
retentionDays: z
|
|
29
|
+
.number()
|
|
30
|
+
.int()
|
|
31
|
+
.min(1)
|
|
32
|
+
.nullable()
|
|
33
|
+
.optional()
|
|
34
|
+
.describe("Trace retention in days, at most the plan's limit (planRetentionDays). null follows the plan. Shortening deletes older traces at the next daily sweep."),
|
|
28
35
|
}, async (params) => {
|
|
29
36
|
try {
|
|
30
37
|
const { data: current } = await client.GET("/v1/tracing/settings");
|
|
31
38
|
const merged = {
|
|
32
39
|
includePrompts: params.includePrompts ?? current?.includePrompts ?? false,
|
|
33
40
|
includeCompletions: params.includeCompletions ?? current?.includeCompletions ?? false,
|
|
41
|
+
retentionDays: params.retentionDays !== undefined ? params.retentionDays : (current?.retentionDays ?? null),
|
|
34
42
|
};
|
|
35
43
|
const { data } = await client.PUT("/v1/tracing/settings", {
|
|
36
44
|
body: merged,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2kw/ai-mcp-server",
|
|
3
|
-
"version": "6.3.0-dev.
|
|
3
|
+
"version": "6.3.0-dev.89",
|
|
4
4
|
"description": "MCP server for 2kw.ai — EU-hosted AI platform: OpenAI-compatible LLM gateway, schema-driven document extraction, transcription, agents with a knowledge base, and cost observability. 158 tools for Claude Code, Cursor, and Windsurf.",
|
|
5
5
|
"mcpName": "ai.2kw/mcp-server",
|
|
6
6
|
"keywords": [
|
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
"check:generated": "tsx openapi/scripts/check-generated.ts",
|
|
42
42
|
"fix:generated": "tsx openapi/scripts/check-generated.ts --write",
|
|
43
43
|
"check:coverage": "tsx ../cli/openapi/scripts/check-coverage.ts",
|
|
44
|
+
"docs:tools": "tsx scripts/tool-docs.ts",
|
|
45
|
+
"check:tool-docs": "tsx scripts/tool-docs.ts --check",
|
|
44
46
|
"test": "tsx --test tests/*.test.ts",
|
|
45
47
|
"typecheck": "tsc --noEmit"
|
|
46
48
|
},
|