@dexto/server 1.6.20 → 1.6.22

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 (133) 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/approval/wire-approval-events.cjs +44 -0
  6. package/dist/approval/wire-approval-events.d.ts +4 -0
  7. package/dist/approval/wire-approval-events.d.ts.map +1 -0
  8. package/dist/approval/wire-approval-events.js +20 -0
  9. package/dist/events/session-sse-subscriber.cjs +167 -0
  10. package/dist/events/session-sse-subscriber.d.ts +13 -0
  11. package/dist/events/session-sse-subscriber.d.ts.map +1 -0
  12. package/dist/events/session-sse-subscriber.js +143 -0
  13. package/dist/hono/__tests__/test-fixtures.cjs +8 -0
  14. package/dist/hono/__tests__/test-fixtures.d.ts +1 -0
  15. package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
  16. package/dist/hono/__tests__/test-fixtures.js +8 -0
  17. package/dist/hono/index.cjs +40 -8
  18. package/dist/hono/index.d.ts +45 -4531
  19. package/dist/hono/index.d.ts.map +1 -1
  20. package/dist/hono/index.js +43 -9
  21. package/dist/hono/node/index.cjs +51 -6
  22. package/dist/hono/node/index.d.ts.map +1 -1
  23. package/dist/hono/node/index.js +51 -6
  24. package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
  25. package/dist/hono/routes/a2a-tasks.cjs +158 -32
  26. package/dist/hono/routes/a2a-tasks.d.ts +1 -502
  27. package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
  28. package/dist/hono/routes/a2a-tasks.js +162 -32
  29. package/dist/hono/routes/a2a.d.ts.map +1 -1
  30. package/dist/hono/routes/agents.cjs +410 -329
  31. package/dist/hono/routes/agents.d.ts +16043 -68
  32. package/dist/hono/routes/agents.d.ts.map +1 -1
  33. package/dist/hono/routes/agents.js +418 -330
  34. package/dist/hono/routes/approvals.cjs +102 -88
  35. package/dist/hono/routes/approvals.d.ts +2089 -142
  36. package/dist/hono/routes/approvals.d.ts.map +1 -1
  37. package/dist/hono/routes/approvals.js +108 -89
  38. package/dist/hono/routes/dexto-auth.cjs +40 -33
  39. package/dist/hono/routes/dexto-auth.d.ts +401 -2
  40. package/dist/hono/routes/dexto-auth.d.ts.map +1 -1
  41. package/dist/hono/routes/dexto-auth.js +40 -33
  42. package/dist/hono/routes/discovery.cjs +16 -14
  43. package/dist/hono/routes/discovery.d.ts +586 -1
  44. package/dist/hono/routes/discovery.d.ts.map +1 -1
  45. package/dist/hono/routes/discovery.js +16 -14
  46. package/dist/hono/routes/greeting.cjs +26 -22
  47. package/dist/hono/routes/greeting.d.ts +787 -3
  48. package/dist/hono/routes/greeting.d.ts.map +1 -1
  49. package/dist/hono/routes/greeting.js +26 -22
  50. package/dist/hono/routes/health.d.ts +1 -1
  51. package/dist/hono/routes/key.cjs +60 -52
  52. package/dist/hono/routes/key.d.ts +1597 -1
  53. package/dist/hono/routes/key.d.ts.map +1 -1
  54. package/dist/hono/routes/key.js +60 -52
  55. package/dist/hono/routes/llm.cjs +382 -349
  56. package/dist/hono/routes/llm.d.ts +12148 -98
  57. package/dist/hono/routes/llm.d.ts.map +1 -1
  58. package/dist/hono/routes/llm.js +386 -349
  59. package/dist/hono/routes/mcp.cjs +257 -226
  60. package/dist/hono/routes/mcp.d.ts +6605 -309
  61. package/dist/hono/routes/mcp.d.ts.map +1 -1
  62. package/dist/hono/routes/mcp.js +263 -225
  63. package/dist/hono/routes/memory.cjs +102 -89
  64. package/dist/hono/routes/memory.d.ts +5368 -4
  65. package/dist/hono/routes/memory.d.ts.map +1 -1
  66. package/dist/hono/routes/memory.js +108 -90
  67. package/dist/hono/routes/messages.cjs +189 -191
  68. package/dist/hono/routes/messages.d.ts +3900 -12
  69. package/dist/hono/routes/messages.d.ts.map +1 -1
  70. package/dist/hono/routes/messages.js +192 -191
  71. package/dist/hono/routes/models.cjs +106 -64
  72. package/dist/hono/routes/models.d.ts +2875 -2
  73. package/dist/hono/routes/models.d.ts.map +1 -1
  74. package/dist/hono/routes/models.js +108 -64
  75. package/dist/hono/routes/openrouter.cjs +79 -65
  76. package/dist/hono/routes/openrouter.d.ts +854 -1
  77. package/dist/hono/routes/openrouter.d.ts.map +1 -1
  78. package/dist/hono/routes/openrouter.js +79 -65
  79. package/dist/hono/routes/prompts.cjs +136 -109
  80. package/dist/hono/routes/prompts.d.ts +2818 -10
  81. package/dist/hono/routes/prompts.d.ts.map +1 -1
  82. package/dist/hono/routes/prompts.js +138 -109
  83. package/dist/hono/routes/queue.cjs +133 -120
  84. package/dist/hono/routes/queue.d.ts +5240 -11
  85. package/dist/hono/routes/queue.d.ts.map +1 -1
  86. package/dist/hono/routes/queue.js +136 -120
  87. package/dist/hono/routes/resources.cjs +65 -46
  88. package/dist/hono/routes/resources.d.ts +1983 -5
  89. package/dist/hono/routes/resources.d.ts.map +1 -1
  90. package/dist/hono/routes/resources.js +72 -47
  91. package/dist/hono/routes/schedules.cjs +233 -226
  92. package/dist/hono/routes/schedules.d.ts +4198 -22
  93. package/dist/hono/routes/schedules.d.ts.map +1 -1
  94. package/dist/hono/routes/schedules.js +233 -226
  95. package/dist/hono/routes/search.cjs +34 -30
  96. package/dist/hono/routes/search.d.ts +3094 -17
  97. package/dist/hono/routes/search.d.ts.map +1 -1
  98. package/dist/hono/routes/search.js +40 -31
  99. package/dist/hono/routes/sessions.cjs +491 -393
  100. package/dist/hono/routes/sessions.d.ts +18263 -65
  101. package/dist/hono/routes/sessions.d.ts.map +1 -1
  102. package/dist/hono/routes/sessions.js +497 -395
  103. package/dist/hono/routes/static.d.ts.map +1 -1
  104. package/dist/hono/routes/system-prompt.cjs +57 -61
  105. package/dist/hono/routes/system-prompt.d.ts +1228 -2
  106. package/dist/hono/routes/system-prompt.d.ts.map +1 -1
  107. package/dist/hono/routes/system-prompt.js +58 -62
  108. package/dist/hono/routes/tools.cjs +29 -34
  109. package/dist/hono/routes/tools.d.ts +1755 -6
  110. package/dist/hono/routes/tools.d.ts.map +1 -1
  111. package/dist/hono/routes/tools.js +33 -33
  112. package/dist/hono/routes/webhooks.cjs +115 -123
  113. package/dist/hono/routes/webhooks.d.ts +2501 -11
  114. package/dist/hono/routes/webhooks.d.ts.map +1 -1
  115. package/dist/hono/routes/webhooks.js +120 -124
  116. package/dist/hono/routes/workspaces.cjs +84 -79
  117. package/dist/hono/routes/workspaces.d.ts +2093 -2
  118. package/dist/hono/routes/workspaces.d.ts.map +1 -1
  119. package/dist/hono/routes/workspaces.js +89 -80
  120. package/dist/hono/schemas/responses.cjs +463 -260
  121. package/dist/hono/schemas/responses.d.ts +1893 -209
  122. package/dist/hono/schemas/responses.d.ts.map +1 -1
  123. package/dist/hono/schemas/responses.js +203 -14
  124. package/dist/hono/start-server.cjs +9 -0
  125. package/dist/hono/start-server.d.ts.map +1 -1
  126. package/dist/hono/start-server.js +9 -0
  127. package/dist/hono/types.d.ts +11 -0
  128. package/dist/hono/types.d.ts.map +1 -1
  129. package/dist/index.cjs +5 -1
  130. package/dist/index.d.ts +2 -0
  131. package/dist/index.d.ts.map +1 -1
  132. package/dist/index.js +2 -0
  133. 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,7 +71,7 @@ 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({
@@ -98,210 +89,216 @@ const ResourcesListResponseSchema = import_zod_openapi.z.object({
98
89
  resources: import_zod_openapi.z.array(ServerResourceSchema).describe("Array of available resources")
99
90
  }).strict().describe("List of resources from MCP server");
100
91
  const ResourceContentSchema = import_zod_openapi.z.object({
101
- content: import_zod_openapi.z.any().describe("Resource content data")
92
+ content: import_responses.JsonValueSchema.describe("Resource content data")
102
93
  }).strict().describe("Resource content wrapper");
103
94
  const ResourceContentResponseSchema = import_zod_openapi.z.object({
104
95
  success: import_zod_openapi.z.boolean().describe("Success indicator"),
105
96
  data: ResourceContentSchema.describe("Resource content")
106
97
  }).strict().describe("Resource content response");
107
- function createMcpRouter(getAgent, getAgentConfigPath) {
108
- const app = new import_zod_openapi.OpenAPIHono();
109
- const addServerRoute = (0, import_zod_openapi.createRoute)({
110
- method: "post",
111
- path: "/mcp/servers",
112
- summary: "Add MCP Server",
113
- description: "Connects a new MCP server dynamically",
114
- tags: ["mcp"],
115
- request: { body: { content: { "application/json": { schema: McpServerRequestSchema } } } },
116
- responses: {
117
- 200: {
118
- description: "Server connected",
119
- content: { "application/json": { schema: ServerStatusResponseSchema } }
120
- }
121
- }
122
- });
123
- const listServersRoute = (0, import_zod_openapi.createRoute)({
124
- method: "get",
125
- path: "/mcp/servers",
126
- summary: "List MCP Servers",
127
- description: "Gets a list of all connected and failed MCP servers",
128
- tags: ["mcp"],
129
- responses: {
130
- 200: {
131
- description: "Servers list",
132
- content: { "application/json": { schema: ServersListResponseSchema } }
133
- }
134
- }
135
- });
136
- const getServerConfigRoute = (0, import_zod_openapi.createRoute)({
137
- method: "get",
138
- path: "/mcp/servers/{serverId}/config",
139
- summary: "Get MCP Server Config",
140
- description: "Retrieves the configuration for a specific MCP server",
141
- tags: ["mcp"],
142
- request: {
143
- 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 } }
144
112
  },
145
- responses: {
146
- 200: {
147
- description: "Server configuration",
148
- content: { "application/json": { schema: ServerConfigResponseSchema } }
149
- },
150
- 404: {
151
- description: "Not found",
152
- content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
153
- }
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 } }
144
+ },
145
+ 404: {
146
+ description: "Not found",
147
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
154
148
  }
155
- });
156
- const updateServerRoute = (0, import_zod_openapi.createRoute)({
157
- method: "put",
158
- path: "/mcp/servers/{serverId}",
159
- summary: "Update MCP Server",
160
- description: "Updates configuration for an existing MCP server",
161
- tags: ["mcp"],
162
- request: {
163
- params: import_zod_openapi.z.object({ serverId: import_zod_openapi.z.string().describe("The ID of the MCP server") }),
164
- 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 } }
165
165
  },
