@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.
Files changed (111) hide show
  1. package/dist/a2a/jsonrpc/methods.cjs +1 -1
  2. package/dist/a2a/jsonrpc/methods.d.ts +14 -4
  3. package/dist/a2a/jsonrpc/methods.d.ts.map +1 -1
  4. package/dist/a2a/jsonrpc/methods.js +1 -1
  5. package/dist/hono/index.cjs +39 -8
  6. package/dist/hono/index.d.ts +43 -4503
  7. package/dist/hono/index.d.ts.map +1 -1
  8. package/dist/hono/index.js +42 -9
  9. package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
  10. package/dist/hono/routes/a2a-tasks.cjs +173 -34
  11. package/dist/hono/routes/a2a-tasks.d.ts +1 -498
  12. package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
  13. package/dist/hono/routes/a2a-tasks.js +177 -34
  14. package/dist/hono/routes/a2a.d.ts.map +1 -1
  15. package/dist/hono/routes/agents.cjs +410 -329
  16. package/dist/hono/routes/agents.d.ts +16048 -73
  17. package/dist/hono/routes/agents.d.ts.map +1 -1
  18. package/dist/hono/routes/agents.js +418 -330
  19. package/dist/hono/routes/approvals.cjs +103 -78
  20. package/dist/hono/routes/approvals.d.ts +2090 -112
  21. package/dist/hono/routes/approvals.d.ts.map +1 -1
  22. package/dist/hono/routes/approvals.js +108 -78
  23. package/dist/hono/routes/dexto-auth.cjs +40 -33
  24. package/dist/hono/routes/dexto-auth.d.ts +401 -2
  25. package/dist/hono/routes/dexto-auth.d.ts.map +1 -1
  26. package/dist/hono/routes/dexto-auth.js +40 -33
  27. package/dist/hono/routes/discovery.cjs +16 -14
  28. package/dist/hono/routes/discovery.d.ts +586 -1
  29. package/dist/hono/routes/discovery.d.ts.map +1 -1
  30. package/dist/hono/routes/discovery.js +16 -14
  31. package/dist/hono/routes/greeting.cjs +26 -22
  32. package/dist/hono/routes/greeting.d.ts +787 -3
  33. package/dist/hono/routes/greeting.d.ts.map +1 -1
  34. package/dist/hono/routes/greeting.js +26 -22
  35. package/dist/hono/routes/health.d.ts +1 -1
  36. package/dist/hono/routes/key.cjs +60 -52
  37. package/dist/hono/routes/key.d.ts +1597 -1
  38. package/dist/hono/routes/key.d.ts.map +1 -1
  39. package/dist/hono/routes/key.js +60 -52
  40. package/dist/hono/routes/llm.cjs +381 -348
  41. package/dist/hono/routes/llm.d.ts +12137 -87
  42. package/dist/hono/routes/llm.d.ts.map +1 -1
  43. package/dist/hono/routes/llm.js +385 -348
  44. package/dist/hono/routes/mcp.cjs +273 -212
  45. package/dist/hono/routes/mcp.d.ts +6605 -316
  46. package/dist/hono/routes/mcp.d.ts.map +1 -1
  47. package/dist/hono/routes/mcp.js +287 -213
  48. package/dist/hono/routes/memory.cjs +102 -89
  49. package/dist/hono/routes/memory.d.ts +5368 -4
  50. package/dist/hono/routes/memory.d.ts.map +1 -1
  51. package/dist/hono/routes/memory.js +108 -90
  52. package/dist/hono/routes/messages.cjs +171 -164
  53. package/dist/hono/routes/messages.d.ts +3899 -10
  54. package/dist/hono/routes/messages.d.ts.map +1 -1
  55. package/dist/hono/routes/messages.js +181 -165
  56. package/dist/hono/routes/models.cjs +106 -64
  57. package/dist/hono/routes/models.d.ts +2874 -1
  58. package/dist/hono/routes/models.d.ts.map +1 -1
  59. package/dist/hono/routes/models.js +108 -64
  60. package/dist/hono/routes/openrouter.cjs +79 -65
  61. package/dist/hono/routes/openrouter.d.ts +854 -1
  62. package/dist/hono/routes/openrouter.d.ts.map +1 -1
  63. package/dist/hono/routes/openrouter.js +79 -65
  64. package/dist/hono/routes/prompts.cjs +137 -104
  65. package/dist/hono/routes/prompts.d.ts +2820 -12
  66. package/dist/hono/routes/prompts.d.ts.map +1 -1
  67. package/dist/hono/routes/prompts.js +144 -105
  68. package/dist/hono/routes/queue.cjs +158 -132
  69. package/dist/hono/routes/queue.d.ts +5148 -13
  70. package/dist/hono/routes/queue.d.ts.map +1 -1
  71. package/dist/hono/routes/queue.js +168 -133
  72. package/dist/hono/routes/resources.cjs +65 -46
  73. package/dist/hono/routes/resources.d.ts +1983 -5
  74. package/dist/hono/routes/resources.d.ts.map +1 -1
  75. package/dist/hono/routes/resources.js +72 -47
  76. package/dist/hono/routes/schedules.cjs +233 -226
  77. package/dist/hono/routes/schedules.d.ts +4202 -26
  78. package/dist/hono/routes/schedules.d.ts.map +1 -1
  79. package/dist/hono/routes/schedules.js +233 -226
  80. package/dist/hono/routes/search.cjs +34 -30
  81. package/dist/hono/routes/search.d.ts +2837 -14
  82. package/dist/hono/routes/search.d.ts.map +1 -1
  83. package/dist/hono/routes/search.js +40 -31
  84. package/dist/hono/routes/sessions.cjs +404 -392
  85. package/dist/hono/routes/sessions.d.ts +16585 -30
  86. package/dist/hono/routes/sessions.d.ts.map +1 -1
  87. package/dist/hono/routes/sessions.js +408 -393
  88. package/dist/hono/routes/static.d.ts.map +1 -1
  89. package/dist/hono/routes/system-prompt.cjs +57 -61
  90. package/dist/hono/routes/system-prompt.d.ts +1228 -2
  91. package/dist/hono/routes/system-prompt.d.ts.map +1 -1
  92. package/dist/hono/routes/system-prompt.js +58 -62
  93. package/dist/hono/routes/tools.cjs +29 -34
  94. package/dist/hono/routes/tools.d.ts +1756 -7
  95. package/dist/hono/routes/tools.d.ts.map +1 -1
  96. package/dist/hono/routes/tools.js +33 -33
  97. package/dist/hono/routes/webhooks.cjs +159 -132
  98. package/dist/hono/routes/webhooks.d.ts +2504 -14
  99. package/dist/hono/routes/webhooks.d.ts.map +1 -1
  100. package/dist/hono/routes/webhooks.js +163 -132
  101. package/dist/hono/routes/workspaces.cjs +84 -79
  102. package/dist/hono/routes/workspaces.d.ts +2093 -2
  103. package/dist/hono/routes/workspaces.d.ts.map +1 -1
  104. package/dist/hono/routes/workspaces.js +89 -80
  105. package/dist/hono/schemas/responses.cjs +492 -235
  106. package/dist/hono/schemas/responses.d.ts +1461 -146
  107. package/dist/hono/schemas/responses.d.ts.map +1 -1
  108. package/dist/hono/schemas/responses.js +247 -9
  109. package/dist/hono/types.d.ts +11 -0
  110. package/dist/hono/types.d.ts.map +1 -1
  111. package/package.json +7 -7
