@mastra/server 1.64.0-alpha.6 → 1.64.0-alpha.7

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 (40) hide show
  1. package/README.md +27 -33
  2. package/dist/{a2a-CMi5AZNR.js → a2a-DdCHhKh5.js} +7 -7
  3. package/dist/{a2a-CMi5AZNR.js.map → a2a-DdCHhKh5.js.map} +1 -1
  4. package/dist/{api-schema-manifest-C0fowe3V.js → api-schema-manifest-Ckuac2Uz.js} +2 -2
  5. package/dist/{api-schema-manifest-C0fowe3V.js.map → api-schema-manifest-Ckuac2Uz.js.map} +1 -1
  6. package/dist/{dist-JaHKn7NU.js → dist-BwPO-2NT.js} +1667 -1378
  7. package/dist/dist-BwPO-2NT.js.map +1 -0
  8. package/dist/{dist-BuyLBfu3.cjs → dist-mj70vroq.cjs} +1667 -1377
  9. package/dist/dist-mj70vroq.cjs.map +1 -0
  10. package/dist/docs/SKILL.md +1 -1
  11. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  12. package/dist/{routes-D9HqtkO2.js → routes-DCdH7ljX.js} +2 -2
  13. package/dist/{routes-D9HqtkO2.js.map → routes-DCdH7ljX.js.map} +1 -1
  14. package/dist/server/handlers/a2a.js +1 -1
  15. package/dist/server/handlers/agent-builder.cjs +1 -1
  16. package/dist/server/handlers/agent-builder.js +1 -1
  17. package/dist/server/handlers/mcp-client-versions.cjs +1 -1
  18. package/dist/server/handlers/mcp-client-versions.js +1 -1
  19. package/dist/server/handlers/prompt-block-versions.cjs +1 -1
  20. package/dist/server/handlers/prompt-block-versions.js +1 -1
  21. package/dist/server/handlers/scorer-versions.cjs +1 -1
  22. package/dist/server/handlers/scorer-versions.js +1 -1
  23. package/dist/server/handlers/stored-mcp-clients.cjs +1 -1
  24. package/dist/server/handlers/stored-mcp-clients.js +1 -1
  25. package/dist/server/handlers/stored-prompt-blocks.cjs +1 -1
  26. package/dist/server/handlers/stored-prompt-blocks.js +1 -1
  27. package/dist/server/handlers/stored-scorers.cjs +1 -1
  28. package/dist/server/handlers/stored-scorers.js +1 -1
  29. package/dist/server/handlers/stored-skill-favorites.cjs +1 -1
  30. package/dist/server/handlers/stored-skill-favorites.js +1 -1
  31. package/dist/server/handlers/stored-skills.cjs +1 -1
  32. package/dist/server/handlers/stored-skills.js +1 -1
  33. package/dist/server/handlers/system.js +1 -1
  34. package/dist/server/handlers.js +1 -1
  35. package/dist/server/schemas/index.cjs +1 -1
  36. package/dist/server/schemas/index.js +1 -1
  37. package/dist/server/server-adapter/index.js +1 -1
  38. package/package.json +7 -7
  39. package/dist/dist-BuyLBfu3.cjs.map +0 -1
  40. package/dist/dist-JaHKn7NU.js.map +0 -1
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # @mastra/server
2
2
 
3
- Typed HTTP handlers and utilities for exposing a `Mastra` instance over HTTP.
4
- This package powers `mastra dev` and can be added to your own server to provide
5
- REST and streaming endpoints for agents, workflows, telemetry and more.
3
+ Typed, framework-agnostic HTTP route definitions, handlers, schemas, and adapter utilities for exposing a `Mastra` instance over HTTP. This package powers Mastra's development server and the framework-specific server adapters.
6
4
 
7
5
  ## Installation
8
6
 
@@ -12,56 +10,52 @@ npm install @mastra/server
12
10
 
13
11
  ## Usage