166
- responses: {
167
- 200: {
168
- description: "Server updated",
169
- content: { "application/json": { schema: ServerStatusResponseSchema } }
170
- },
171
- 404: {
172
- description: "Not found",
173
- content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
174
- }
166
+ 404: {
167
+ description: "Not found",
168
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
175
169
  }
176
- });
177
- const toolsRoute = (0, import_zod_openapi.createRoute)({
178
- method: "get",
179
- path: "/mcp/servers/{serverId}/tools",
180
- summary: "List Server Tools",
181
- description: "Retrieves the list of tools available on a specific MCP server",
182
- tags: ["mcp"],
183
- request: {
184
- 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 } }
185
185
  },
186
- responses: {
187
- 200: {
188
- description: "Tools list",
189
- content: { "application/json": { schema: ToolsListResponseSchema } }
190
- },
191
- 404: {
192
- description: "Not found",
193
- content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
194
- }
186
+ 404: {
187
+ description: "Not found",
188
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
195
189
  }
196
- });
197
- const deleteServerRoute = (0, import_zod_openapi.createRoute)({
198
- method: "delete",
199
- path: "/mcp/servers/{serverId}",
200
- summary: "Remove MCP Server",
201
- description: "Disconnects and removes an MCP server",
202
- tags: ["mcp"],
203
- request: {
204
- 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 } }
205
205
  },
