@dexto/server 1.5.8 → 1.6.1
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/events/a2a-sse-subscriber.d.ts +1 -1
- package/dist/hono/__tests__/test-fixtures.cjs +27 -6
- package/dist/hono/__tests__/test-fixtures.d.ts +2 -1
- package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
- package/dist/hono/__tests__/test-fixtures.js +31 -6
- package/dist/hono/index.cjs +17 -2
- package/dist/hono/index.d.ts +874 -58
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +17 -2
- package/dist/hono/routes/a2a-tasks.d.ts +6 -6
- package/dist/hono/routes/agents.cjs +38 -27
- package/dist/hono/routes/agents.d.ts +2 -1
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +37 -31
- package/dist/hono/routes/discovery.cjs +99 -22
- package/dist/hono/routes/discovery.d.ts +14 -12
- package/dist/hono/routes/discovery.d.ts.map +1 -1
- package/dist/hono/routes/discovery.js +89 -22
- package/dist/hono/routes/llm.d.ts +2 -2
- package/dist/hono/routes/mcp.cjs +96 -14
- package/dist/hono/routes/mcp.d.ts +139 -4
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +97 -15
- package/dist/hono/routes/memory.d.ts +1 -1
- package/dist/hono/routes/models.d.ts +1 -1
- package/dist/hono/routes/resources.d.ts +1 -1
- package/dist/hono/routes/schedules.cjs +456 -0
- package/dist/hono/routes/schedules.d.ts +472 -0
- package/dist/hono/routes/schedules.d.ts.map +1 -0
- package/dist/hono/routes/schedules.js +439 -0
- package/dist/hono/routes/search.d.ts +1 -1
- package/dist/hono/routes/sessions.cjs +10 -4
- package/dist/hono/routes/sessions.d.ts +135 -5
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +10 -4
- package/dist/hono/routes/tools.cjs +12 -19
- package/dist/hono/routes/tools.d.ts +5 -3
- package/dist/hono/routes/tools.d.ts.map +1 -1
- package/dist/hono/routes/tools.js +12 -19
- package/dist/hono/routes/workspaces.cjs +136 -0
- package/dist/hono/routes/workspaces.d.ts +77 -0
- package/dist/hono/routes/workspaces.d.ts.map +1 -0
- package/dist/hono/routes/workspaces.js +112 -0
- package/dist/hono/schemas/responses.cjs +82 -7
- package/dist/hono/schemas/responses.d.ts +366 -16
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +75 -6
- package/dist/hono/start-server.cjs +3 -3
- package/dist/hono/start-server.d.ts +15 -6
- package/dist/hono/start-server.d.ts.map +1 -1
- package/dist/hono/start-server.js +3 -3
- package/dist/index.cjs +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/mcp/mcp-handler.d.ts +2 -2
- package/dist/mcp/mcp-handler.d.ts.map +1 -1
- package/package.json +8 -5
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
-
|
|
2
|
+
import type { Context } from 'hono';
|
|
3
|
+
export type GetAgentConfigPathFn = (ctx: Context) => string | undefined | Promise<string | undefined>;
|
|
4
|
+
export declare function createDiscoveryRouter(getAgentConfigPath: GetAgentConfigPathFn): OpenAPIHono<import("hono").Env, {
|
|
3
5
|
"/discovery": {
|
|
4
6
|
$get: {
|
|
5
7
|
input: {};
|
|
6
8
|
output: {
|
|
7
|
-
|
|
8
|
-
description: string;
|
|
9
|
-
name: string;
|
|
10
|
-
}[];
|
|
11
|
-
customTools: {
|
|
9
|
+
blob: {
|
|
12
10
|
type: string;
|
|
13
|
-
category: "
|
|
11
|
+
category: "blob" | "tools" | "compaction" | "database";
|
|
14
12
|
metadata?: {
|
|
15
13
|
[x: string]: import("hono/utils/types").JSONValue;
|
|
16
14
|
description?: string | undefined;
|
|
@@ -19,31 +17,35 @@ export declare function createDiscoveryRouter(): OpenAPIHono<import("hono").Env,
|
|
|
19
17
|
}[];
|
|
20
18
|
compaction: {
|
|
21
19
|
type: string;
|
|
22
|
-
category: "
|
|
20
|
+
category: "blob" | "tools" | "compaction" | "database";
|
|
23
21
|
metadata?: {
|
|
24
22
|
[x: string]: import("hono/utils/types").JSONValue;
|
|
25
23
|
description?: string | undefined;
|
|
26
24
|
displayName?: string | undefined;
|
|
27
25
|
} | undefined;
|
|
28
26
|
}[];
|
|
29
|
-
|
|
27
|
+
database: {
|
|
30
28
|
type: string;
|
|
31
|
-
category: "
|
|
29
|
+
category: "blob" | "tools" | "compaction" | "database";
|
|
32
30
|
metadata?: {
|
|
33
31
|
[x: string]: import("hono/utils/types").JSONValue;
|
|
34
32
|
description?: string | undefined;
|
|
35
33
|
displayName?: string | undefined;
|
|
36
34
|
} | undefined;
|
|
37
35
|
}[];
|
|
38
|
-
|
|
36
|
+
toolFactories: {
|
|
39
37
|
type: string;
|
|
40
|
-
category: "
|
|
38
|
+
category: "blob" | "tools" | "compaction" | "database";
|
|
41
39
|
metadata?: {
|
|
42
40
|
[x: string]: import("hono/utils/types").JSONValue;
|
|
43
41
|
description?: string | undefined;
|
|
44
42
|
displayName?: string | undefined;
|
|
45
43
|
} | undefined;
|
|
46
44
|
}[];
|
|
45
|
+
builtinTools: {
|
|
46
|
+
description: string;
|
|
47
|
+
name: string;
|
|
48
|
+
}[];
|
|
47
49
|
};
|
|
48
50
|
outputFormat: "json";
|
|
49
51
|
status: 200;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAMpC,MAAM,MAAM,oBAAoB,GAAG,CAC/B,GAAG,EAAE,OAAO,KACX,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAgJtD,wBAAgB,qBAAqB,CAAC,kBAAkB,EAAE,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAqB7E"}
|
|
@@ -1,42 +1,109 @@
|
|
|
1
1
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { loadImage } from "@dexto/agent-config";
|
|
3
|
+
import { loadAgentConfig } from "@dexto/agent-management";
|
|
4
|
+
import imageLocal from "@dexto/image-local";
|
|
5
|
+
const DiscoveredFactorySchema = z.object({
|
|
6
|
+
type: z.string().describe("Factory type identifier"),
|
|
7
|
+
category: z.enum(["blob", "database", "compaction", "tools"]).describe("Factory category"),
|
|
6
8
|
metadata: z.object({
|
|
7
9
|
displayName: z.string().optional().describe("Human-readable display name"),
|
|
8
|
-
description: z.string().optional().describe("
|
|
9
|
-
}).passthrough().optional().describe("Optional metadata about the
|
|
10
|
-
}).describe("Information about a registered
|
|
11
|
-
const
|
|
12
|
-
name: z.string().describe('
|
|
10
|
+
description: z.string().optional().describe("Factory description")
|
|
11
|
+
}).passthrough().optional().describe("Optional metadata about the factory")
|
|
12
|
+
}).describe("Information about a registered factory");
|
|
13
|
+
const ToolSchema = z.object({
|
|
14
|
+
name: z.string().describe('Built-in tool name identifier (e.g., "search_history", "ask_user")'),
|
|
13
15
|
description: z.string().describe("Human-readable description of what the tool does")
|
|
14
|
-
}).describe("Information about
|
|
16
|
+
}).describe("Information about a built-in tool");
|
|
15
17
|
const DiscoveryResponseSchema = z.object({
|
|
16
|
-
blob: z.array(
|
|
17
|
-
database: z.array(
|
|
18
|
-
compaction: z.array(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}).describe("Discovery response with
|
|
22
|
-
function
|
|
18
|
+
blob: z.array(DiscoveredFactorySchema).describe("Blob storage factories"),
|
|
19
|
+
database: z.array(DiscoveredFactorySchema).describe("Database factories"),
|
|
20
|
+
compaction: z.array(DiscoveredFactorySchema).describe("Compaction strategy factories"),
|
|
21
|
+
toolFactories: z.array(DiscoveredFactorySchema).describe("Tool factories"),
|
|
22
|
+
builtinTools: z.array(ToolSchema).describe("Built-in tools available for configuration")
|
|
23
|
+
}).describe("Discovery response with factories grouped by category");
|
|
24
|
+
function toMetadata(metadata) {
|
|
25
|
+
if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
const record = metadata;
|
|
29
|
+
const result = {};
|
|
30
|
+
for (const [key, value] of Object.entries(record)) {
|
|
31
|
+
if (value === void 0) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
35
|
+
result[key] = value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
39
|
+
}
|
|
40
|
+
async function resolveImage(options) {
|
|
41
|
+
const { ctx, getAgentConfigPath } = options;
|
|
42
|
+
const configPath = await getAgentConfigPath(ctx);
|
|
43
|
+
if (!configPath) {
|
|
44
|
+
return imageLocal;
|
|
45
|
+
}
|
|
46
|
+
const rawConfig = await loadAgentConfig(configPath);
|
|
47
|
+
const imageName = (typeof rawConfig.image === "string" && rawConfig.image.length > 0 ? rawConfig.image : void 0) ?? process.env.DEXTO_IMAGE ?? "@dexto/image-local";
|
|
48
|
+
if (imageName === "@dexto/image-local") {
|
|
49
|
+
return imageLocal;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
return await loadImage(imageName);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Failed to load image module '${imageName}'. Ensure it is installed and that the host called setImageImporter(). Original error: ${message}`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async function listDiscoveryFactories(options) {
|
|
61
|
+
const image = await resolveImage(options);
|
|
62
|
+
const blob = Object.entries(image.storage.blob).map(([type, factory]) => ({
|
|
63
|
+
type,
|
|
64
|
+
category: "blob",
|
|
65
|
+
metadata: toMetadata(factory.metadata)
|
|
66
|
+
}));
|
|
67
|
+
const database = Object.entries(image.storage.database).map(([type, factory]) => ({
|
|
68
|
+
type,
|
|
69
|
+
category: "database",
|
|
70
|
+
metadata: toMetadata(factory.metadata)
|
|
71
|
+
}));
|
|
72
|
+
const compaction = Object.entries(image.compaction).map(([type, factory]) => ({
|
|
73
|
+
type,
|
|
74
|
+
category: "compaction",
|
|
75
|
+
metadata: toMetadata(factory.metadata)
|
|
76
|
+
}));
|
|
77
|
+
const toolFactories = Object.entries(image.tools);
|
|
78
|
+
const builtinFactory = toolFactories.find(([type]) => type === "builtin-tools")?.[1];
|
|
79
|
+
const builtinTools = builtinFactory ? builtinFactory.create(builtinFactory.configSchema.parse({ type: "builtin-tools" })).map((tool) => ({
|
|
80
|
+
name: tool.id,
|
|
81
|
+
description: tool.description
|
|
82
|
+
})) : [];
|
|
83
|
+
const toolFactoriesList = toolFactories.filter(([type]) => type !== "builtin-tools").map(([type, factory]) => ({
|
|
84
|
+
type,
|
|
85
|
+
category: "tools",
|
|
86
|
+
metadata: toMetadata(factory.metadata)
|
|
87
|
+
}));
|
|
88
|
+
return { blob, database, compaction, toolFactories: toolFactoriesList, builtinTools };
|
|
89
|
+
}
|
|
90
|
+
function createDiscoveryRouter(getAgentConfigPath) {
|
|
23
91
|
const app = new OpenAPIHono();
|
|
24
92
|
const discoveryRoute = createRoute({
|
|
25
93
|
method: "get",
|
|
26
94
|
path: "/discovery",
|
|
27
|
-
summary: "Discover Available
|
|
28
|
-
description: "Returns all
|
|
95
|
+
summary: "Discover Available Factories and Tools",
|
|
96
|
+
description: "Returns all available factories (storage, compaction, tools) for the currently active image.",
|
|
29
97
|
tags: ["discovery"],
|
|
30
98
|
responses: {
|
|
31
99
|
200: {
|
|
32
|
-
description: "Available
|
|
100
|
+
description: "Available factories grouped by category",
|
|
33
101
|
content: { "application/json": { schema: DiscoveryResponseSchema } }
|
|
34
102
|
}
|
|
35
103
|
}
|
|
36
104
|
});
|
|
37
105
|
return app.openapi(discoveryRoute, async (ctx) => {
|
|
38
|
-
|
|
39
|
-
return ctx.json(providers);
|
|
106
|
+
return ctx.json(await listDiscoveryFactories({ ctx, getAgentConfigPath }));
|
|
40
107
|
});
|
|
41
108
|
}
|
|
42
109
|
export {
|
|
@@ -450,9 +450,9 @@ export declare function createLlmRouter(getAgent: GetAgentFn): OpenAPIHono<impor
|
|
|
450
450
|
$post: {
|
|
451
451
|
input: {
|
|
452
452
|
json: {
|
|
453
|
+
apiKey?: string | undefined;
|
|
453
454
|
model?: string | undefined;
|
|
454
455
|
provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova" | undefined;
|
|
455
|
-
apiKey?: string | undefined;
|
|
456
456
|
maxInputTokens?: number | undefined;
|
|
457
457
|
maxIterations?: number | undefined;
|
|
458
458
|
baseURL?: string | undefined;
|
|
@@ -559,8 +559,8 @@ export declare function createLlmRouter(getAgent: GetAgentFn): OpenAPIHono<impor
|
|
|
559
559
|
};
|
|
560
560
|
};
|
|
561
561
|
output: {
|
|
562
|
-
ok: false;
|
|
563
562
|
error: string;
|
|
563
|
+
ok: false;
|
|
564
564
|
};
|
|
565
565
|
outputFormat: "json";
|
|
566
566
|
status: 404;
|
package/dist/hono/routes/mcp.cjs
CHANGED
|
@@ -29,7 +29,11 @@ const McpServerRequestSchema = import_zod_openapi.z.object({
|
|
|
29
29
|
name: import_zod_openapi.z.string().min(1, "Server name is required").describe("A unique name for the server"),
|
|
30
30
|
config: import_core.McpServerConfigSchema.describe("The server configuration object"),
|
|
31
31
|
persistToAgent: import_zod_openapi.z.boolean().optional().describe("If true, saves the server to agent configuration file")
|
|
32
|
-
}).describe("Request body for adding or updating an MCP server");
|
|
32
|
+
}).strict().describe("Request body for adding or updating an MCP server");
|
|
33
|
+
const McpServerUpdateSchema = import_zod_openapi.z.object({
|
|
34
|
+
config: import_core.McpServerConfigSchema.describe("The updated server configuration object"),
|
|
35
|
+
persistToAgent: import_zod_openapi.z.boolean().optional().describe("If true, saves the server to agent configuration file")
|
|
36
|
+
}).strict().describe("Request body for updating an MCP server");
|
|
33
37
|
const ExecuteToolBodySchema = import_zod_openapi.z.record(import_zod_openapi.z.unknown()).describe(
|
|
34
38
|
"Tool execution parameters as JSON object. The specific fields depend on the tool being executed and are defined by the tool's inputSchema."
|
|
35
39
|
);
|
|
@@ -60,7 +64,8 @@ const ToolInfoSchema = import_zod_openapi.z.object({
|
|
|
60
64
|
id: import_zod_openapi.z.string().describe("Tool identifier"),
|
|
61
65
|
name: import_zod_openapi.z.string().describe("Tool name"),
|
|
62
66
|
description: import_zod_openapi.z.string().describe("Tool description"),
|
|
63
|
-
inputSchema: ToolInputSchema.optional().describe("JSON Schema for tool input parameters")
|
|
67
|
+
inputSchema: ToolInputSchema.optional().describe("JSON Schema for tool input parameters"),
|
|
68
|
+
_meta: import_zod_openapi.z.record(import_zod_openapi.z.unknown()).optional().describe("Optional tool metadata (e.g., MCP Apps UI resource info)")
|
|
64
69
|
}).strict().describe("Tool information");
|
|
65
70
|
const ToolsListResponseSchema = import_zod_openapi.z.object({
|
|
66
71
|
tools: import_zod_openapi.z.array(ToolInfoSchema).describe("Array of available tools")
|
|
@@ -78,6 +83,10 @@ const ToolExecutionResponseSchema = import_zod_openapi.z.object({
|
|
|
78
83
|
data: import_zod_openapi.z.any().optional().describe("Tool execution result data"),
|
|
79
84
|
error: import_zod_openapi.z.string().optional().describe("Error message if execution failed")
|
|
80
85
|
}).strict().describe("Tool execution response");
|
|
86
|
+
const ServerConfigResponseSchema = import_zod_openapi.z.object({
|
|
87
|
+
name: import_zod_openapi.z.string().describe("Server name"),
|
|
88
|
+
config: import_core.McpServerConfigSchema.describe("Server configuration")
|
|
89
|
+
}).strict().describe("MCP server configuration response");
|
|
81
90
|
const ResourcesListResponseSchema = import_zod_openapi.z.object({
|
|
82
91
|
success: import_zod_openapi.z.boolean().describe("Success indicator"),
|
|
83
92
|
resources: import_zod_openapi.z.array(import_responses.ResourceSchema).describe("Array of available resources")
|
|
@@ -89,7 +98,7 @@ const ResourceContentResponseSchema = import_zod_openapi.z.object({
|
|
|
89
98
|
success: import_zod_openapi.z.boolean().describe("Success indicator"),
|
|
90
99
|
data: ResourceContentSchema.describe("Resource content")
|
|
91
100
|
}).strict().describe("Resource content response");
|
|
92
|
-
function createMcpRouter(getAgent) {
|
|
101
|
+
function createMcpRouter(getAgent, getAgentConfigPath) {
|
|
93
102
|
const app = new import_zod_openapi.OpenAPIHono();
|
|
94
103
|
const addServerRoute = (0, import_zod_openapi.createRoute)({
|
|
95
104
|
method: "post",
|
|
@@ -118,6 +127,41 @@ function createMcpRouter(getAgent) {
|
|
|
118
127
|
}
|
|
119
128
|
}
|
|
120
129
|
});
|
|
130
|
+
const getServerConfigRoute = (0, import_zod_openapi.createRoute)({
|
|
131
|
+
method: "get",
|
|
132
|
+
path: "/mcp/servers/{serverId}/config",
|
|
133
|
+
summary: "Get MCP Server Config",
|
|
134
|
+
description: "Retrieves the configuration for a specific MCP server",
|
|
135
|
+
tags: ["mcp"],
|
|
136
|
+
request: {
|
|
137
|
+
params: import_zod_openapi.z.object({ serverId: import_zod_openapi.z.string().describe("The ID of the MCP server") })
|
|
138
|
+
},
|
|
139
|
+
responses: {
|
|
140
|
+
200: {
|
|
141
|
+
description: "Server configuration",
|
|
142
|
+
content: { "application/json": { schema: ServerConfigResponseSchema } }
|
|
143
|
+
},
|
|
144
|
+
404: { description: "Not found" }
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
const updateServerRoute = (0, import_zod_openapi.createRoute)({
|
|
148
|
+
method: "put",
|
|
149
|
+
path: "/mcp/servers/{serverId}",
|
|
150
|
+
summary: "Update MCP Server",
|
|
151
|
+
description: "Updates configuration for an existing MCP server",
|
|
152
|
+
tags: ["mcp"],
|
|
153
|
+
request: {
|
|
154
|
+
params: import_zod_openapi.z.object({ serverId: import_zod_openapi.z.string().describe("The ID of the MCP server") }),
|
|
155
|
+
body: { content: { "application/json": { schema: McpServerUpdateSchema } } }
|
|
156
|
+
},
|
|
157
|
+
responses: {
|
|
158
|
+
200: {
|
|
159
|
+
description: "Server updated",
|
|
160
|
+
content: { "application/json": { schema: ServerStatusResponseSchema } }
|
|
161
|
+
},
|
|
162
|
+
404: { description: "Not found" }
|
|
163
|
+
}
|
|
164
|
+
});
|
|
121
165
|
const toolsRoute = (0, import_zod_openapi.createRoute)({
|
|
122
166
|
method: "get",
|
|
123
167
|
path: "/mcp/servers/{serverId}/tools",
|
|
@@ -237,6 +281,10 @@ function createMcpRouter(getAgent) {
|
|
|
237
281
|
);
|
|
238
282
|
if (persistToAgent === true) {
|
|
239
283
|
try {
|
|
284
|
+
const agentPath = await getAgentConfigPath(ctx);
|
|
285
|
+
if (!agentPath) {
|
|
286
|
+
throw import_core.AgentError.noConfigPath();
|
|
287
|
+
}
|
|
240
288
|
const currentConfig = agent.getEffectiveConfig();
|
|
241
289
|
const updates = {
|
|
242
290
|
mcpServers: {
|
|
@@ -244,16 +292,7 @@ function createMcpRouter(getAgent) {
|
|
|
244
292
|
[name]: config
|
|
245
293
|
}
|
|
246
294
|
};
|
|
247
|
-
|
|
248
|
-
agent.getAgentFilePath(),
|
|
249
|
-
updates
|
|
250
|
-
);
|
|
251
|
-
const reloadResult = await agent.reload(newConfig);
|
|
252
|
-
if (reloadResult.restarted) {
|
|
253
|
-
import_core.logger.info(
|
|
254
|
-
`Agent restarted to apply changes: ${reloadResult.changesApplied.join(", ")}`
|
|
255
|
-
);
|
|
256
|
-
}
|
|
295
|
+
await (0, import_agent_management.updateAgentConfigFile)(agentPath, updates);
|
|
257
296
|
import_core.logger.info(`Saved server '${name}' to agent configuration file`);
|
|
258
297
|
} catch (saveError) {
|
|
259
298
|
const errorMessage = saveError instanceof Error ? saveError.message : String(saveError);
|
|
@@ -279,6 +318,48 @@ function createMcpRouter(getAgent) {
|
|
|
279
318
|
servers.push({ id: name, name, status: "error" });
|
|
280
319
|
}
|
|
281
320
|
return ctx.json({ servers });
|
|
321
|
+
}).openapi(getServerConfigRoute, async (ctx) => {
|
|
322
|
+
const agent = await getAgent(ctx);
|
|
323
|
+
const { serverId } = ctx.req.valid("param");
|
|
324
|
+
const config = agent.getMcpServerConfig(serverId);
|
|
325
|
+
if (!config) {
|
|
326
|
+
return ctx.json({ error: `Server '${serverId}' not found.` }, 404);
|
|
327
|
+
}
|
|
328
|
+
return ctx.json({ name: serverId, config }, 200);
|
|
329
|
+
}).openapi(updateServerRoute, async (ctx) => {
|
|
330
|
+
const agent = await getAgent(ctx);
|
|
331
|
+
const { serverId } = ctx.req.valid("param");
|
|
332
|
+
const { config, persistToAgent } = ctx.req.valid("json");
|
|
333
|
+
const existingConfig = agent.getMcpServerConfig(serverId);
|
|
334
|
+
if (!existingConfig) {
|
|
335
|
+
return ctx.json({ error: `Server '${serverId}' not found.` }, 404);
|
|
336
|
+
}
|
|
337
|
+
await agent.updateMcpServer(serverId, config);
|
|
338
|
+
if (persistToAgent === true) {
|
|
339
|
+
try {
|
|
340
|
+
const agentPath = await getAgentConfigPath(ctx);
|
|
341
|
+
if (!agentPath) {
|
|
342
|
+
throw import_core.AgentError.noConfigPath();
|
|
343
|
+
}
|
|
344
|
+
const currentConfig = agent.getEffectiveConfig();
|
|
345
|
+
const updates = {
|
|
346
|
+
mcpServers: {
|
|
347
|
+
...currentConfig.mcpServers || {},
|
|
348
|
+
[serverId]: config
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
await (0, import_agent_management.updateAgentConfigFile)(agentPath, updates);
|
|
352
|
+
import_core.logger.info(`Saved server '${serverId}' to agent configuration file`);
|
|
353
|
+
} catch (saveError) {
|
|
354
|
+
const errorMessage = saveError instanceof Error ? saveError.message : String(saveError);
|
|
355
|
+
import_core.logger.warn(
|
|
356
|
+
`Failed to persist MCP server '${serverId}' update: ${errorMessage}`,
|
|
357
|
+
{ error: saveError }
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const status = config.enabled === false ? "registered" : "connected";
|
|
362
|
+
return ctx.json({ status, name: serverId }, 200);
|
|
282
363
|
}).openapi(toolsRoute, async (ctx) => {
|
|
283
364
|
const agent = await getAgent(ctx);
|
|
284
365
|
const { serverId } = ctx.req.valid("param");
|
|
@@ -291,7 +372,8 @@ function createMcpRouter(getAgent) {
|
|
|
291
372
|
id: toolName,
|
|
292
373
|
name: toolName,
|
|
293
374
|
description: toolDef.description || "",
|
|
294
|
-
inputSchema: toolDef.parameters
|
|
375
|
+
inputSchema: toolDef.parameters,
|
|
376
|
+
_meta: toolDef._meta
|
|
295
377
|
}));
|
|
296
378
|
return ctx.json({ tools });
|
|
297
379
|
}).openapi(deleteServerRoute, async (ctx) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
-
import type { GetAgentFn } from '../index.js';
|
|
3
|
-
export declare function createMcpRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
|
|
2
|
+
import type { GetAgentConfigPathFn, GetAgentFn } from '../index.js';
|
|
3
|
+
export declare function createMcpRouter(getAgent: GetAgentFn, getAgentConfigPath: GetAgentConfigPathFn): OpenAPIHono<import("hono").Env, {
|
|
4
4
|
"/mcp/servers": {
|
|
5
5
|
$post: {
|
|
6
6
|
input: {
|
|
@@ -9,8 +9,8 @@ export declare function createMcpRouter(getAgent: GetAgentFn): OpenAPIHono<impor
|
|
|
9
9
|
type: "stdio";
|
|
10
10
|
command: string;
|
|
11
11
|
timeout?: number | undefined;
|
|
12
|
-
enabled?: boolean | undefined;
|
|
13
12
|
args?: string[] | undefined;
|
|
13
|
+
enabled?: boolean | undefined;
|
|
14
14
|
env?: Record<string, string> | undefined;
|
|
15
15
|
connectionMode?: "strict" | "lenient" | undefined;
|
|
16
16
|
} | {
|
|
@@ -55,6 +55,138 @@ export declare function createMcpRouter(getAgent: GetAgentFn): OpenAPIHono<impor
|
|
|
55
55
|
status: 200;
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
|
+
} & {
|
|
59
|
+
"/mcp/servers/:serverId/config": {
|
|
60
|
+
$get: {
|
|
61
|
+
input: {
|
|
62
|
+
param: {
|
|
63
|
+
serverId: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
output: {};
|
|
67
|
+
outputFormat: string;
|
|
68
|
+
status: 404;
|
|
69
|
+
} | {
|
|
70
|
+
input: {
|
|
71
|
+
param: {
|
|
72
|
+
serverId: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
output: {
|
|
76
|
+
config: {
|
|
77
|
+
timeout: number;
|
|
78
|
+
type: "stdio";
|
|
79
|
+
args: string[];
|
|
80
|
+
command: string;
|
|
81
|
+
enabled: boolean;
|
|
82
|
+
env: {
|
|
83
|
+
[x: string]: string;
|
|
84
|
+
};
|
|
85
|
+
connectionMode: "strict" | "lenient";
|
|
86
|
+
} | {
|
|
87
|
+
timeout: number;
|
|
88
|
+
type: "sse";
|
|
89
|
+
enabled: boolean;
|
|
90
|
+
connectionMode: "strict" | "lenient";
|
|
91
|
+
url: string;
|
|
92
|
+
headers: {
|
|
93
|
+
[x: string]: string;
|
|
94
|
+
};
|
|
95
|
+
} | {
|
|
96
|
+
timeout: number;
|
|
97
|
+
type: "http";
|
|
98
|
+
enabled: boolean;
|
|
99
|
+
connectionMode: "strict" | "lenient";
|
|
100
|
+
url: string;
|
|
101
|
+
headers: {
|
|
102
|
+
[x: string]: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
name: string;
|
|
106
|
+
};
|
|
107
|
+
outputFormat: "json";
|
|
108
|
+
status: 200;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
} & {
|
|
112
|
+
"/mcp/servers/:serverId": {
|
|
113
|
+
$put: {
|
|
114
|
+
input: {
|
|
115
|
+
param: {
|
|
116
|
+
serverId: string;
|
|
117
|
+
};
|
|
118
|
+
} & {
|
|
119
|
+
json: {
|
|
120
|
+
config: {
|
|
121
|
+
type: "stdio";
|
|
122
|
+
command: string;
|
|
123
|
+
timeout?: number | undefined;
|
|
124
|
+
args?: string[] | undefined;
|
|
125
|
+
enabled?: boolean | undefined;
|
|
126
|
+
env?: Record<string, string> | undefined;
|
|
127
|
+
connectionMode?: "strict" | "lenient" | undefined;
|
|
128
|
+
} | {
|
|
129
|
+
type: "sse";
|
|
130
|
+
url: string;
|
|
131
|
+
timeout?: number | undefined;
|
|
132
|
+
enabled?: boolean | undefined;
|
|
133
|
+
connectionMode?: "strict" | "lenient" | undefined;
|
|
134
|
+
headers?: Record<string, string> | undefined;
|
|
135
|
+
} | {
|
|
136
|
+
type: "http";
|
|
137
|
+
url: string;
|
|
138
|
+
timeout?: number | undefined;
|
|
139
|
+
enabled?: boolean | undefined;
|
|
140
|
+
connectionMode?: "strict" | "lenient" | undefined;
|
|
141
|
+
headers?: Record<string, string> | undefined;
|
|
142
|
+
};
|
|
143
|
+
persistToAgent?: boolean | undefined;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
output: {};
|
|
147
|
+
outputFormat: string;
|
|
148
|
+
status: 404;
|
|
149
|
+
} | {
|
|
150
|
+
input: {
|
|
151
|
+
param: {
|
|
152
|
+
serverId: string;
|
|
153
|
+
};
|
|
154
|
+
} & {
|
|
155
|
+
json: {
|
|
156
|
+
config: {
|
|
157
|
+
type: "stdio";
|
|
158
|
+
command: string;
|
|
159
|
+
timeout?: number | undefined;
|
|
160
|
+
args?: string[] | undefined;
|
|
161
|
+
enabled?: boolean | undefined;
|
|
162
|
+
env?: Record<string, string> | undefined;
|
|
163
|
+
connectionMode?: "strict" | "lenient" | undefined;
|
|
164
|
+
} | {
|
|
165
|
+
type: "sse";
|
|
166
|
+
url: string;
|
|
167
|
+
timeout?: number | undefined;
|
|
168
|
+
enabled?: boolean | undefined;
|
|
169
|
+
connectionMode?: "strict" | "lenient" | undefined;
|
|
170
|
+
headers?: Record<string, string> | undefined;
|
|
171
|
+
} | {
|
|
172
|
+
type: "http";
|
|
173
|
+
url: string;
|
|
174
|
+
timeout?: number | undefined;
|
|
175
|
+
enabled?: boolean | undefined;
|
|
176
|
+
connectionMode?: "strict" | "lenient" | undefined;
|
|
177
|
+
headers?: Record<string, string> | undefined;
|
|
178
|
+
};
|
|
179
|
+
persistToAgent?: boolean | undefined;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
output: {
|
|
183
|
+
status: string;
|
|
184
|
+
name: string;
|
|
185
|
+
};
|
|
186
|
+
outputFormat: "json";
|
|
187
|
+
status: 200;
|
|
188
|
+
};
|
|
189
|
+
};
|
|
58
190
|
} & {
|
|
59
191
|
"/mcp/servers/:serverId/tools": {
|
|
60
192
|
$get: {
|
|
@@ -91,6 +223,9 @@ export declare function createMcpRouter(getAgent: GetAgentFn): OpenAPIHono<impor
|
|
|
91
223
|
} | undefined;
|
|
92
224
|
required?: string[] | undefined;
|
|
93
225
|
} | undefined;
|
|
226
|
+
_meta?: {
|
|
227
|
+
[x: string]: import("hono/utils/types").JSONValue;
|
|
228
|
+
} | undefined;
|
|
94
229
|
}[];
|
|
95
230
|
};
|
|
96
231
|
outputFormat: "json";
|
|
@@ -197,7 +332,6 @@ export declare function createMcpRouter(getAgent: GetAgentFn): OpenAPIHono<impor
|
|
|
197
332
|
};
|
|
198
333
|
};
|
|
199
334
|
output: {
|
|
200
|
-
success: boolean;
|
|
201
335
|
resources: {
|
|
202
336
|
uri: string;
|
|
203
337
|
source: "mcp" | "internal";
|
|
@@ -211,6 +345,7 @@ export declare function createMcpRouter(getAgent: GetAgentFn): OpenAPIHono<impor
|
|
|
211
345
|
size?: number | undefined;
|
|
212
346
|
lastModified?: string | undefined;
|
|
213
347
|
}[];
|
|
348
|
+
success: boolean;
|
|
214
349
|
};
|
|
215
350
|
outputFormat: "json";
|
|
216
351
|
status: 200;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAIhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAIhE,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA+JpE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAuY7F"}
|