14
12
 
15
- The handlers are framework agnostic functions which accept a `Mastra` instance
16
- and a request context. They are typically mounted under a URL prefix within your
17
- web framework of choice:
13
+ The handlers are framework-agnostic functions that accept a `Mastra` instance and request context. Import them from `@mastra/server/handlers`, then mount the route handlers under a URL prefix in your web framework:
18
14
 
19
15
  ```typescript
16
+ import { RequestContext } from '@mastra/core/request-context';
17
+ import { agents } from '@mastra/server/handlers';
20
18
  import { Hono } from 'hono';
21
- import { handlers } from '@mastra/server';
22
19
  import { mastra } from './mastra-instance';
23
20
 
24
21
  const app = new Hono();
25
22
 
26
- app.get('/mastra/agents', ctx => handlers.agents.listAgentsHandler({ mastra, requestContext: ctx }));
27
- app.post('/mastra/agents/:id/generate', async ctx => {
28
- const body = await ctx.req.json();
29
- return handlers.agents.generateHandler({
23
+ app.get('/mastra/agents', async c => {
24
+ const result = await agents.LIST_AGENTS_ROUTE.handler({
30
25
  mastra,
31
- requestContext: ctx,
32
- agentId: ctx.req.param('id'),
33
- body,
26
+ partial: c.req.query('partial'),
27
+ requestContext: new RequestContext(),
34
28
  });
29
+
30
+ return c.json(result);
35
31
  });
36
32
 
37
- // Mount additional handlers as required
33
+ export default app;
38
34
  ```
39
35
 
40
- Running `mastra dev` starts a local development UI at
41
- `http://localhost:3000` using these handlers.
36
+ Each exported route combines its HTTP method, path, validation schemas, permission requirements, response type, and handler. Framework adapter packages automate this registration and translate framework requests and responses into the common handler context.
42
37
 
43
- ## Available Handler Groups
38
+ ## Documentation
44
39
 
45
- - **Agents** - list defined agents, retrieve metadata, and run `generate`
46
- or `stream`.
47
- - **Workflows** - start and inspect workflow runs.
48
- - **Tools** - discover tools available to the `Mastra` instance.
49
- - **Memory** - interact with configured memory stores.
50
- - **Logs** - query runtime logs when a supporting logger transport is used.
51
- - **Telemetry** - expose metrics produced by the telemetry subsystem.
52
- - **Networks** - interact with agent networks.
53
- - **Vector / Voice** - endpoints related to vector stores and voice synthesis.
40
+ Handler groups cover agents and agent controllers, conversations, workflows and dynamic workflows, tools, MCP, memory, vectors, voice, logs, observability, scores, schedules, datasets, processors, workspaces, skills, plans, authentication, A2A tasks, and stored entities.
54
41
 
55
- Handlers return JSON serialisable data and throw an `HTTPException` (subclass of
56
- `Error`) when a failure should result in a non-2xx HTTP status.
42
+ Route handlers return serializable values or streams and throw `HTTPException` when an error should map to a non-2xx response. Shared schemas and error-formatting helpers are available through package subpaths for adapters that need to validate requests or emit OpenAPI metadata.
57
43
 
58
- ## OpenAPI Spec Generation
44
+ `@mastra/server/server-adapter` exports the abstract `MastraServer` contract and common route-registration utilities. Adapter packages implement framework-specific streaming, parameter extraction, response handling, context middleware, authentication middleware, and HTTP logging around this contract.
59
45
 
60
- The local OpenAPI specification used by the CLI playground and similar tools can
61
- be refreshed by running:
46
+ The package's OpenAPI-derived route metadata can be refreshed from `packages/server` with:
62
47
 
63
48
  ```bash
64
49
  pnpm run pull:openapispec
65
50
  ```
66
51
 