206
- responses: {
207
- 200: {
208
- description: "Disconnected",
209
- content: { "application/json": { schema: DisconnectResponseSchema } }
210
- },
211
- 404: {
212
- description: "Not found",
213
- content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
214
- }
206
+ 404: {
207
+ description: "Not found",
208
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
215
209
  }
216
- });
217
- const restartServerRoute = (0, import_zod_openapi.createRoute)({
218
- method: "post",
219
- path: "/mcp/servers/{serverId}/restart",
220
- summary: "Restart MCP Server",
221
- description: "Restarts a connected MCP server",
222
- tags: ["mcp"],
223
- request: {
224
- 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 } }
225
225
  },
226
- responses: {
227
- 200: {
228
- description: "Server restarted",
229
- content: { "application/json": { schema: RestartResponseSchema } }
230
- },
231
- 404: {
232
- description: "Not found",
233
- content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
234
- }
226
+ 404: {
227
+ description: "Not found",
228
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
235
229
  }
236
- });
237
- const execToolRoute = (0, import_zod_openapi.createRoute)({
238
- method: "post",
239
- path: "/mcp/servers/{serverId}/tools/{toolName}/execute",
240
- summary: "Execute MCP Tool",
241
- description: "Executes a tool on an MCP server directly",
242
- tags: ["mcp"],
243
- request: {
244
- params: import_zod_openapi.z.object({
245
- serverId: import_zod_openapi.z.string().describe("The ID of the MCP server"),
246
- toolName: import_zod_openapi.z.string().describe("The name of the tool to execute")
247
- }),
248
- 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 } }
249
249
  },
