@mastra/mcp 1.15.0 → 1.15.1-alpha.1

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.
@@ -24,7 +24,7 @@ const myAgent = new Agent({
24
24
  name: 'MyExampleAgent',
25
25
  description: 'A generalist to help with basic questions.',
26
26
  instructions: 'You are a helpful assistant.',
27
- model: 'openai/gpt-5.5',
27
+ model: 'openai/gpt-5.6-sol',
28
28
  })
29
29
 
30
30
  const weatherTool = createTool({
@@ -101,20 +101,20 @@ A powerful feature of `MCPServer` is its ability to automatically expose your Ma
101
101
 
102
102
  - **Description**: The generated tool's description will be in the format: "Ask agent `<AgentName>` a question. Original agent instructions: `<agent description>`".
103
103
  - **Input**: The tool expects a single object argument with a `message` property (string): `{ message: "Your question for the agent" }`.
104
- - **Execution**: When this tool is called, it invokes the `generate()` method of the corresponding agent, passing the provided `query`.
104
+ - **Execution**: When this tool is called, it invokes the corresponding agent's `generate()` method with the provided `query`.
105
105
  - **Output**: The direct result from the agent's `generate()` method is returned as the output of the tool.
106
106
 
107
- - **Name Collisions**: If an explicit tool defined in the `tools` configuration has the same name as an agent-derived tool (e.g., you have a tool named `ask_myAgentKey` and also an agent with the key `myAgentKey`), the _explicitly defined tool will take precedence_. The agent won't be converted into a tool in this conflicting case, and a warning will be logged.
107
+ - **Name collisions.** If an explicit tool defined in the `tools` configuration has the same name as an agent-derived tool (e.g., a tool named `ask_myAgentKey` alongside an agent keyed as `myAgentKey`), the _explicitly defined tool will take precedence_. The agent won't be converted into a tool in this conflicting case, and a warning will be logged.
108
108
 
109
109
  This makes it straightforward to allow MCP clients to interact with your agents using natural language queries, like any other tool.
110
110
 
111
111
  ### Agent-to-Tool Conversion
112
112
 
113
- When you provide agents in the `agents` configuration property, `MCPServer` will automatically create a corresponding tool for each agent. The tool will be named `ask_<agentIdentifier>`, where `<agentIdentifier>` is the key you used in the `agents` object.
113
+ When you provide agents in the `agents` configuration property, `MCPServer` will automatically create a corresponding tool for each agent. The tool will be `ask_<agentIdentifier>`, where `<agentIdentifier>` is the key you used in the `agents` object.
114
114
 
115
115
  The description for this generated tool will be: "Ask agent `<agent.name>` a question. Agent description: `<agent.description>`".
116
116
 
117
- **Important**: For an agent to be converted into a tool, it **must** have a non-empty `description` string property set in its configuration when it was instantiated (e.g., `new Agent({ id: 'my-agent', name: 'myAgent', description: 'This agent does X.', ... })`). If an agent is passed to `MCPServer` with a missing or empty `description`, an error will be thrown when the `MCPServer` is instantiated, and server setup will fail.
117
+ For an agent to be converted into a tool, it **must** have a non-empty `description` string property set in its configuration when it was instantiated (e.g., `new Agent({ id: 'my-agent', name: 'myAgent', description: 'This agent does X.', ... })`). If an agent is passed to `MCPServer` with a missing or empty `description`, an error will be thrown when the `MCPServer` is instantiated, and server setup will fail.
118
118
 
119
119
  This allows you to quickly expose the generative capabilities of your agents through the MCP, enabling clients to "ask" your agents questions directly.
120
120
 
@@ -412,7 +412,7 @@ serve(async req => {
412
412
  >
413
413
  > This is still stateless: no `mcp-session-id` is required or persisted. It only enables notifications scoped to the current request (such as progress). The session-dependent features below remain unavailable.
414
414
  >
415
- > **Note:** The following MCP features require session state or persistent connections and **won't work** in serverless mode (including with `serverlessStreaming: true`):
415
+ > The following MCP features require session state or persistent connections and **won't work** in serverless mode (including with `serverlessStreaming: true`):
416
416
  >
417
417
  > - **Elicitation** - Interactive user input requests during tool execution require session management to route responses back to the correct client
418
418
  > - **Resource subscriptions** - `resources/subscribe` and `resources/unsubscribe` need persistent connections to maintain subscription state
@@ -439,7 +439,7 @@ The `StreamableHTTPServerTransportOptions` object allows you to customize the be
439
439
 
440
440
  **serverless** (`boolean`): If true, runs in stateless mode without session management. Each request is handled independently with a fresh server instance. Essential for serverless environments (Cloudflare Workers, Supabase Edge Functions, Vercel Edge, etc.) where sessions cannot persist between invocations. Defaults to false.
441
441
 
442
- **serverlessStreaming** (`boolean`): If true, serverless requests use request-scoped SSE streaming instead of a buffered JSON response, allowing in-request notifications/progress to reach the client before the final result. Only takes effect together with serverless: true. Defaults to false (buffered JSON responses), which preserves backward-compatible behavior. This enables only request-scoped notifications such as progress; elicitation, subscriptions, and out-of-request notifications still require session state.
442
+ **serverlessStreaming** (`boolean`): If true, serverless requests use request-scoped SSE streaming instead of a buffered JSON response, allowing in-request notifications/progress to reach the client before the final result. Only takes effect together with serverless: true. Defaults to false (buffered JSON responses), which preserves backward-compatible behavior. It enables only request-scoped notifications such as progress; elicitation, subscriptions, and out-of-request notifications still require session state.
443
443
 
444
444
  **sessionIdGenerator** (`(() => string) | undefined`): A function that generates a unique session ID. This should be a cryptographically secure, globally unique string. Return undefined to disable session management.
445
445
 
@@ -459,7 +459,7 @@ async close(): Promise<void>
459
459
 
460
460
  ### `getServerInfo()`
461
461
 
462
- This method gives you a look at the server's basic information.
462
+ The method returns the server's basic information.
463
463
 
464
464
  ```typescript
465
465
  getServerInfo(): ServerInfo
@@ -467,7 +467,7 @@ getServerInfo(): ServerInfo
467
467
 
468
468
  ### `getServerDetail()`
469
469
 
470
- This method gives you a detailed look at the server's information.
470
+ The method returns details about the server's information.
471
471
 
472
472
  ```typescript
473
473
  getServerDetail(): ServerDetail
@@ -475,7 +475,7 @@ getServerDetail(): ServerDetail
475
475
 
476
476
  ### `getToolListInfo()`
477
477
 
478
- This method gives you a look at the tools that were set up when you created the server. It's a read-only list, useful for debugging purposes.
478
+ The method returns the tools that were set up when you created the server. It's a read-only list, useful for debugging purposes.
479
479
 
480
480
  ```typescript
481
481
  getToolListInfo(): ToolListInfo
@@ -483,7 +483,7 @@ getToolListInfo(): ToolListInfo
483
483
 
484
484
  ### `getToolInfo()`
485
485
 
486
- This method gives you detailed information about a specific tool.
486
+ The method returns details about a specific tool.
487
487
 
488
488
  ```typescript
489
489
  getToolInfo(toolName: string): ToolInfo
@@ -565,7 +565,7 @@ Resources are identified by unique URIs (e.g., `file:///home/user/documents/repo
565
565
  Clients can discover resources through:
566
566
 
567
567
  1. **Direct resources**: Servers expose a list of concrete resources via a `resources/list` endpoint.
568
- 2. **Resource templates**: For dynamic resources, servers can expose URI templates (RFC 6570) that clients use to construct resource URIs.
568
+ 2. **Resource templates**: For runtime-defined resources, servers can expose URI templates (RFC 6570) that clients use to construct resource URIs.
569
569
 
570
570
  To read a resource, clients make a `resources/read` request with the URI. Servers can also notify clients about changes to the resource list (`notifications/resources/list_changed`) or updates to specific resource content (`notifications/resources/updated`) if a client has subscribed to that resource.
571
571
 
@@ -659,7 +659,7 @@ await serverWithResources.resources.notifyUpdated({ uri: 'file://data.txt' })
659
659
 
660
660
  #### `server.resources.notifyListChanged()`
661
661
 
662
- Call this method when the overall list of available resources has changed (e.g., a resource was added or removed). This will send a `notifications/resources/list_changed` message to clients, prompting them to re-fetch the list of resources.
662
+ Call this method when the list of available resources has changed (e.g., a resource was added or removed). This will send a `notifications/resources/list_changed` message to clients, prompting them to re-fetch the list of resources.
663
663
 
664
664
  ```typescript
665
665
  async server.resources.notifyListChanged(): Promise<void>
@@ -676,9 +676,9 @@ await serverWithResources.resources.notifyListChanged()
676
676
 
677
677
  ### What are MCP Prompts?
678
678
 
679
- Prompts are reusable templates or workflows that MCP servers expose to clients. They can accept arguments, include resource context, support versioning, and be used to standardize LLM interactions.
679
+ Prompts are reusable templates or workflows that MCP servers expose to clients. They can accept arguments and include resource context. They also support versioning and standardize LLM interactions.
680
680
 
681
- Prompts are identified by a unique name (and optional version) and can be dynamic or static.
681
+ Prompts are identified by a unique name (and optional version) and can be runtime-defined or static.
682
682
 
683
683
  ### `MCPServerPrompts` Type
684
684
 
@@ -773,7 +773,7 @@ If the available prompts change, your server can notify connected clients:
773
773
 
774
774
  #### `server.prompts.notifyListChanged()`
775
775
 
776
- Call this method when the overall list of available prompts has changed (e.g., a prompt was added or removed). This will send a `notifications/prompts/list_changed` message to clients, prompting them to re-fetch the list of prompts.
776
+ Call this method when the list of available prompts has changed (e.g., a prompt was added or removed). This will send a `notifications/prompts/list_changed` message to clients, prompting them to re-fetch the list of prompts.
777
777
 
778
778
  ```typescript
779
779
  await serverWithPrompts.prompts.notifyListChanged()
@@ -793,7 +793,7 @@ await serverWithPrompts.prompts.notifyListChanged()
793
793
 
794
794
  Tools are usually provided when constructing the `MCPServer`, but you can also add or remove tools while the server is running. The server exposes these operations through the `toolActions` property. When the tool list changes, connected clients receive a `notifications/tools/list_changed` message prompting them to re-fetch the tool list.
795
795
 
796
- The property is named `toolActions` because `tools()` is the method that returns the registered tool registry.
796
+ The property is `toolActions` because `tools()` is the method that returns the registered tool registry.
797
797
 
798
798
  ### `toolActions.add(tools)`
799
799
 
@@ -821,7 +821,7 @@ await server.toolActions.add({ searchTool })
821
821
 
822
822
  ### `toolActions.remove(toolIds)`
823
823
 
824
- Removes tools from the running server by tool ID and notifies connected clients. Unknown tool IDs are ignored. If no tools were removed, no notification is sent.
824
+ Removes tools from the running server by tool ID and notifies connected clients. Unknown tool IDs are ignored. A notification is sent only when at least one tool is removed.
825
825
 
826
826
  ```typescript
827
827
  async server.toolActions.remove(toolIds: string[]): Promise<void>
@@ -847,7 +847,7 @@ When the server is registered with a Mastra instance, `toolActions.add()` and `t
847
847
 
848
848
  ## Logging
849
849
 
850
- MCP servers can send structured log messages to clients using `notifications/message`. Clients control verbosity by sending a `logging/setLevel` request; the server drops messages below the requested minimum level (following RFC 5424 severity ordering). The level is tracked per session, so different clients can request different verbosity.
850
+ MCP servers can send structured log messages to clients using `notifications/message`. Clients control verbosity by sending a `logging/setLevel` request. The server drops messages below the requested minimum level (following RFC 5424 severity ordering). The level is tracked per session, so different clients can request different verbosity.
851
851
 
852
852
  ### `sendLoggingMessage()`
853
853
 
@@ -937,7 +937,7 @@ The example at the beginning of this page also demonstrates how to instantiate `
937
937
 
938
938
  ### What's Elicitation?
939
939
 
940
- Elicitation is a feature in the Model Context Protocol (MCP) that allows servers to request structured information from users. This enables interactive workflows where servers can collect additional data dynamically.
940
+ Elicitation is a feature in the Model Context Protocol (MCP) that allows servers to request structured information from users. It supports interactive workflows where servers can collect additional data at runtime.
941
941
 
942
942
  The `MCPServer` class automatically includes elicitation capabilities. Tools receive a `context.mcp` object in their `execute` function that includes an `elicitation.sendRequest()` method for requesting user input.
943
943
 
@@ -1126,7 +1126,7 @@ execute: async (inputData, context) => {
1126
1126
  }
1127
1127
  ```
1128
1128
 
1129
- Note that elicitation is **session-aware** when using HTTP-based transports (SSE or HTTP). This means that when multiple clients are connected to the same server, elicitation requests are routed to the correct client session that initiated the tool execution.
1129
+ Elicitation is **session-aware** when using HTTP-based transports (SSE or HTTP). When multiple clients are connected to the same server, elicitation requests are routed to the client session that initiated the tool execution.
1130
1130
 
1131
1131
  The `ElicitResult` type:
1132
1132