67
- within the `@mastra/server` directory.
52
+ - [`MastraServer` adapter reference](https://mastra.ai/reference/server/mastra-server)
53
+ - [Server adapter guide](https://mastra.ai/docs/server/server-adapters)
54
+
55
+ ## Changelog
56
+
57
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/packages/server/CHANGELOG.md) for version history and release notes.
58
+
59
+ ## Support
60
+
61
+ We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
@@ -8,7 +8,7 @@ import { getPublicOrigin } from "./server/handlers/auth.js";
8
8
  import { z } from "zod/v4";
9
9
  import { isDeepStrictEqual } from "util";
10
10
  import { MastraA2AError } from "@mastra/core/a2a";
11
- import * as crypto$1 from "crypto";
11
+ import * as crypto$2 from "crypto";
12
12
  import { lookup } from "dns/promises";
13
13
  import { request } from "http";
14
14
  import { request as request$1 } from "https";
@@ -47,8 +47,8 @@ function stripAgentCardSignatures(agentCard) {
47
47
  }
48
48
  function importSigningKey(signing) {
49
49
  const { privateKey } = signing;
50
- if (typeof privateKey === "string") return crypto$1.createPrivateKey(privateKey);
51
- return crypto$1.createPrivateKey({
50
+ if (typeof privateKey === "string") return crypto$2.createPrivateKey(privateKey);
51
+ return crypto$2.createPrivateKey({
52
52
  key: privateKey,
53
53
  format: "jwk"
54
54
  });
@@ -64,8 +64,8 @@ function getProtectedHeader(signing) {
64
64
  function getSignatureOptions(algorithm) {
65
65
  if (algorithm.startsWith("ES")) return { dsaEncoding: "ieee-p1363" };
66
66
  if (algorithm.startsWith("PS")) return {
67
- padding: crypto$1.constants.RSA_PKCS1_PSS_PADDING,
68
- saltLength: crypto$1.constants.RSA_PSS_SALTLEN_DIGEST
67
+ padding: crypto$2.constants.RSA_PKCS1_PSS_PADDING,
68
+ saltLength: crypto$2.constants.RSA_PSS_SALTLEN_DIGEST
69
69
  };
70
70
  return {};
71
71
  }
@@ -82,7 +82,7 @@ async function signAgentCard({ agentCard, signing }) {
82
82
  const protectedHeader = getProtectedHeader(signing);
83
83
  const encodedHeader = Buffer.from(JSON.stringify(protectedHeader), "utf8").toString("base64url");
84
84
  const signingInput = `${encodedHeader}.${Buffer.from(canonicalPayload, "utf8").toString("base64url")}`;
85
- const signatureValue = crypto$1.sign(getDigestAlgorithm(String(protectedHeader.alg)), Buffer.from(signingInput, "utf8"), {
85
+ const signatureValue = crypto$2.sign(getDigestAlgorithm(String(protectedHeader.alg)), Buffer.from(signingInput, "utf8"), {
86
86
  key,
87
87
  ...getSignatureOptions(String(protectedHeader.alg))
88
88
  }).toString("base64url");
@@ -1973,4 +1973,4 @@ const AGENT_EXECUTION_ROUTE = createRoute({
1973
1973
  //#endregion
1974
1974
  export { getAgentExecutionHandler as a, handleListTaskPushNotificationConfig as c, handleSetTaskPushNotificationConfig as d, handleTaskCancel as f, resolveA2AProtocolVersion as g, handleTaskResubscribe as h, getAgentCardByIdHandler as i, handleMessageSend as l, handleTaskList as m, GET_AGENT_CARD_ROUTE as n, handleDeleteTaskPushNotificationConfig as o, handleTaskGet as p, a2a_exports as r, handleGetTaskPushNotificationConfig as s, AGENT_EXECUTION_ROUTE as t, handleMessageStream as u };
1975
1975
 
1976
- //# sourceMappingURL=a2a-CMi5AZNR.js.map
1976
+ //# sourceMappingURL=a2a-DdCHhKh5.js.map