@@ -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 = import_zod_openapi.z.record(import_zod_openapi.z.unknown()).describe(
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: import_zod_openapi.z.record(import_zod_openapi.z.unknown()).optional().describe("Optional tool metadata (e.g., MCP Apps UI resource info)")
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: import_zod_openapi.z.any().optional().describe("Tool execution result 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(import_responses.ResourceSchema).describe("Array of available resources")
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: import_zod_openapi.z.any().describe("Resource content data")
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 createMcpRouter(getAgent, getAgentConfigPath) {
102
- const app = new import_zod_openapi.OpenAPIHono();
103
- const addServerRoute = (0, import_zod_openapi.createRoute)({
104
- method: "post",
105
- path: "/mcp/servers",
106
- summary: "Add MCP Server",
107
- description: "Connects a new MCP server dynamically",
108
- tags: ["mcp"],
109
- request: { body: { content: { "application/json": { schema: McpServerRequestSchema } } } },
110
- responses: {
111
- 200: {
112
- description: "Server connected",
113
- content: { "application/json": { schema: ServerStatusResponseSchema } }
114
- }
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
- }
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") })
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
- responses: {
140
- 200: {
141
- description: "Server configuration",
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
- 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 } } }
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
- responses: {
158
- 200: {
159
- description: "Server updated",
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
- const toolsRoute = (0, import_zod_openapi.createRoute)({
166
- method: "get",
167
- path: "/mcp/servers/{serverId}/tools",
168
- summary: "List Server Tools",
169
- description: "Retrieves the list of tools available on a specific MCP server",
170
- tags: ["mcp"],
171
- request: {
172
- params: import_zod_openapi.z.object({ serverId: import_zod_openapi.z.string().describe("The ID of the MCP server") })
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
- responses: {
175
- 200: {
176
- description: "Tools list",
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
- const deleteServerRoute = (0, import_zod_openapi.createRoute)({
183
- method: "delete",
184
- path: "/mcp/servers/{serverId}",
185
- summary: "Remove MCP Server",
186
- description: "Disconnects and removes an MCP server",
187
- tags: ["mcp"],
188
- request: {
189
- params: import_zod_openapi.z.object({ serverId: import_zod_openapi.z.string().describe("The ID of the MCP server") })
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
- responses: {
192
- 200: {
193
- description: "Disconnected",
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
- const restartServerRoute = (0, import_zod_openapi.createRoute)({
200
- method: "post",
201
- path: "/mcp/servers/{serverId}/restart",
202
- summary: "Restart MCP Server",
203
- description: "Restarts a connected MCP server",
204
- tags: ["mcp"],
205
- request: {
206
- params: import_zod_openapi.z.object({ serverId: import_zod_openapi.z.string().describe("The ID of the MCP server") })
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
- responses: {
209
- 200: {
210
- description: "Server restarted",
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
- const execToolRoute = (0, import_zod_openapi.createRoute)({
217
- method: "post",
218
- path: "/mcp/servers/{serverId}/tools/{toolName}/execute",
219
- summary: "Execute MCP Tool",
220
- description: "Executes a tool on an MCP server directly",
221
- tags: ["mcp"],
222
- request: {
223
- params: import_zod_openapi.z.object({
224
- serverId: import_zod_openapi.z.string().describe("The ID of the MCP server"),
225
- toolName: import_zod_openapi.z.string().describe("The name of the tool to execute")
226
- }),
227
- body: { content: { "application/json": { schema: ExecuteToolBodySchema } } }
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
- responses: {
230
- 200: {
231
- description: "Tool executed",
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
- const listResourcesRoute = (0, import_zod_openapi.createRoute)({
238
- method: "get",
239
- path: "/mcp/servers/{serverId}/resources",
240
- summary: "List Server Resources",
241
- description: "Retrieves all resources available from a specific MCP server",
242
- tags: ["mcp"],
243
- request: {
244
- params: import_zod_openapi.z.object({ serverId: import_zod_openapi.z.string().describe("The ID of the MCP server") })
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
- responses: {
247
- 200: {
248
- description: "Server resources",
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
- const getResourceContentRoute = (0, import_zod_openapi.createRoute)({
255
- method: "get",
256
- path: "/mcp/servers/{serverId}/resources/{resourceId}/content",
257
- summary: "Read Server Resource Content",
258
- description: "Reads content from a specific resource on an MCP server. This endpoint automatically constructs the qualified URI format (mcp:serverId:resourceId)",
259
- tags: ["mcp"],
260
- request: {
261
- params: import_zod_openapi.z.object({
262
- serverId: import_zod_openapi.z.string().describe("The ID of the MCP server"),
263
- 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")
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
- responses: {
267
- 200: {
268
- description: "Resource content",
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
- return app.openapi(addServerRoute, async (ctx) => {
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
- return ctx.json({ error: `Server '${serverId}' not found.` }, 404);
353
+ throw import_core.MCPError.serverNotFound(serverId);
327
354
  }
328
- return ctx.json({ name: serverId, config }, 200);
329
- }).openapi(updateServerRoute, async (ctx) => {
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
- return ctx.json({ error: `Server '${serverId}' not found.` }, 404);
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
- `Failed to persist MCP server '${serverId}' update: ${errorMessage}`,
357
- { error: saveError }
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
- }).openapi(toolsRoute, async (ctx) => {
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
- return ctx.json({ error: `Server '${serverId}' not found` }, 404);
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
- return ctx.json({ tools });
379
- }).openapi(deleteServerRoute, async (ctx) => {
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
- return ctx.json({ error: `Server '${serverId}' not found.` }, 404);
414
+ throw import_core.MCPError.serverNotFound(serverId);
385
415
  }
386
416
  await agent.removeMcpServer(serverId);
387
- return ctx.json({ status: "disconnected", id: serverId });
388
- }).openapi(restartServerRoute, async (ctx) => {
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
- return ctx.json({ error: `Server '${serverId}' not found.` }, 404);
427
+ throw import_core.MCPError.serverNotFound(serverId);
396
428
  }
397
429
  await agent.restartMcpServer(serverId);
398
- return ctx.json({ status: "restarted", id: serverId });
399
- }).openapi(execToolRoute, async (ctx) => {
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
- return ctx.json({ success: false, error: `Server '${serverId}' not found` }, 404);
439
+ throw import_core.MCPError.serverNotFound(serverId);
406
440
  }
407
441
  try {
408
442
  const rawResult = await client.callTool(toolName, body);
409
- return ctx.json({ success: true, data: rawResult });
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
- return ctx.json({ success: false, error: errorMessage }, 200);
454
+ const response = {
455
+ success: false,
456
+ error: errorMessage
457
+ };
458
+ return ctx.json(response, 200);
417
459
  }
418
- }).openapi(listResourcesRoute, async (ctx) => {
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
- return ctx.json({ error: `Server '${serverId}' not found` }, 404);
466
+ throw import_core.MCPError.serverNotFound(serverId);
424
467
  }
425
468
  const resources = await agent.listResourcesForServer(serverId);
426
- return ctx.json({ success: true, resources });
427
- }).openapi(getResourceContentRoute, async (ctx) => {
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 = {