250
- responses: {
251
- 200: {
252
- description: "Tool executed",
253
- content: { "application/json": { schema: ToolExecutionResponseSchema } }
254
- },
255
- 404: {
256
- description: "Not found",
257
- content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
258
- }
250
+ 404: {
251
+ description: "Not found",
252
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
259
253
  }
260
- });
261
- const listResourcesRoute = (0, import_zod_openapi.createRoute)({
262
- method: "get",
263
- path: "/mcp/servers/{serverId}/resources",
264
- summary: "List Server Resources",
265
- description: "Retrieves all resources available from a specific MCP server",
266
- tags: ["mcp"],
267
- request: {
268
- 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 } }
269
269
  },
270
- responses: {
271
- 200: {
272
- description: "Server resources",
273
- content: { "application/json": { schema: ResourcesListResponseSchema } }
274
- },
275
- 404: {
276
- description: "Not found",
277
- content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
278
- }
270
+ 404: {
271
+ description: "Not found",
272
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
279
273
  }
280
- });
281
- const getResourceContentRoute = (0, import_zod_openapi.createRoute)({
282
- method: "get",
283
- path: "/mcp/servers/{serverId}/resources/{resourceId}/content",
284
- summary: "Read Server Resource Content",
285
- description: "Reads content from a specific resource on an MCP server. This endpoint automatically constructs the qualified URI format (mcp:serverId:resourceId)",
286
- tags: ["mcp"],
287
- request: {
288
- params: import_zod_openapi.z.object({
289
- serverId: import_zod_openapi.z.string().describe("The ID of the MCP server"),
290
- 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")
291
- })
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 } }
292
292
  },
293
- responses: {
294
- 200: {
295
- description: "Resource content",
296
- content: { "application/json": { schema: ResourceContentResponseSchema } }
297
- },
298
- 404: {
299
- description: "Not found",
300
- content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
301
- }
293
+ 404: {
294
+ description: "Not found",
295
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
302
296
  }
303
- });
304
- 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) => {
305
302
  const agent = await getAgent(ctx);
306
303
  const { name, config, persistToAgent } = ctx.req.valid("json");
307
304
  await agent.addMcpServer(name, config);
@@ -356,7 +353,8 @@ function createMcpRouter(getAgent, getAgentConfigPath) {
356
353
  throw import_core.MCPError.serverNotFound(serverId);
357
354
  }
358
355
  return ctx.json({ name: serverId, config: import_core.McpServerConfigSchema.parse(config) }, 200);
359
- }).openapi(updateServerRoute, async (ctx) => {
356
+ });
357
+ const serverUpdateRouter = new import_zod_openapi.OpenAPIHono().openapi(updateServerRoute, async (ctx) => {
360
358
  const agent = await getAgent(ctx);
361
359
  const { serverId } = ctx.req.valid("param");
362
360
  const { config, persistToAgent } = ctx.req.valid("json");
@@ -382,15 +380,15 @@ function createMcpRouter(getAgent, getAgentConfigPath) {
382
380
  import_core.logger.info(`Saved server '${serverId}' to agent configuration file`);
383
381
  } catch (saveError) {
384
382
  const errorMessage = saveError instanceof Error ? saveError.message : String(saveError);
385
- import_core.logger.warn(
386
- `Failed to persist MCP server '${serverId}' update: ${errorMessage}`,
387
- { error: saveError }
388
- );
383
+ import_core.logger.warn(`Failed to persist MCP server '${serverId}' update: ${errorMessage}`, {
384
+ error: saveError
385
+ });
389
386
  }
390
387
  }
391
388
  const status = config.enabled === false ? "registered" : "connected";
392
389
  return ctx.json({ status, name: serverId }, 200);
393
- }).openapi(toolsRoute, async (ctx) => {
390
+ });
391
+ const serverToolsRouter = new import_zod_openapi.OpenAPIHono().openapi(toolsRoute, async (ctx) => {
394
392
  const agent = await getAgent(ctx);
395
393
  const { serverId } = ctx.req.valid("param");
396
394
  const client = agent.getMcpClients().get(serverId);
@@ -402,11 +400,13 @@ function createMcpRouter(getAgent, getAgentConfigPath) {
402
400
  id: toolName,
403
401
  name: toolName,
404
402
  description: toolDef.description || "",
405
- inputSchema: toolDef.parameters === void 0 ? void 0 : ToolInputSchema.parse(toolDef.parameters),
406
- _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)
407
405
  }));
