@dexto/server 1.6.19 → 1.6.21
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/a2a/jsonrpc/methods.cjs +1 -1
- package/dist/a2a/jsonrpc/methods.d.ts +14 -4
- package/dist/a2a/jsonrpc/methods.d.ts.map +1 -1
- package/dist/a2a/jsonrpc/methods.js +1 -1
- package/dist/hono/index.cjs +39 -8
- package/dist/hono/index.d.ts +43 -4503
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +42 -9
- package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.cjs +173 -34
- package/dist/hono/routes/a2a-tasks.d.ts +1 -498
- package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.js +177 -34
- package/dist/hono/routes/a2a.d.ts.map +1 -1
- package/dist/hono/routes/agents.cjs +410 -329
- package/dist/hono/routes/agents.d.ts +16048 -73
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +418 -330
- package/dist/hono/routes/approvals.cjs +103 -78
- package/dist/hono/routes/approvals.d.ts +2090 -112
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +108 -78
- package/dist/hono/routes/dexto-auth.cjs +40 -33
- package/dist/hono/routes/dexto-auth.d.ts +401 -2
- package/dist/hono/routes/dexto-auth.d.ts.map +1 -1
- package/dist/hono/routes/dexto-auth.js +40 -33
- package/dist/hono/routes/discovery.cjs +16 -14
- package/dist/hono/routes/discovery.d.ts +586 -1
- package/dist/hono/routes/discovery.d.ts.map +1 -1
- package/dist/hono/routes/discovery.js +16 -14
- package/dist/hono/routes/greeting.cjs +26 -22
- package/dist/hono/routes/greeting.d.ts +787 -3
- package/dist/hono/routes/greeting.d.ts.map +1 -1
- package/dist/hono/routes/greeting.js +26 -22
- package/dist/hono/routes/health.d.ts +1 -1
- package/dist/hono/routes/key.cjs +60 -52
- package/dist/hono/routes/key.d.ts +1597 -1
- package/dist/hono/routes/key.d.ts.map +1 -1
- package/dist/hono/routes/key.js +60 -52
- package/dist/hono/routes/llm.cjs +381 -348
- package/dist/hono/routes/llm.d.ts +12137 -87
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +385 -348
- package/dist/hono/routes/mcp.cjs +273 -212
- package/dist/hono/routes/mcp.d.ts +6605 -316
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +287 -213
- package/dist/hono/routes/memory.cjs +102 -89
- package/dist/hono/routes/memory.d.ts +5368 -4
- package/dist/hono/routes/memory.d.ts.map +1 -1
- package/dist/hono/routes/memory.js +108 -90
- package/dist/hono/routes/messages.cjs +171 -164
- package/dist/hono/routes/messages.d.ts +3899 -10
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +181 -165
- package/dist/hono/routes/models.cjs +106 -64
- package/dist/hono/routes/models.d.ts +2874 -1
- package/dist/hono/routes/models.d.ts.map +1 -1
- package/dist/hono/routes/models.js +108 -64
- package/dist/hono/routes/openrouter.cjs +79 -65
- package/dist/hono/routes/openrouter.d.ts +854 -1
- package/dist/hono/routes/openrouter.d.ts.map +1 -1
- package/dist/hono/routes/openrouter.js +79 -65
- package/dist/hono/routes/prompts.cjs +137 -104
- package/dist/hono/routes/prompts.d.ts +2820 -12
- package/dist/hono/routes/prompts.d.ts.map +1 -1
- package/dist/hono/routes/prompts.js +144 -105
- package/dist/hono/routes/queue.cjs +158 -132
- package/dist/hono/routes/queue.d.ts +5148 -13
- package/dist/hono/routes/queue.d.ts.map +1 -1
- package/dist/hono/routes/queue.js +168 -133
- package/dist/hono/routes/resources.cjs +65 -46
- package/dist/hono/routes/resources.d.ts +1983 -5
- package/dist/hono/routes/resources.d.ts.map +1 -1
- package/dist/hono/routes/resources.js +72 -47
- package/dist/hono/routes/schedules.cjs +233 -226
- package/dist/hono/routes/schedules.d.ts +4202 -26
- package/dist/hono/routes/schedules.d.ts.map +1 -1
- package/dist/hono/routes/schedules.js +233 -226
- package/dist/hono/routes/search.cjs +34 -30
- package/dist/hono/routes/search.d.ts +2837 -14
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +40 -31
- package/dist/hono/routes/sessions.cjs +404 -392
- package/dist/hono/routes/sessions.d.ts +16585 -30
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +408 -393
- package/dist/hono/routes/static.d.ts.map +1 -1
- package/dist/hono/routes/system-prompt.cjs +57 -61
- package/dist/hono/routes/system-prompt.d.ts +1228 -2
- package/dist/hono/routes/system-prompt.d.ts.map +1 -1
- package/dist/hono/routes/system-prompt.js +58 -62
- package/dist/hono/routes/tools.cjs +29 -34
- package/dist/hono/routes/tools.d.ts +1756 -7
- package/dist/hono/routes/tools.d.ts.map +1 -1
- package/dist/hono/routes/tools.js +33 -33
- package/dist/hono/routes/webhooks.cjs +159 -132
- package/dist/hono/routes/webhooks.d.ts +2504 -14
- package/dist/hono/routes/webhooks.d.ts.map +1 -1
- package/dist/hono/routes/webhooks.js +163 -132
- package/dist/hono/routes/workspaces.cjs +84 -79
- package/dist/hono/routes/workspaces.d.ts +2093 -2
- package/dist/hono/routes/workspaces.d.ts.map +1 -1
- package/dist/hono/routes/workspaces.js +89 -80
- package/dist/hono/schemas/responses.cjs +492 -235
- package/dist/hono/schemas/responses.d.ts +1461 -146
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +247 -9
- package/dist/hono/types.d.ts +11 -0
- package/dist/hono/types.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/hono/routes/mcp.cjs
CHANGED
|
@@ -34,7 +34,7 @@ const McpServerUpdateSchema = import_zod_openapi.z.object({
|
|
|
34
34
|
config: import_core.McpServerConfigSchema.describe("The updated server configuration object"),
|
|
35
35
|
persistToAgent: import_zod_openapi.z.boolean().optional().describe("If true, saves the server to agent configuration file")
|
|
36
36
|
}).strict().describe("Request body for updating an MCP server");
|
|
37
|
-
const ExecuteToolBodySchema =
|
|
37
|
+
const ExecuteToolBodySchema = import_responses.JsonObjectSchema.describe(
|
|
38
38
|
"Tool execution parameters as JSON object. The specific fields depend on the tool being executed and are defined by the tool's inputSchema."
|
|
39
39
|
);
|
|
40
40
|
const ServerStatusResponseSchema = import_zod_openapi.z.object({
|
|
@@ -49,23 +49,14 @@ const ServerInfoSchema = import_zod_openapi.z.object({
|
|
|
49
49
|
const ServersListResponseSchema = import_zod_openapi.z.object({
|
|
50
50
|
servers: import_zod_openapi.z.array(ServerInfoSchema).describe("Array of server information")
|
|
51
51
|
}).strict().describe("List of MCP servers");
|
|
52
|
-
const JsonSchemaProperty = import_zod_openapi.z.object({
|
|
53
|
-
type: import_zod_openapi.z.enum(["string", "number", "integer", "boolean", "object", "array"]).optional().describe("Property type"),
|
|
54
|
-
description: import_zod_openapi.z.string().optional().describe("Property description"),
|
|
55
|
-
enum: import_zod_openapi.z.array(import_zod_openapi.z.union([import_zod_openapi.z.string(), import_zod_openapi.z.number(), import_zod_openapi.z.boolean()])).optional().describe("Enum values"),
|
|
56
|
-
default: import_zod_openapi.z.any().optional().describe("Default value")
|
|
57
|
-
}).passthrough().describe("JSON Schema property definition");
|
|
58
|
-
const ToolInputSchema = import_zod_openapi.z.object({
|
|
59
|
-
type: import_zod_openapi.z.literal("object").optional().describe('Schema type, always "object" when present'),
|
|
60
|
-
properties: import_zod_openapi.z.record(JsonSchemaProperty).optional().describe("Property definitions"),
|
|
61
|
-
required: import_zod_openapi.z.array(import_zod_openapi.z.string()).optional().describe("Required property names")
|
|
62
|
-
}).passthrough().describe("JSON Schema for tool input parameters");
|
|
63
52
|
const ToolInfoSchema = import_zod_openapi.z.object({
|
|
64
53
|
id: import_zod_openapi.z.string().describe("Tool identifier"),
|
|
65
54
|
name: import_zod_openapi.z.string().describe("Tool name"),
|
|
66
55
|
description: import_zod_openapi.z.string().describe("Tool description"),
|
|
67
|
-
inputSchema: ToolInputSchema.optional().describe("JSON Schema for tool input parameters"),
|
|
68
|
-
_meta:
|
|
56
|
+
inputSchema: import_responses.ToolInputSchema.optional().describe("JSON Schema for tool input parameters"),
|
|
57
|
+
_meta: import_responses.JsonObjectSchema.optional().describe(
|
|
58
|
+
"Optional tool metadata (e.g., MCP Apps UI resource info)"
|
|
59
|
+
)
|
|
69
60
|
}).strict().describe("Tool information");
|
|
70
61
|
const ToolsListResponseSchema = import_zod_openapi.z.object({
|
|
71
62
|
tools: import_zod_openapi.z.array(ToolInfoSchema).describe("Array of available tools")
|
|
@@ -80,198 +71,234 @@ const RestartResponseSchema = import_zod_openapi.z.object({
|
|
|
80
71
|
}).strict().describe("Server restart response");
|
|
81
72
|
const ToolExecutionResponseSchema = import_zod_openapi.z.object({
|
|
82
73
|
success: import_zod_openapi.z.boolean().describe("Whether tool execution succeeded"),
|
|
83
|
-
data:
|
|
74
|
+
data: import_responses.JsonValueSchema.optional().describe("Tool execution result data"),
|
|
84
75
|
error: import_zod_openapi.z.string().optional().describe("Error message if execution failed")
|
|
85
76
|
}).strict().describe("Tool execution response");
|
|
86
77
|
const ServerConfigResponseSchema = import_zod_openapi.z.object({
|
|
87
78
|
name: import_zod_openapi.z.string().describe("Server name"),
|
|
88
79
|
config: import_core.McpServerConfigSchema.describe("Server configuration")
|
|
89
80
|
}).strict().describe("MCP server configuration response");
|
|
81
|
+
const ServerResourceSchema = import_zod_openapi.z.object({
|
|
82
|
+
uri: import_zod_openapi.z.string().describe("Resolved resource URI for this server"),
|
|
83
|
+
name: import_zod_openapi.z.string().describe("Resource display name"),
|
|
84
|
+
originalUri: import_zod_openapi.z.string().describe("Original MCP resource URI"),
|
|
85
|
+
serverName: import_zod_openapi.z.string().describe("Owning MCP server name")
|
|
86
|
+
}).strict().describe("Resource exposed by a specific MCP server");
|
|
90
87
|
const ResourcesListResponseSchema = import_zod_openapi.z.object({
|
|
91
88
|
success: import_zod_openapi.z.boolean().describe("Success indicator"),
|
|
92
|
-
resources: import_zod_openapi.z.array(
|
|
89
|
+
resources: import_zod_openapi.z.array(ServerResourceSchema).describe("Array of available resources")
|
|
93
90
|
}).strict().describe("List of resources from MCP server");
|
|
94
91
|
const ResourceContentSchema = import_zod_openapi.z.object({
|
|
95
|
-
content:
|
|
92
|
+
content: import_responses.JsonValueSchema.describe("Resource content data")
|
|
96
93
|
}).strict().describe("Resource content wrapper");
|
|
97
94
|
const ResourceContentResponseSchema = import_zod_openapi.z.object({
|
|
98
95
|
success: import_zod_openapi.z.boolean().describe("Success indicator"),
|
|
99
96
|
data: ResourceContentSchema.describe("Resource content")
|
|
100
97
|
}).strict().describe("Resource content response");
|
|
101
|
-
function
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
98
|
+
function mountMcpSubrouter(app, router) {
|
|
99
|
+
app.route("/", router);
|
|
100
|
+
}
|
|
101
|
+
const addServerRoute = (0, import_zod_openapi.createRoute)({
|
|
102
|
+
method: "post",
|
|
103
|
+
path: "/mcp/servers",
|
|
104
|
+
summary: "Add MCP Server",
|
|
105
|
+
description: "Connects a new MCP server dynamically",
|
|
106
|
+
tags: ["mcp"],
|
|
107
|
+
request: { body: { content: { "application/json": { schema: McpServerRequestSchema } } } },
|
|
108
|
+
responses: {
|
|
109
|
+
200: {
|
|
110
|
+
description: "Server connected",
|
|
111
|
+
content: { "application/json": { schema: ServerStatusResponseSchema } }
|
|
112
|
+
},
|
|
113
|
+
400: import_responses.BadRequestErrorResponse,
|
|
114
|
+
500: import_responses.InternalErrorResponse
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
const listServersRoute = (0, import_zod_openapi.createRoute)({
|
|
118
|
+
method: "get",
|
|
119
|
+
path: "/mcp/servers",
|
|
120
|
+
summary: "List MCP Servers",
|
|
121
|
+
description: "Gets a list of all connected and failed MCP servers",
|
|
122
|
+
tags: ["mcp"],
|
|
123
|
+
responses: {
|
|
124
|
+
200: {
|
|
125
|
+
description: "Servers list",
|
|
126
|
+
content: { "application/json": { schema: ServersListResponseSchema } }
|
|
127
|
+
},
|
|
128
|
+
500: import_responses.InternalErrorResponse
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
const getServerConfigRoute = (0, import_zod_openapi.createRoute)({
|
|
132
|
+
method: "get",
|
|
133
|
+
path: "/mcp/servers/{serverId}/config",
|
|
134
|
+
summary: "Get MCP Server Config",
|
|
135
|
+
description: "Retrieves the configuration for a specific MCP server",
|
|
136
|
+
tags: ["mcp"],
|
|
137
|
+
request: {
|
|
138
|
+
params: import_zod_openapi.z.object({ serverId: import_zod_openapi.z.string().describe("The ID of the MCP server") })
|
|
139
|
+
},
|
|
140
|
+
responses: {
|
|
141
|
+
200: {
|
|
142
|
+
description: "Server configuration",
|
|
143
|
+
content: { "application/json": { schema: ServerConfigResponseSchema } }
|
|
138
144
|
},
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
content: { "application/json": { schema: ServerConfigResponseSchema } }
|
|
143
|
-
},
|
|
144
|
-
404: { description: "Not found" }
|
|
145
|
+
404: {
|
|
146
|
+
description: "Not found",
|
|
147
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
145
148
|
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
const updateServerRoute = (0, import_zod_openapi.createRoute)({
|
|
152
|
+
method: "put",
|
|
153
|
+
path: "/mcp/servers/{serverId}",
|
|
154
|
+
summary: "Update MCP Server",
|
|
155
|
+
description: "Updates configuration for an existing MCP server",
|
|
156
|
+
tags: ["mcp"],
|
|
157
|
+
request: {
|
|
158
|
+
params: import_zod_openapi.z.object({ serverId: import_zod_openapi.z.string().describe("The ID of the MCP server") }),
|
|
159
|
+
body: { content: { "application/json": { schema: McpServerUpdateSchema } } }
|
|
160
|
+
},
|
|
161
|
+
responses: {
|
|
162
|
+
200: {
|
|
163
|
+
description: "Server updated",
|
|
164
|
+
content: { "application/json": { schema: ServerStatusResponseSchema } }
|
|
156
165
|
},
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
content: { "application/json": { schema: ServerStatusResponseSchema } }
|
|
161
|
-
},
|
|
162
|
-
404: { description: "Not found" }
|
|
166
|
+
404: {
|
|
167
|
+
description: "Not found",
|
|
168
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
163
169
|
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const toolsRoute = (0, import_zod_openapi.createRoute)({
|
|
173
|
+
method: "get",
|
|
174
|
+
path: "/mcp/servers/{serverId}/tools",
|
|
175
|
+
summary: "List Server Tools",
|
|
176
|
+
description: "Retrieves the list of tools available on a specific MCP server",
|
|
177
|
+
tags: ["mcp"],
|
|
178
|
+
request: {
|
|
179
|
+
params: import_zod_openapi.z.object({ serverId: import_zod_openapi.z.string().describe("The ID of the MCP server") })
|
|
180
|
+
},
|
|
181
|
+
responses: {
|
|
182
|
+
200: {
|
|
183
|
+
description: "Tools list",
|
|
184
|
+
content: { "application/json": { schema: ToolsListResponseSchema } }
|
|
173
185
|
},
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
content: { "application/json": { schema: ToolsListResponseSchema } }
|
|
178
|
-
},
|
|
179
|
-
404: { description: "Not found" }
|
|
186
|
+
404: {
|
|
187
|
+
description: "Not found",
|
|
188
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
180
189
|
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
const deleteServerRoute = (0, import_zod_openapi.createRoute)({
|
|
193
|
+
method: "delete",
|
|
194
|
+
path: "/mcp/servers/{serverId}",
|
|
195
|
+
summary: "Remove MCP Server",
|
|
196
|
+
description: "Disconnects and removes an MCP server",
|
|
197
|
+
tags: ["mcp"],
|
|
198
|
+
request: {
|
|
199
|
+
params: import_zod_openapi.z.object({ serverId: import_zod_openapi.z.string().describe("The ID of the MCP server") })
|
|
200
|
+
},
|
|
201
|
+
responses: {
|
|
202
|
+
200: {
|
|
203
|
+
description: "Disconnected",
|
|
204
|
+
content: { "application/json": { schema: DisconnectResponseSchema } }
|
|
190
205
|
},
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
content: { "application/json": { schema: DisconnectResponseSchema } }
|
|
195
|
-
},
|
|
196
|
-
404: { description: "Not found" }
|
|
206
|
+
404: {
|
|
207
|
+
description: "Not found",
|
|
208
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
197
209
|
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
const restartServerRoute = (0, import_zod_openapi.createRoute)({
|
|
213
|
+
method: "post",
|
|
214
|
+
path: "/mcp/servers/{serverId}/restart",
|
|
215
|
+
summary: "Restart MCP Server",
|
|
216
|
+
description: "Restarts a connected MCP server",
|
|
217
|
+
tags: ["mcp"],
|
|
218
|
+
request: {
|
|
219
|
+
params: import_zod_openapi.z.object({ serverId: import_zod_openapi.z.string().describe("The ID of the MCP server") })
|
|
220
|
+
},
|
|
221
|
+
responses: {
|
|
222
|
+
200: {
|
|
223
|
+
description: "Server restarted",
|
|
224
|
+
content: { "application/json": { schema: RestartResponseSchema } }
|
|
207
225
|
},
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
content: { "application/json": { schema: RestartResponseSchema } }
|
|
212
|
-
},
|
|
213
|
-
404: { description: "Not found" }
|
|
226
|
+
404: {
|
|
227
|
+
description: "Not found",
|
|
228
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
214
229
|
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
const execToolRoute = (0, import_zod_openapi.createRoute)({
|
|
233
|
+
method: "post",
|
|
234
|
+
path: "/mcp/servers/{serverId}/tools/{toolName}/execute",
|
|
235
|
+
summary: "Execute MCP Tool",
|
|
236
|
+
description: "Executes a tool on an MCP server directly",
|
|
237
|
+
tags: ["mcp"],
|
|
238
|
+
request: {
|
|
239
|
+
params: import_zod_openapi.z.object({
|
|
240
|
+
serverId: import_zod_openapi.z.string().describe("The ID of the MCP server"),
|
|
241
|
+
toolName: import_zod_openapi.z.string().describe("The name of the tool to execute")
|
|
242
|
+
}),
|
|
243
|
+
body: { content: { "application/json": { schema: ExecuteToolBodySchema } } }
|
|
244
|
+
},
|
|
245
|
+
responses: {
|
|
246
|
+
200: {
|
|
247
|
+
description: "Tool executed",
|
|
248
|
+
content: { "application/json": { schema: ToolExecutionResponseSchema } }
|
|
228
249
|
},
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
content: { "application/json": { schema: ToolExecutionResponseSchema } }
|
|
233
|
-
},
|
|
234
|
-
404: { description: "Not found" }
|
|
250
|
+
404: {
|
|
251
|
+
description: "Not found",
|
|
252
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
235
253
|
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
const listResourcesRoute = (0, import_zod_openapi.createRoute)({
|
|
257
|
+
method: "get",
|
|
258
|
+
path: "/mcp/servers/{serverId}/resources",
|
|
259
|
+
summary: "List Server Resources",
|
|
260
|
+
description: "Retrieves all resources available from a specific MCP server",
|
|
261
|
+
tags: ["mcp"],
|
|
262
|
+
request: {
|
|
263
|
+
params: import_zod_openapi.z.object({ serverId: import_zod_openapi.z.string().describe("The ID of the MCP server") })
|
|
264
|
+
},
|
|
265
|
+
responses: {
|
|
266
|
+
200: {
|
|
267
|
+
description: "Server resources",
|
|
268
|
+
content: { "application/json": { schema: ResourcesListResponseSchema } }
|
|
245
269
|
},
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
content: { "application/json": { schema: ResourcesListResponseSchema } }
|
|
250
|
-
},
|
|
251
|
-
404: { description: "Not found" }
|
|
270
|
+
404: {
|
|
271
|
+
description: "Not found",
|
|
272
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
252
273
|
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
const getResourceContentRoute = (0, import_zod_openapi.createRoute)({
|
|
277
|
+
method: "get",
|
|
278
|
+
path: "/mcp/servers/{serverId}/resources/{resourceId}/content",
|
|
279
|
+
summary: "Read Server Resource Content",
|
|
280
|
+
description: "Reads content from a specific resource on an MCP server. This endpoint automatically constructs the qualified URI format (mcp:serverId:resourceId)",
|
|
281
|
+
tags: ["mcp"],
|
|
282
|
+
request: {
|
|
283
|
+
params: import_zod_openapi.z.object({
|
|
284
|
+
serverId: import_zod_openapi.z.string().describe("The ID of the MCP server"),
|
|
285
|
+
resourceId: import_zod_openapi.z.string().min(1, "Resource ID is required").transform((encoded) => decodeURIComponent(encoded)).describe("The URI-encoded resource identifier on that server")
|
|
286
|
+
})
|
|
287
|
+
},
|
|
288
|
+
responses: {
|
|
289
|
+
200: {
|
|
290
|
+
description: "Resource content",
|
|
291
|
+
content: { "application/json": { schema: ResourceContentResponseSchema } }
|
|
265
292
|
},
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
content: { "application/json": { schema: ResourceContentResponseSchema } }
|
|
270
|
-
},
|
|
271
|
-
404: { description: "Not found" }
|
|
293
|
+
404: {
|
|
294
|
+
description: "Not found",
|
|
295
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
272
296
|
}
|
|
273
|
-
}
|
|
274
|
-
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
function createMcpRouter(getAgent, getAgentConfigPath) {
|
|
300
|
+
const app = new import_zod_openapi.OpenAPIHono();
|
|
301
|
+
const serverRegistrationRouter = new import_zod_openapi.OpenAPIHono().openapi(addServerRoute, async (ctx) => {
|
|
275
302
|
const agent = await getAgent(ctx);
|
|
276
303
|
const { name, config, persistToAgent } = ctx.req.valid("json");
|
|
277
304
|
await agent.addMcpServer(name, config);
|
|
@@ -317,22 +344,23 @@ function createMcpRouter(getAgent, getAgentConfigPath) {
|
|
|
317
344
|
for (const name of Object.keys(failedConnections)) {
|
|
318
345
|
servers.push({ id: name, name, status: "error" });
|
|
319
346
|
}
|
|
320
|
-
return ctx.json({ servers });
|
|
347
|
+
return ctx.json({ servers }, 200);
|
|
321
348
|
}).openapi(getServerConfigRoute, async (ctx) => {
|
|
322
349
|
const agent = await getAgent(ctx);
|
|
323
350
|
const { serverId } = ctx.req.valid("param");
|
|
324
351
|
const config = agent.getMcpServerConfig(serverId);
|
|
325
352
|
if (!config) {
|
|
326
|
-
|
|
353
|
+
throw import_core.MCPError.serverNotFound(serverId);
|
|
327
354
|
}
|
|
328
|
-
return ctx.json({ name: serverId, config }, 200);
|
|
329
|
-
})
|
|
355
|
+
return ctx.json({ name: serverId, config: import_core.McpServerConfigSchema.parse(config) }, 200);
|
|
356
|
+
});
|
|
357
|
+
const serverUpdateRouter = new import_zod_openapi.OpenAPIHono().openapi(updateServerRoute, async (ctx) => {
|
|
330
358
|
const agent = await getAgent(ctx);
|
|
331
359
|
const { serverId } = ctx.req.valid("param");
|
|
332
360
|
const { config, persistToAgent } = ctx.req.valid("json");
|
|
333
361
|
const existingConfig = agent.getMcpServerConfig(serverId);
|
|
334
362
|
if (!existingConfig) {
|
|
335
|
-
|
|
363
|
+
throw import_core.MCPError.serverNotFound(serverId);
|
|
336
364
|
}
|
|
337
365
|
await agent.updateMcpServer(serverId, config);
|
|
338
366
|
if (persistToAgent === true) {
|
|
@@ -352,89 +380,122 @@ function createMcpRouter(getAgent, getAgentConfigPath) {
|
|
|
352
380
|
import_core.logger.info(`Saved server '${serverId}' to agent configuration file`);
|
|
353
381
|
} catch (saveError) {
|
|
354
382
|
const errorMessage = saveError instanceof Error ? saveError.message : String(saveError);
|
|
355
|
-
import_core.logger.warn(
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
);
|
|
383
|
+
import_core.logger.warn(`Failed to persist MCP server '${serverId}' update: ${errorMessage}`, {
|
|
384
|
+
error: saveError
|
|
385
|
+
});
|
|
359
386
|
}
|
|
360
387
|
}
|
|
361
388
|
const status = config.enabled === false ? "registered" : "connected";
|
|
362
389
|
return ctx.json({ status, name: serverId }, 200);
|
|
363
|
-
})
|
|
390
|
+
});
|
|
391
|
+
const serverToolsRouter = new import_zod_openapi.OpenAPIHono().openapi(toolsRoute, async (ctx) => {
|
|
364
392
|
const agent = await getAgent(ctx);
|
|
365
393
|
const { serverId } = ctx.req.valid("param");
|
|
366
394
|
const client = agent.getMcpClients().get(serverId);
|
|
367
395
|
if (!client) {
|
|
368
|
-
|
|
396
|
+
throw import_core.MCPError.serverNotFound(serverId);
|
|
369
397
|
}
|
|
370
398
|
const toolsMap = await client.getTools();
|
|
371
399
|
const tools = Object.entries(toolsMap).map(([toolName, toolDef]) => ({
|
|
372
400
|
id: toolName,
|
|
373
401
|
name: toolName,
|
|
374
402
|
description: toolDef.description || "",
|
|
375
|
-
inputSchema: toolDef.parameters,
|
|
376
|
-
_meta: toolDef._meta
|
|
403
|
+
inputSchema: toolDef.parameters === void 0 ? void 0 : import_responses.ToolInputSchema.parse(toolDef.parameters),
|
|
404
|
+
_meta: toolDef._meta === void 0 ? void 0 : import_responses.JsonObjectSchema.parse(toolDef._meta)
|
|
377
405
|
}));
|
|
378
|
-
|
|
379
|
-
|
|
406
|
+
const response = { tools };
|
|
407
|
+
return ctx.json(response, 200);
|
|
408
|
+
});
|
|
409
|
+
const deleteServerRouter = new import_zod_openapi.OpenAPIHono().openapi(deleteServerRoute, async (ctx) => {
|
|
380
410
|
const agent = await getAgent(ctx);
|
|
381
411
|
const { serverId } = ctx.req.valid("param");
|
|
382
412
|
const clientExists = agent.getMcpClients().has(serverId) || agent.getMcpFailedConnections()[serverId];
|
|
383
413
|
if (!clientExists) {
|
|
384
|
-
|
|
414
|
+
throw import_core.MCPError.serverNotFound(serverId);
|
|
385
415
|
}
|
|
386
416
|
await agent.removeMcpServer(serverId);
|
|
387
|
-
|
|
388
|
-
|
|
417
|
+
const response = { status: "disconnected", id: serverId };
|
|
418
|
+
return ctx.json(response, 200);
|
|
419
|
+
});
|
|
420
|
+
const restartServerRouter = new import_zod_openapi.OpenAPIHono().openapi(restartServerRoute, async (ctx) => {
|
|
389
421
|
const agent = await getAgent(ctx);
|
|
390
422
|
const { serverId } = ctx.req.valid("param");
|
|
391
423
|
import_core.logger.info(`Received request to POST /api/mcp/servers/${serverId}/restart`);
|
|
392
424
|
const clientExists = agent.getMcpClients().has(serverId);
|
|
393
425
|
if (!clientExists) {
|
|
394
426
|
import_core.logger.warn(`Attempted to restart non-existent server: ${serverId}`);
|
|
395
|
-
|
|
427
|
+
throw import_core.MCPError.serverNotFound(serverId);
|
|
396
428
|
}
|
|
397
429
|
await agent.restartMcpServer(serverId);
|
|
398
|
-
|
|
399
|
-
|
|
430
|
+
const response = { status: "restarted", id: serverId };
|
|
431
|
+
return ctx.json(response, 200);
|
|
432
|
+
});
|
|
433
|
+
const execToolRouter = new import_zod_openapi.OpenAPIHono().openapi(execToolRoute, async (ctx) => {
|
|
400
434
|
const agent = await getAgent(ctx);
|
|
401
435
|
const { serverId, toolName } = ctx.req.valid("param");
|
|
402
436
|
const body = ctx.req.valid("json");
|
|
403
437
|
const client = agent.getMcpClients().get(serverId);
|
|
404
438
|
if (!client) {
|
|
405
|
-
|
|
439
|
+
throw import_core.MCPError.serverNotFound(serverId);
|
|
406
440
|
}
|
|
407
441
|
try {
|
|
408
442
|
const rawResult = await client.callTool(toolName, body);
|
|
409
|
-
|
|
443
|
+
const response = {
|
|
444
|
+
success: true,
|
|
445
|
+
data: import_responses.JsonValueSchema.parse(rawResult)
|
|
446
|
+
};
|
|
447
|
+
return ctx.json(response, 200);
|
|
410
448
|
} catch (error) {
|
|
411
449
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
412
450
|
import_core.logger.error(
|
|
413
451
|
`Tool execution failed for '${toolName}' on server '${serverId}': ${errorMessage}`,
|
|
414
452
|
{ error }
|
|
415
453
|
);
|
|
416
|
-
|
|
454
|
+
const response = {
|
|
455
|
+
success: false,
|
|
456
|
+
error: errorMessage
|
|
457
|
+
};
|
|
458
|
+
return ctx.json(response, 200);
|
|
417
459
|
}
|
|
418
|
-
})
|
|
460
|
+
});
|
|
461
|
+
const listResourcesRouter = new import_zod_openapi.OpenAPIHono().openapi(listResourcesRoute, async (ctx) => {
|
|
419
462
|
const agent = await getAgent(ctx);
|
|
420
463
|
const { serverId } = ctx.req.valid("param");
|
|
421
464
|
const client = agent.getMcpClients().get(serverId);
|
|
422
465
|
if (!client) {
|
|
423
|
-
|
|
466
|
+
throw import_core.MCPError.serverNotFound(serverId);
|
|
424
467
|
}
|
|
425
468
|
const resources = await agent.listResourcesForServer(serverId);
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
const agent = await getAgent(ctx);
|
|
429
|
-
const { serverId, resourceId } = ctx.req.valid("param");
|
|
430
|
-
const client = agent.getMcpClients().get(serverId);
|
|
431
|
-
if (!client) {
|
|
432
|
-
return ctx.json({ error: `Server '${serverId}' not found` }, 404);
|
|
433
|
-
}
|
|
434
|
-
const qualifiedUri = `mcp:${serverId}:${resourceId}`;
|
|
435
|
-
const content = await agent.readResource(qualifiedUri);
|
|
436
|
-
return ctx.json({ success: true, data: { content } });
|
|
469
|
+
const response = { success: true, resources };
|
|
470
|
+
return ctx.json(response, 200);
|
|
437
471
|
});
|
|
472
|
+
const getResourceContentRouter = new import_zod_openapi.OpenAPIHono().openapi(
|
|
473
|
+
getResourceContentRoute,
|
|
474
|
+
async (ctx) => {
|
|
475
|
+
const agent = await getAgent(ctx);
|
|
476
|
+
const { serverId, resourceId } = ctx.req.valid("param");
|
|
477
|
+
const client = agent.getMcpClients().get(serverId);
|
|
478
|
+
if (!client) {
|
|
479
|
+
throw import_core.MCPError.serverNotFound(serverId);
|
|
480
|
+
}
|
|
481
|
+
const qualifiedUri = `mcp:${serverId}:${resourceId}`;
|
|
482
|
+
const content = await agent.readResource(qualifiedUri);
|
|
483
|
+
const response = {
|
|
484
|
+
success: true,
|
|
485
|
+
data: { content: import_responses.JsonValueSchema.parse(content) }
|
|
486
|
+
};
|
|
487
|
+
return ctx.json(response, 200);
|
|
488
|
+
}
|
|
489
|
+
);
|
|
490
|
+
mountMcpSubrouter(app, serverRegistrationRouter);
|
|
491
|
+
mountMcpSubrouter(app, serverUpdateRouter);
|
|
492
|
+
mountMcpSubrouter(app, serverToolsRouter);
|
|
493
|
+
mountMcpSubrouter(app, deleteServerRouter);
|
|
494
|
+
mountMcpSubrouter(app, restartServerRouter);
|
|
495
|
+
mountMcpSubrouter(app, execToolRouter);
|
|
496
|
+
mountMcpSubrouter(app, listResourcesRouter);
|
|
497
|
+
mountMcpSubrouter(app, getResourceContentRouter);
|
|
498
|
+
return app;
|
|
438
499
|
}
|
|
439
500
|
// Annotate the CommonJS export names for ESM import in node:
|
|
440
501
|
0 && (module.exports = {
|