@mastra/deployer 0.10.4 → 0.10.6-alpha.0

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.
@@ -517,9 +517,9 @@ is_latest: boolean;
517
517
  }, ContentfulStatusCode, "json">)>;
518
518
 
519
519
  /**
520
- * Handler for POST /api/mcp/:serverId/mcp
520
+ * Handler for Streamable HTTP requests (POST, GET, DELETE) to /api/mcp/:serverId/mcp
521
521
  */
522
- export declare const getMcpServerMessageHandler: (c: Context) => Promise<Response>;
522
+ export declare const getMcpServerMessageHandler: (c: Context) => Promise<Response | undefined>;
523
523
 
524
524
  /**
525
525
  * Handler for SSE related routes for an MCP server.
@@ -517,9 +517,9 @@ is_latest: boolean;
517
517
  }, ContentfulStatusCode, "json">)>;
518
518
 
519
519
  /**
520
- * Handler for POST /api/mcp/:serverId/mcp
520
+ * Handler for Streamable HTTP requests (POST, GET, DELETE) to /api/mcp/:serverId/mcp
521
521
  */
522
- export declare const getMcpServerMessageHandler: (c: Context) => Promise<Response>;
522
+ export declare const getMcpServerMessageHandler: (c: Context) => Promise<Response | undefined>;
523
523
 