408
- return ctx.json({ tools }, 200);
409
- }).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) => {
410
410
  const agent = await getAgent(ctx);
411
411
  const { serverId } = ctx.req.valid("param");
412
412
  const clientExists = agent.getMcpClients().has(serverId) || agent.getMcpFailedConnections()[serverId];
@@ -414,8 +414,10 @@ function createMcpRouter(getAgent, getAgentConfigPath) {
414
414
  throw import_core.MCPError.serverNotFound(serverId);
415
415
  }
416
416
  await agent.removeMcpServer(serverId);
417
- return ctx.json({ status: "disconnected", id: serverId }, 200);
418
- }).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) => {
419
421
  const agent = await getAgent(ctx);
420
422
  const { serverId } = ctx.req.valid("param");
421
423
  import_core.logger.info(`Received request to POST /api/mcp/servers/${serverId}/restart`);
@@ -425,8 +427,10 @@ function createMcpRouter(getAgent, getAgentConfigPath) {
425
427
  throw import_core.MCPError.serverNotFound(serverId);
426
428
  }
427
429
  await agent.restartMcpServer(serverId);
428
- return ctx.json({ status: "restarted", id: serverId }, 200);
429
- }).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) => {
430
434
  const agent = await getAgent(ctx);
431
435
  const { serverId, toolName } = ctx.req.valid("param");
432
436
  const body = ctx.req.valid("json");
@@ -436,16 +440,25 @@ function createMcpRouter(getAgent, getAgentConfigPath) {
436
440
  }
437
441
  try {
438
442
  const rawResult = await client.callTool(toolName, body);
439
- return ctx.json({ success: true, data: rawResult }, 200);
443
+ const response = {
444
+ success: true,
445
+ data: import_responses.JsonValueSchema.parse(rawResult)
446
+ };
447
+ return ctx.json(response, 200);
440
448
  } catch (error) {
441
449
  const errorMessage = error instanceof Error ? error.message : String(error);
442
450
  import_core.logger.error(
443
451
  `Tool execution failed for '${toolName}' on server '${serverId}': ${errorMessage}`,
444
452
  { error }
445
453
  );
446
- return ctx.json({ success: false, error: errorMessage }, 200);
454
+ const response = {
455
+ success: false,
456
+ error: errorMessage
457
+ };
458
+ return ctx.json(response, 200);
447
459
  }
448
- }).openapi(listResourcesRoute, async (ctx) => {
460
+ });
461
+ const listResourcesRouter = new import_zod_openapi.OpenAPIHono().openapi(listResourcesRoute, async (ctx) => {
449
462
  const agent = await getAgent(ctx);
450
463
  const { serverId } = ctx.req.valid("param");
451
464
  const client = agent.getMcpClients().get(serverId);
@@ -453,18 +466,36 @@ function createMcpRouter(getAgent, getAgentConfigPath) {
453
466
  throw import_core.MCPError.serverNotFound(serverId);
454
467
  }
455
468
  const resources = await agent.listResourcesForServer(serverId);
456
- return ctx.json({ success: true, resources }, 200);
457
- }).openapi(getResourceContentRoute, async (ctx) => {
458
- const agent = await getAgent(ctx);
459
- const { serverId, resourceId } = ctx.req.valid("param");
460
- const client = agent.getMcpClients().get(serverId);
461
- if (!client) {
462
- throw import_core.MCPError.serverNotFound(serverId);
463
- }
464
- const qualifiedUri = `mcp:${serverId}:${resourceId}`;
465
- const content = await agent.readResource(qualifiedUri);
466
- return ctx.json({ success: true, data: { content } }, 200);
469
+ const response = { success: true, resources };
470
+ return ctx.json(response, 200);
467
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;
468
499
  }
469
500
  // Annotate the CommonJS export names for ESM import in node:
470
501
  0 && (module.exports = {