524
524
  /**
525
525
  * Handler for SSE related routes for an MCP server.
@@ -736,7 +736,7 @@ var middleware = (options) => async (c2) => {
736
736
  );
737
737
  };
738
738
 
739
- // ../../node_modules/.pnpm/hono-openapi@0.4.8_hono@4.7.11_openapi-types@12.1.3_zod@3.25.56/node_modules/hono-openapi/utils.js
739
+ // ../../node_modules/.pnpm/hono-openapi@0.4.8_hono@4.7.11_openapi-types@12.1.3_zod@3.25.57/node_modules/hono-openapi/utils.js
740
740
  var e = Symbol("openapi");
741
741
  var n = ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
742
742
  var s2 = (e2) => e2.charAt(0).toUpperCase() + e2.slice(1);
@@ -3378,22 +3378,35 @@ var getMcpServerMessageHandler = async (c2) => {
3378
3378
  const { req, res } = toReqRes(c2.req.raw);
3379
3379
  const server = mastra.getMCPServer(serverId);
3380
3380
  if (!server) {
3381
- return c2.json({ error: `MCP server '${serverId}' not found` }, 404);
3381
+ res.writeHead(404, { "Content-Type": "application/json" });
3382
+ res.end(JSON.stringify({ error: `MCP server '${serverId}' not found` }));
3383
+ return;
3382
3384
  }
3383
3385
  try {
3384
3386
  await server.startHTTP({
3385
3387
  url: new URL(c2.req.url),
3386
3388
  httpPath: `/api/mcp/${serverId}/mcp`,
3387
3389
  req,
3388
- res,
3389
- options: {
3390
- sessionIdGenerator: void 0
3391
- }
3390
+ res
3392
3391
  });
3393
- const toFetchRes = await toFetchResponse(res);
3394
- return toFetchRes;
3392
+ return await toFetchResponse(res);
3395
3393
  } catch (error) {
3396
- return handleError(error, "Error sending MCP message");
3394
+ if (!res.headersSent) {
3395
+ res.writeHead(500, { "Content-Type": "application/json" });
3396
+ res.end(
3397
+ JSON.stringify({
3398
+ jsonrpc: "2.0",
3399
+ error: {
3400
+ code: -32603,
3401
+ message: "Internal server error"
3402
+ },
3403
+ id: null
3404
+ // Cannot determine original request ID in catch
3405
+ })
3406
+ );
3407
+ } else {
3408
+ c2.get("logger")?.error("Error after headers sent:", error);
3409
+ }
3397
3410
  }
3398
3411
  };
3399
3412
  var getMcpServerSseHandler = async (c2) => {
@@ -4261,7 +4274,7 @@ async function streamWorkflowHandler(c2) {
4261
4274
  c2,
4262
4275
  async (stream4) => {
4263
4276
  try {
4264
- const result = workflows.streamWorkflowHandler({
4277
+ const result = await workflows.streamWorkflowHandler({
4265
4278
  mastra,
4266
4279
  workflowId,
4267
4280
  runId,
@@ -4513,7 +4526,8 @@ ${err.stack.split("\n").slice(1).join("\n")}
4513
4526
  const contentType = c2.req.header("content-type");
4514
4527
  if (contentType?.includes("application/json")) {
4515
4528
  try {
4516
- const body = await c2.req.json();
4529
+ const clonedReq = c2.req.raw.clone();
4530
+ const body = await clonedReq.json();
4517
4531
  if (body.runtimeContext) {
4518
4532
  runtimeContext$1 = new runtimeContext.RuntimeContext(Object.entries(body.runtimeContext));
4519
4533
  }
@@ -5661,6 +5675,30 @@ ${err.stack.split("\n").slice(1).join("\n")}
5661
5675
  }),
5662
5676
  getMcpServerMessageHandler
5663
5677
  );
5678
+ app.get(
5679
+ "/api/mcp/:serverId/mcp",
5680
+ w({
5681
+ description: "Send a message to an MCP server using Streamable HTTP",
5682
+ tags: ["mcp"],
5683
+ parameters: [
5684
+ {
5685
+ name: "serverId",
5686
+ in: "path",
5687
+ required: true,
5688
+ schema: { type: "string" }
5689
+ }
5690
+ ],
5691
+ responses: {
5692
+ 200: {
5693
+ description: "Streamable HTTP connection processed"
5694
+ },
5695
+ 404: {
5696
+ description: "MCP server not found"
5697
+ }
5698
+ }
5699
+ }),
5700
+ getMcpServerMessageHandler
5701
+ );
5664
5702
  const mcpSseBasePath = "/api/mcp/:serverId/sse";
5665
5703
  const mcpSseMessagePath = "/api/mcp/:serverId/messages";
5666
5704
  app.get(
@@ -7414,14 +7452,9 @@ async function createNodeServer(mastra, options = {}) {
7414
7452
  const logger2 = mastra.getLogger();
7415
7453
  const host = serverOptions?.host ?? "localhost";
7416
7454
  logger2.info(` Mastra API running on port http://${host}:${port}/api`);
7417
- if (options?.isDev) {
7418
- logger2.info(`\u{1F517} Open API documentation available at http://${host}:${port}/openapi.json`);
7419
- }
7420
- if (options?.isDev) {
7421
- logger2.info(`\u{1F9EA} Swagger UI available at http://${host}:${port}/swagger-ui`);
7422
- }
7423
7455
  if (options?.playground) {
7424
- logger2.info(`\u{1F468}\u200D\u{1F4BB} Playground available at http://${host}:${port}/`);
7456
+ const playgroundUrl = `http://${host}:${port}`;
7457
+ logger2.info(`\u{1F468}\u200D\u{1F4BB} Playground available at ${playgroundUrl}`);
7425
7458
  }
7426
7459
  if (process.send) {
7427
7460
  process.send({
@@ -729,7 +729,7 @@ var middleware = (options) => async (c2) => {
729
729
  );
730
730
  };
731
731
 
732
- // ../../node_modules/.pnpm/hono-openapi@0.4.8_hono@4.7.11_openapi-types@12.1.3_zod@3.25.56/node_modules/hono-openapi/utils.js
732
+ // ../../node_modules/.pnpm/hono-openapi@0.4.8_hono@4.7.11_openapi-types@12.1.3_zod@3.25.57/node_modules/hono-openapi/utils.js
733
733
  var e = Symbol("openapi");
734
734
  var n = ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
735
735
  var s2 = (e2) => e2.charAt(0).toUpperCase() + e2.slice(1);
@@ -3371,22 +3371,35 @@ var getMcpServerMessageHandler = async (c2) => {
3371
3371
  const { req, res } = toReqRes(c2.req.raw);
3372
3372
  const server = mastra.getMCPServer(serverId);
3373
3373
  if (!server) {
3374
- return c2.json({ error: `MCP server '${serverId}' not found` }, 404);
3374
+ res.writeHead(404, { "Content-Type": "application/json" });
3375
+ res.end(JSON.stringify({ error: `MCP server '${serverId}' not found` }));
3376
+ return;
3375
3377
  }
3376
3378
  try {
3377
3379
  await server.startHTTP({
3378
3380
  url: new URL(c2.req.url),
3379
3381
  httpPath: `/api/mcp/${serverId}/mcp`,
3380
3382
  req,
3381
- res,
3382
- options: {
3383
- sessionIdGenerator: void 0
3384
- }
3383
+ res
3385
3384
  });
3386
- const toFetchRes = await toFetchResponse(res);
3387
- return toFetchRes;
3385
+ return await toFetchResponse(res);
3388
3386
  } catch (error) {
3389
- return handleError(error, "Error sending MCP message");
3387
+ if (!res.headersSent) {
3388
+ res.writeHead(500, { "Content-Type": "application/json" });
3389
+ res.end(
3390
+ JSON.stringify({
3391
+ jsonrpc: "2.0",
3392
+ error: {
3393
+ code: -32603,
3394
+ message: "Internal server error"
3395
+ },
3396
+ id: null
3397
+ // Cannot determine original request ID in catch
3398
+ })
3399
+ );
3400
+ } else {
3401
+ c2.get("logger")?.error("Error after headers sent:", error);
3402
+ }
3390
3403
  }
3391
3404
  };
3392
3405
  var getMcpServerSseHandler = async (c2) => {
@@ -4254,7 +4267,7 @@ async function streamWorkflowHandler(c2) {
4254
4267
  c2,
4255
4268
  async (stream4) => {
4256
4269
  try {
4257
- const result = streamWorkflowHandler$1({
4270
+ const result = await streamWorkflowHandler$1({
4258
4271
  mastra,
4259
4272
  workflowId,
4260
4273
  runId,
@@ -4506,7 +4519,8 @@ ${err.stack.split("\n").slice(1).join("\n")}
4506
4519
  const contentType = c2.req.header("content-type");
4507
4520
  if (contentType?.includes("application/json")) {
4508
4521
  try {
4509
- const body = await c2.req.json();
4522
+ const clonedReq = c2.req.raw.clone();
4523
+ const body = await clonedReq.json();
4510
4524
  if (body.runtimeContext) {
4511
4525
  runtimeContext = new RuntimeContext(Object.entries(body.runtimeContext));
4512
4526
  }
@@ -5654,6 +5668,30 @@ ${err.stack.split("\n").slice(1).join("\n")}
5654
5668
  }),
5655
5669
  getMcpServerMessageHandler
5656
5670
  );
5671
+ app.get(
5672
+ "/api/mcp/:serverId/mcp",
5673
+ w({
5674
+ description: "Send a message to an MCP server using Streamable HTTP",
5675
+ tags: ["mcp"],
5676
+ parameters: [
5677
+ {
5678
+ name: "serverId",
5679
+ in: "path",
5680
+ required: true,
5681
+ schema: { type: "string" }
5682
+ }
5683
+ ],
5684
+ responses: {
5685
+ 200: {
5686
+ description: "Streamable HTTP connection processed"
5687
+ },
5688
+ 404: {
5689
+ description: "MCP server not found"
5690
+ }
5691
+ }
5692
+ }),
5693
+ getMcpServerMessageHandler
5694
+ );
5657
5695
  const mcpSseBasePath = "/api/mcp/:serverId/sse";
5658
5696
  const mcpSseMessagePath = "/api/mcp/:serverId/messages";
5659
5697
  app.get(
@@ -7407,14 +7445,9 @@ async function createNodeServer(mastra, options = {}) {
7407
7445
  const logger2 = mastra.getLogger();
7408
7446
  const host = serverOptions?.host ?? "localhost";
7409
7447
  logger2.info(` Mastra API running on port http://${host}:${port}/api`);
7410
- if (options?.isDev) {
7411
- logger2.info(`\u{1F517} Open API documentation available at http://${host}:${port}/openapi.json`);
7412
- }
7413
- if (options?.isDev) {
7414
- logger2.info(`\u{1F9EA} Swagger UI available at http://${host}:${port}/swagger-ui`);
7415
- }
7416
7448
  if (options?.playground) {
7417
- logger2.info(`\u{1F468}\u200D\u{1F4BB} Playground available at http://${host}:${port}/`);
7449
+ const playgroundUrl = `http://${host}:${port}`;
7450
+ logger2.info(`\u{1F468}\u200D\u{1F4BB} Playground available at ${playgroundUrl}`);
7418
7451
  }
7419
7452
  if (process.send) {
7420
7453
  process.send({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/deployer",
3
- "version": "0.10.4",
3
+ "version": "0.10.6-alpha.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -95,29 +95,29 @@
95
95
  "@rollup/plugin-virtual": "^3.0.2",
96
96
  "@sindresorhus/slugify": "^2.2.1",
97
97
  "builtins": "^5.1.0",
98
- "detect-libc": "^2.0.3",
98
+ "detect-libc": "^2.0.4",
99
99
  "dotenv": "^16.5.0",
100
- "esbuild": "^0.25.1",
100
+ "esbuild": "^0.25.5",
101
101
  "find-workspaces": "^0.3.1",
102
102
  "fs-extra": "^11.3.0",
103
103
  "globby": "^14.1.0",
104
104
  "hono": "^4.7.11",
105
105
  "resolve-from": "^5.0.0",
106
- "rollup": "^4.41.1",
106
+ "rollup": "^4.43.0",
107
107
  "rollup-plugin-esbuild": "^6.2.1",
108
108
  "rollup-plugin-node-externals": "^8.0.0",
109
109
  "typescript-paths": "^1.5.1",
110
- "zod": "^3.25.56",
111
- "@mastra/server": "^0.10.4"
110
+ "zod": "^3.25.57",
111
+ "@mastra/server": "^0.10.6-alpha.0"
112
112
  },
113
113
  "devDependencies": {
114
- "@hono/node-server": "^1.14.3",
115
- "@hono/swagger-ui": "^0.5.1",
114
+ "@hono/node-server": "^1.14.4",
115
+ "@hono/swagger-ui": "^0.5.2",
116
116
  "@microsoft/api-extractor": "^7.52.8",
117
117
  "@types/babel__core": "^7.20.5",
118
118
  "@types/babel__helper-module-imports": "^7.18.3",
119
119
  "@types/fs-extra": "^11.0.4",
120
- "@types/node": "^20.17.57",
120
+ "@types/node": "^20.19.0",
121
121
  "eslint": "^9.28.0",
122
122
  "fetch-to-node": "^2.1.0",
123
123
  "hono-openapi": "^0.4.8",
@@ -125,11 +125,11 @@
125
125
  "superjson": "^2.2.2",
126
126
  "tsup": "^8.5.0",
127
127
  "type-fest": "^4.41.0",
128
- "typescript": "^5.8.2",
128
+ "typescript": "^5.8.3",
129
129
  "vitest": "^2.1.9",
130
- "@internal/lint": "0.0.11",
131
- "@mastra/core": "0.10.4",
132
- "@mastra/mcp": "^0.10.3"
130
+ "@internal/lint": "0.0.12",
131
+ "@mastra/core": "0.10.6-alpha.0",
132
+ "@mastra/mcp": "^0.10.4-alpha.0"
133
133
  },
134
134
  "peerDependencies": {
135
135
  "@mastra/core": "^0.10.2-alpha.0"