@mastra/mcp-docs-server 1.2.7 → 1.2.8-alpha.17

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 (147) hide show
  1. package/.docs/docs/agent-builder/deploying.md +1 -0
  2. package/.docs/docs/agent-builder/integrations.md +1 -3
  3. package/.docs/docs/agent-builder/overview.md +1 -1
  4. package/.docs/docs/agent-controller/overview.md +1 -1
  5. package/.docs/docs/agents/overview.md +17 -13
  6. package/.docs/docs/agents/skills.md +1 -3
  7. package/.docs/docs/agents/structured-output.md +14 -7
  8. package/.docs/docs/agents/using-tools.md +80 -26
  9. package/.docs/docs/browser/agent-browser.md +1 -0
  10. package/.docs/docs/browser/firecrawl.md +129 -0
  11. package/.docs/docs/browser/overview.md +16 -2
  12. package/.docs/docs/capabilities/channels/other-adapters.md +1 -1
  13. package/.docs/docs/capabilities/channels/overview.md +1 -0
  14. package/.docs/docs/capabilities/channels/slack.md +113 -3
  15. package/.docs/docs/deployment/mastra-server.md +35 -0
  16. package/.docs/docs/deployment/monorepo.md +2 -0
  17. package/.docs/docs/deployment/overview.md +6 -0
  18. package/.docs/docs/deployment/sandbox.md +277 -0
  19. package/.docs/docs/editor/overview.md +2 -6
  20. package/.docs/docs/editor/tools.md +2 -6
  21. package/.docs/docs/evals/multi-turn.md +178 -0
  22. package/.docs/docs/evals/overview.md +1 -0
  23. package/.docs/docs/evals/running-in-ci.md +3 -9
  24. package/.docs/docs/getting-started/file-based-agents.md +2 -2
  25. package/.docs/docs/index.md +17 -13
  26. package/.docs/docs/long-running-agents/background-tasks.md +2 -2
  27. package/.docs/docs/long-running-agents/durable-agents.md +2 -1
  28. package/.docs/docs/long-running-agents/schedules.md +2 -2
  29. package/.docs/docs/mastra-platform/database.md +13 -6
  30. package/.docs/docs/mastra-platform/deploy.md +17 -8
  31. package/.docs/docs/mastra-platform/environments.md +5 -4
  32. package/.docs/docs/mastra-platform/regions.md +73 -0
  33. package/.docs/docs/mcp/overview.md +1 -1
  34. package/.docs/docs/memory/multi-user-threads.md +4 -4
  35. package/.docs/docs/memory/observational-memory.md +78 -3
  36. package/.docs/docs/memory/overview.md +4 -0
  37. package/.docs/docs/memory/working-memory.md +1 -1
  38. package/.docs/docs/observability/integrations/bridges/otel.md +1 -3
  39. package/.docs/docs/observability/integrations/exporters/braintrust.md +34 -2
  40. package/.docs/docs/observability/integrations/exporters/otel.md +1 -3
  41. package/.docs/docs/server/auth/simple-auth.md +1 -3
  42. package/.docs/docs/server/request-context.md +2 -0
  43. package/.docs/docs/studio/overview.md +2 -0
  44. package/.docs/docs/voice/livekit.md +1 -1
  45. package/.docs/docs/workflows/control-flow.md +1 -3
  46. package/.docs/guides/build-your-ui/ai-sdk-ui.md +1 -0
  47. package/.docs/guides/guide/signal-provider.md +2 -0
  48. package/.docs/guides/migrations/vnext-to-standard-apis.md +1 -3
  49. package/.docs/models/environment-variables.md +1 -0
  50. package/.docs/models/gateways/openrouter.md +339 -345
  51. package/.docs/models/gateways/vercel.md +6 -5
  52. package/.docs/models/index.md +1 -1
  53. package/.docs/models/providers/ambient.md +12 -10
  54. package/.docs/models/providers/baseten.md +3 -2
  55. package/.docs/models/providers/crossmodel.md +2 -1
  56. package/.docs/models/providers/deepinfra.md +4 -7
  57. package/.docs/models/providers/empiriolabs.md +2 -1
  58. package/.docs/models/providers/evroc.md +3 -2
  59. package/.docs/models/providers/google.md +2 -2
  60. package/.docs/models/providers/kilo.md +1 -1
  61. package/.docs/models/providers/kimi-for-coding.md +10 -11
  62. package/.docs/models/providers/llmgateway.md +3 -8
  63. package/.docs/models/providers/moonshotai-cn.md +3 -2
  64. package/.docs/models/providers/moonshotai.md +3 -2
  65. package/.docs/models/providers/nebius.md +3 -1
  66. package/.docs/models/providers/ollama-cloud.md +25 -42
  67. package/.docs/models/providers/opencode-go.md +5 -3
  68. package/.docs/models/providers/orcarouter.md +1 -1
  69. package/.docs/models/providers/privatemode-ai.md +10 -10
  70. package/.docs/models/providers/thinkingmachines.md +73 -0
  71. package/.docs/models/providers/togetherai.md +2 -6
  72. package/.docs/models/providers/zenmux.md +2 -1
  73. package/.docs/models/providers.md +1 -0
  74. package/.docs/reference/acp/acp-agent.md +2 -0
  75. package/.docs/reference/acp/create-acp-tool.md +28 -0
  76. package/.docs/reference/agent-controller/agent-controller-class.md +1 -1
  77. package/.docs/reference/agent-controller/session.md +15 -0
  78. package/.docs/reference/agents/agent.md +14 -2
  79. package/.docs/reference/agents/durable-agent.md +23 -0
  80. package/.docs/reference/agents/generate.md +19 -1
  81. package/.docs/reference/browser/firecrawl-browser.md +71 -0
  82. package/.docs/reference/cli/mastra.md +14 -6
  83. package/.docs/reference/code-sdk/mount-agent-controller.md +1 -3
  84. package/.docs/reference/core/getMCPServer.md +1 -3
  85. package/.docs/reference/core/getMCPServerById.md +1 -3
  86. package/.docs/reference/core/getTool.md +33 -0
  87. package/.docs/reference/core/getToolById.md +48 -0
  88. package/.docs/reference/core/getWorkflow.md +1 -3
  89. package/.docs/reference/core/listMCPServers.md +2 -6
  90. package/.docs/reference/core/listTools.md +38 -0
  91. package/.docs/reference/core/mastra-class.md +1 -1
  92. package/.docs/reference/datasets/addItem.md +1 -3
  93. package/.docs/reference/datasets/addItems.md +1 -3
  94. package/.docs/reference/datasets/compareExperiments.md +1 -3
  95. package/.docs/reference/datasets/create.md +1 -3
  96. package/.docs/reference/datasets/dataset.md +2 -6
  97. package/.docs/reference/datasets/datasets-manager.md +5 -15
  98. package/.docs/reference/datasets/delete.md +1 -3
  99. package/.docs/reference/datasets/deleteExperiment.md +1 -3
  100. package/.docs/reference/datasets/deleteItem.md +1 -3
  101. package/.docs/reference/datasets/deleteItems.md +1 -3
  102. package/.docs/reference/datasets/get.md +1 -3
  103. package/.docs/reference/datasets/getDetails.md +1 -3
  104. package/.docs/reference/datasets/getExperiment.md +1 -3
  105. package/.docs/reference/datasets/getItem.md +1 -3
  106. package/.docs/reference/datasets/getItemHistory.md +1 -3
  107. package/.docs/reference/datasets/list.md +1 -3
  108. package/.docs/reference/datasets/listExperimentResults.md +1 -3
  109. package/.docs/reference/datasets/listExperiments.md +1 -3
  110. package/.docs/reference/datasets/listItems.md +1 -3
  111. package/.docs/reference/datasets/listVersions.md +1 -3
  112. package/.docs/reference/datasets/startExperiment.md +1 -3
  113. package/.docs/reference/datasets/startExperimentAsync.md +1 -3
  114. package/.docs/reference/datasets/update.md +1 -3
  115. package/.docs/reference/datasets/updateItem.md +1 -3
  116. package/.docs/reference/editor/mastra-editor.md +1 -3
  117. package/.docs/reference/evals/create-scorer.md +4 -10
  118. package/.docs/reference/evals/mastra-scorer.md +1 -3
  119. package/.docs/reference/evals/run-evals.md +94 -2
  120. package/.docs/reference/file-based-agents/logger.md +1 -1
  121. package/.docs/reference/file-based-agents/tools.md +7 -6
  122. package/.docs/reference/index.md +5 -0
  123. package/.docs/reference/memory/observational-memory.md +21 -0
  124. package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +1 -3
  125. package/.docs/reference/processors/token-limiter-processor.md +1 -3
  126. package/.docs/reference/rag/database-config.md +12 -0
  127. package/.docs/reference/storage/clickhouse.md +1 -1
  128. package/.docs/reference/storage/convex.md +17 -10
  129. package/.docs/reference/storage/retention.md +1 -1
  130. package/.docs/reference/streaming/agents/stream.md +3 -1
  131. package/.docs/reference/tools/create-tool.md +78 -52
  132. package/.docs/reference/tools/mcp-client.md +104 -24
  133. package/.docs/reference/tools/mcp-server.md +143 -44
  134. package/.docs/reference/tools/task-tools.md +2 -2
  135. package/.docs/reference/tools/tavily.md +1 -1
  136. package/.docs/reference/tools/vector-query-tool.md +22 -0
  137. package/.docs/reference/vectors/mongodb.md +2 -0
  138. package/.docs/reference/vectors/turbopuffer.md +4 -0
  139. package/.docs/reference/voice/mistral.md +127 -0
  140. package/.docs/reference/workspace/daytona-sandbox.md +2 -6
  141. package/CHANGELOG.md +64 -0
  142. package/dist/{chunk-GLPCVXXO.js → chunk-HGADBLKG.js} +2 -2
  143. package/dist/{chunk-GLPCVXXO.js.map → chunk-HGADBLKG.js.map} +1 -1
  144. package/dist/index.js +1 -1
  145. package/dist/stdio.js +1 -1
  146. package/dist/tools/docs.d.ts.map +1 -1
  147. package/package.json +7 -7
@@ -29,6 +29,7 @@ import { LibSQLStore } from '@mastra/libsql'
29
29
 
30
30
  new Mastra({
31
31
  storage: new LibSQLStore({
32
+ id: 'mastra-storage',
32
33
  url: process.env.DATABASE_URL!,
33
34
  authToken: process.env.DATABASE_AUTH_TOKEN,
34
35
  }),
@@ -37,9 +37,7 @@ import { MastraEditor } from '@mastra/editor'
37
37
  import { ComposioToolProvider } from '@mastra/editor/composio'
38
38
 
39
39
  export const mastra = new Mastra({
40
- agents: {
41
- /* your agents */
42
- },
40
+ agents: {/* your agents */},
43
41
  editor: new MastraEditor({
44
42
  toolProviders: {
45
43
  composio: new ComposioToolProvider({
@@ -67,7 +67,7 @@ import { createBuilderAgent } from '@mastra/editor/ee'
67
67
  import { LibSQLStore } from '@mastra/libsql'
68
68
 
69
69
  export const mastra = new Mastra({
70
- storage: new LibSQLStore({ url: 'file:./mastra.db' }),
70
+ storage: new LibSQLStore({ id: 'mastra-storage', url: 'file:./mastra.db' }),
71
71
  agents: { builderAgent: createBuilderAgent() },
72
72
  editor: new MastraEditor({
73
73
  builder: {
@@ -65,7 +65,7 @@ const agent = new Agent({
65
65
  const agentController = new AgentController({
66
66
  id: 'my-agent',
67
67
  agent,
68
- storage: new LibSQLStore({ url: 'file:./data.db' }),
68
+ storage: new LibSQLStore({ id: 'agent-storage', url: 'file:./data.db' }),
69
69
  modes: [
70
70
  {
71
71
  id: 'plan',
@@ -44,17 +44,31 @@ export const weatherTool = createTool({
44
44
  location: z.string().describe('City name'),
45
45
  }),
46
46
  outputSchema: z.object({
47
- output: z.string(),
47
+ location: z.string(),
48
+ temperatureCelsius: z.number(),
49
+ conditions: z.string(),
48
50
  }),
49
51
  execute: async ({ location }) => {
50
52
  return {
51
- output: `The weather in ${location} is sunny`,
53
+ location,
54
+ temperatureCelsius: 21,
55
+ conditions: 'sunny',
52
56
  }
53
57
  },
54
58
  })
55
59
  ```
56
60
 
57
- If you need to create an agent, create a new file and use `import { Agent } from "@mastra/core/agent"`. The constructor takes `{ id, name, instructions, model }`. The `model` property is a string in Mastra's model router format: `provider/model`, for example `openai/gpt-5.5`. For OpenAI models, use `openai/<model>`, not `openai:<model>`, and don't pass a provider object. No provider import is needed for this format. Don't install any AI SDK package unless Mastra's documentation says otherwise.
61
+ If you need to create an agent, create a new file and use `import { Agent } from "@mastra/core/agent"`. The constructor takes `{ id, name, instructions, model }`. The `model` property is a string in Mastra's model router format. No provider import is needed for this format. Don't install any AI SDK package unless Mastra's documentation says otherwise.
62
+
63
+ By defining the model using `provider/model` format Mastra automatically looks for environment variables for the given provider. The defined model requires an environment variable to be set for the provider. OpenAI: `OPENAI_API_KEY`. Anthropic: `ANTHROPIC_API_KEY`. Google: `GOOGLE_API_KEY`. Example: Any `openai/<model>` requires the `OPENAI_API_KEY` environment variable. Go to <https://mastra.ai/models/environment-variables> for a full list of supported providers and their environment variable names.
64
+
65
+ Short list of known model IDs are:
66
+
67
+ - `openai/gpt-5.5`, `openai/gpt-5-mini`
68
+ - `anthropic/claude-sonnet-4-6`, `anthropic/claude-opus-4-7`, `anthropic/claude-haiku-4-5`
69
+ - `google/gemini-2.5-flash`
70
+
71
+ Go to <https://mastra.ai/models> for a full list of supported models.
58
72
 
59
73
  Add a tool an agent by importing the tool and passing it to the agent constructor as a tools object.
60
74
 
@@ -83,16 +97,6 @@ export const weatherAgent = new Agent({
83
97
  })
84
98
  ```
85
99
 
86
- By defining the model using `provider/model` format Mastra automatically looks for environment variables for the given provider. The defined model requires an environment variable to be set for the provider. OpenAI: `OPENAI_API_KEY`. Anthropic: `ANTHROPIC_API_KEY`. Google: `GOOGLE_API_KEY`. Example: Any `openai/<model>` requires the `OPENAI_API_KEY` environment variable. Go to <https://mastra.ai/models/environment-variables> for a full list of supported providers and their environment variable names.
87
-
88
- Short list of known model IDs are:
89
-
90
- - `openai/gpt-5.5`, `openai/gpt-5-mini`
91
- - `anthropic/claude-sonnet-4-6`, `anthropic/claude-opus-4-7`, `anthropic/claude-haiku-4-5`
92
- - `google/gemini-2.5-flash`
93
-
94
- Go to <https://mastra.ai/models> for a full list of supported models.
95
-
96
100
  Create a Mastra entry point at `src/mastra/index.ts` and register the agent:
97
101
 
98
102
  ```ts
@@ -85,9 +85,7 @@ export const agent = new Agent({
85
85
  skills: [
86
86
  './skills/code-review', // path to a SKILL.md directory
87
87
  './skills/testing', // another filesystem skill
88
- createSkill({
89
- /* ... */
90
- }), // inline skill
88
+ createSkill({/* ... */}), // inline skill
91
89
  ],
92
90
  })
93
91
  ```
@@ -197,9 +197,9 @@ If your tools aren't being called when structured output is enabled, or you rece
197
197
 
198
198
  When your model doesn't support tools and structured output together, you have three options:
199
199
 
200
- 1. **Use `jsonPromptInjection: true`** - Injects the schema into the prompt instead of using the API's `response_format` parameter
201
- 2. **Use a separate structuring model** - Pass a `model` to `structuredOutput` to use a second LLM for structuring
202
- 3. **Use `prepareStep`** - Handle tools and structured output in separate steps
200
+ 1. **Use `jsonPromptInjection`**: Set it to `'auto'` to select native structured output when supported and inline prompt injection otherwise, or choose an explicit injection mode
201
+ 2. **Use a separate structuring model**: Pass a `model` to `structuredOutput` to use a second LLM for structuring
202
+ 3. **Use `prepareStep`**: Handle tools and structured output in separate steps
203
203
 
204
204
  Each approach is detailed in the sections below.
205
205
 
@@ -209,9 +209,7 @@ Structured output support varies across LLMs due to differences in their APIs. T
209
209
 
210
210
  ### `jsonPromptInjection`
211
211
 
212
- By default, Mastra passes the schema to the model provider using the `response_format` API parameter. Most model providers have built-in support for this, which reliably enforces the schema.
213
-
214
- If your model provider doesn't support `response_format`, you'll get an error from the API. When this happens, set `jsonPromptInjection: true`. This adds the schema to the system prompt instead, instructing the model to output JSON. This is less reliable than the API parameter approach.
212
+ By default, Mastra passes the schema to the model provider using the `response_format` API parameter. Set `jsonPromptInjection: 'auto'` to let Mastra choose the mode from its model capability data. Mastra uses native structured output for supported models and inline prompt injection for unsupported models or models without capability data.
215
213
 
216
214
  ```typescript
217
215
  import { z } from 'zod'
@@ -224,13 +222,20 @@ const response = await testAgent.generate('Help me plan my day.', {
224
222
  activities: z.array(z.string()),
225
223
  }),
226
224
  ),
227
- jsonPromptInjection: true,
225
+ jsonPromptInjection: 'auto',
228
226
  },
229
227
  })
230
228
 
231
229
  console.log(response.object)
232
230
  ```
233
231
 
232
+ Use an explicit mode when you need to override the capability-based choice:
233
+
234
+ - `false` or omitted: Use the provider's native structured output.
235
+ - `'inline'`: Add the schema instructions to the latest user message.
236
+ - `true` or `'system'`: Add the schema instructions to the system message.
237
+ - `'auto'`: Use native structured output when the model supports it. Otherwise, use inline prompt injection.
238
+
234
239
  > **Gemini 2.5 with tools:** Gemini 2.5 models don't support combining `response_format` (structured output) with function calling (tools) in the same API call. If your agent has tools and you're using `structuredOutput` with a Gemini 2.5 model, you must set `jsonPromptInjection: true` to avoid the error `Function calling with a response mime type: 'application/json' is unsupported`.
235
240
  >
236
241
  > ```typescript
@@ -246,6 +251,8 @@ console.log(response.object)
246
251
 
247
252
  When `model` is provided to the `structuredOutput` property, Mastra uses a separate internal agent to handle the structured output. The main agent will handle all of the steps (including tool calling) and the structured output model will handle only the generation of structured output.
248
253
 
254
+ **For AI agents:** The `model` property is a string in Mastra's model router format: `provider/model`, for example `openai/gpt-5.5`, `openai/gpt-5-mini`, `anthropic/claude-sonnet-4-6` or `google/gemini-2.5-pro`. Use `/` and not `:` as a separator. Example: `openai/<model>`, not `openai:<model>`, and don't pass a provider object. No provider import is needed for this format. Don't install any AI SDK package unless Mastra's documentation says otherwise. By defining the model using `provider/model` format Mastra automatically looks for environment variables for the given provider. The defined model requires an environment variable to be set for the provider. OpenAI: `OPENAI_API_KEY`. Anthropic: `ANTHROPIC_API_KEY`. Google: `GOOGLE_API_KEY`.
255
+
249
256
  ```typescript
250
257
  const response = await testAgent.generate('Tell me about TypeScript.', {
251
258
  structuredOutput: {
@@ -14,7 +14,7 @@ Use tools when an agent needs additional context or information from remote reso
14
14
 
15
15
  Import [`createTool`](https://mastra.ai/reference/tools/create-tool) from `@mastra/core/tools` and define a tool with an `id`, `description`, `inputSchema`, `outputSchema`, and `execute` function.
16
16
 
17
- This example shows how to create a tool that fetches weather data from an API. When the agent calls the tool, it provides the required input as defined by the tool's `inputSchema`. The tool accesses this data through its `inputData` parameter, which in this example includes the `location` used in the weather API query.
17
+ This example creates a tool that fetches weather data from an API. The `execute` function receives input validated against `inputSchema` as its first argument and an optional execution context as its second. You can destructure the input fields directly in the function signature.
18
18
 
19
19
  ```typescript
20
20
  import { createTool } from '@mastra/core/tools'
@@ -27,15 +27,21 @@ export const weatherTool = createTool({
27
27
  location: z.string(),
28
28
  }),
29
29
  outputSchema: z.object({
30
- weather: z.string(),
30
+ location: z.string(),
31
+ temperatureCelsius: z.number(),
32
+ conditions: z.string(),
31
33
  }),
32
- execute: async inputData => {
33
- const { location } = inputData
34
-
35
- const response = await fetch(`https://wttr.in/${location}?format=3`)
36
- const weather = await response.text()
34
+ execute: async ({ location }, { abortSignal }) => {
35
+ const response = await fetch(`https://wttr.in/${location}?format=j1`, {
36
+ signal: abortSignal,
37
+ })
38
+ const data = await response.json()
37
39
 
38
- return { weather }
40
+ return {
41
+ location,
42
+ temperatureCelsius: Number(data.current_condition[0].temp_C),
43
+ conditions: data.current_condition[0].weatherDesc[0].value,
44
+ }
39
45
  },
40
46
  })
41
47
  ```
@@ -76,10 +82,12 @@ export const weatherTool = createTool({
76
82
  location: z.string(),
77
83
  }),
78
84
  outputSchema: z.object({
79
- weather: z.string(),
85
+ location: z.string(),
86
+ temperatureCelsius: z.number(),
87
+ conditions: z.string(),
80
88
  }),
81
- execute: async inputData => {
82
- // Fetch weather data
89
+ execute: async ({ location }) => {
90
+ return { location, temperatureCelsius: 21, conditions: 'sunny' }
83
91
  },
84
92
  })
85
93
  ```
@@ -101,11 +109,13 @@ export const weatherTool = createTool({
101
109
  ),
102
110
  outputSchema: toStandardJsonSchema(
103
111
  v.object({
104
- weather: v.string(),
112
+ location: v.string(),
113
+ temperatureCelsius: v.number(),
114
+ conditions: v.string(),
105
115
  }),
106
116
  ),
107
- execute: async inputData => {
108
- // Fetch weather data
117
+ execute: async ({ location }) => {
118
+ return { location, temperatureCelsius: 21, conditions: 'sunny' }
109
119
  },
110
120
  })
111
121
  ```
@@ -123,10 +133,12 @@ export const weatherTool = createTool({
123
133
  location: 'string',
124
134
  }),
125
135
  outputSchema: type({
126
- weather: 'string',
136
+ location: 'string',
137
+ temperatureCelsius: 'number',
138
+ conditions: 'string',
127
139
  }),
128
- execute: async inputData => {
129
- // Fetch weather data
140
+ execute: async ({ location }) => {
141
+ return { location, temperatureCelsius: 21, conditions: 'sunny' }
130
142
  },
131
143
  })
132
144
  ```
@@ -193,6 +205,47 @@ export const researchAgent = new Agent({
193
205
  })
194
206
  ```
195
207
 
208
+ ## Share tools across agents
209
+
210
+ Direct imports are the best choice when one tool is used by multiple agents. Each agent imports the tool and adds it to its `tools` record. Dependencies remain explicit and each agent can be used independently.
211
+
212
+ ```typescript
213
+ import { createTool } from '@mastra/core/tools'
214
+
215
+ export const weatherTool = createTool({
216
+ id: 'weather-tool',
217
+ // Rest of the tool definition...
218
+ })
219
+ ```
220
+
221
+ ```typescript
222
+ import { Agent } from '@mastra/core/agent'
223
+ import { weatherTool } from '../tools/weather-tool'
224
+
225
+ export const weatherAgent = new Agent({
226
+ id: 'weather-agent',
227
+ name: 'Weather Agent',
228
+ instructions: 'Answer questions about current weather.',
229
+ model: 'openai/gpt-5.5',
230
+ tools: { weatherTool },
231
+ })
232
+ ```
233
+
234
+ ```typescript
235
+ import { Agent } from '@mastra/core/agent'
236
+ import { weatherTool } from '../tools/weather-tool'
237
+
238
+ export const travelAgent = new Agent({
239
+ id: 'travel-agent',
240
+ name: 'Travel Agent',
241
+ instructions: 'Help users plan trips.',
242
+ model: 'openai/gpt-5.5',
243
+ tools: { weatherTool },
244
+ })
245
+ ```
246
+
247
+ If you need to access tools from the Mastra instance, see [`Mastra.getTool()`](https://mastra.ai/reference/core/getTool), [`Mastra.getToolById()`](https://mastra.ai/reference/core/getToolById), [`Mastra.listTools()`](https://mastra.ai/reference/core/listTools), and the [`Agent` reference](https://mastra.ai/reference/agents/agent).
248
+
196
249
  ## Shape output for the model
197
250
 
198
251
  Use `toModelOutput` when your tool returns rich structured data for your application, but you want the model to receive a smaller or multimodal representation. This keeps model context focused while preserving the full tool result in your app.
@@ -205,8 +258,8 @@ export const weatherTool = createTool({
205
258
 
206
259
  return {
207
260
  location,
208
- temperature: data.current_condition[0].temp_F,
209
- condition: data.current_condition[0].weatherDesc[0].value,
261
+ temperatureCelsius: Number(data.current_condition[0].temp_C),
262
+ conditions: data.current_condition[0].weatherDesc[0].value,
210
263
  weatherIconUrl: data.current_condition[0].weatherIconUrl[0].value,
211
264
  source: data,
212
265
  }
@@ -217,7 +270,7 @@ export const weatherTool = createTool({
217
270
  value: [
218
271
  {
219
272
  type: 'text',
220
- text: `${output.location}: ${output.temperature}F and ${output.condition}`,
273
+ text: `${output.location}: ${output.temperatureCelsius}°C and ${output.conditions}`,
221
274
  },
222
275
  { type: 'image-url', url: output.weatherIconUrl },
223
276
  ],
@@ -321,23 +374,24 @@ export const weatherTool = createTool({
321
374
  id: 'weather-tool',
322
375
  description: 'Get weather information',
323
376
  inputSchema: z.object({
324
- city: z.string(),
377
+ location: z.string(),
325
378
  }),
326
379
  outputSchema: z.object({
327
- temperature: z.number(),
380
+ location: z.string(),
381
+ temperatureCelsius: z.number(),
328
382
  conditions: z.string(),
329
383
  }),
330
384
  // Called when the complete input is available
331
385
  onInputAvailable: ({ input, toolCallId }) => {
332
- console.log(`Weather requested for: ${input.city}`)
386
+ console.log(`Weather requested for: ${input.location}`)
333
387
  },
334
- execute: async input => {
335
- const weather = await fetchWeather(input.city)
388
+ execute: async ({ location }) => {
389
+ const weather = await fetchWeather(location)
336
390
  return weather
337
391
  },
338
392
  // Called after successful execution
339
393
  onOutput: ({ output, toolName }) => {
340
- console.log(`${toolName} result: ${output.temperatureF, ${output.conditions}`)
394
+ console.log(`${toolName} result: ${output.temperatureCelsiusC, ${output.conditions}`)
341
395
  },
342
396
  })
343
397
  ```
@@ -105,5 +105,6 @@ This adds `browser_record` and `browser_record_caption` to the agent's toolset.
105
105
 
106
106
  - [Browser overview](https://mastra.ai/docs/browser/overview)
107
107
  - [Stagehand](https://mastra.ai/docs/browser/stagehand)
108
+ - [Firecrawl](https://mastra.ai/docs/browser/firecrawl)
108
109
  - [Browser recording (alpha)](https://mastra.ai/docs/browser/recording)
109
110
  - [AgentBrowser reference](https://mastra.ai/reference/browser/agent-browser)
@@ -0,0 +1,129 @@
1
+ > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
+
3
+ # Firecrawl
4
+
5
+ The `@mastra/browser-firecrawl` package provides browser automation using the [Firecrawl Browser Sandbox](https://docs.firecrawl.dev/features/browser). It provisions remote browser sessions through the Firecrawl API and drives them with the same deterministic, accessibility-first tools as [AgentBrowser](https://mastra.ai/docs/browser/agent-browser).
6
+
7
+ `FirecrawlBrowser` extends `AgentBrowser`, so agents get the same toolset (`browser_goto`, `browser_snapshot`, `browser_click`, and so on) while the browser itself runs in Firecrawl's hosted infrastructure. No local Chromium install is needed.
8
+
9
+ ## When to use Firecrawl
10
+
11
+ Use Firecrawl when you need:
12
+
13
+ - Hosted browser sessions without managing local Chromium binaries
14
+ - Browser automation in environments that can't launch a local browser
15
+ - Per-thread sandbox isolation with automatic session cleanup
16
+ - Named Firecrawl profiles that persist cookies and login state between sessions
17
+
18
+ ## Quickstart
19
+
20
+ Install the package:
21
+
22
+ **npm**:
23
+
24
+ ```bash
25
+ npm install @mastra/browser-firecrawl
26
+ ```
27
+
28
+ **pnpm**:
29
+
30
+ ```bash
31
+ pnpm add @mastra/browser-firecrawl
32
+ ```
33
+
34
+ **Yarn**:
35
+
36
+ ```bash
37
+ yarn add @mastra/browser-firecrawl
38
+ ```
39
+
40
+ **Bun**:
41
+
42
+ ```bash
43
+ bun add @mastra/browser-firecrawl
44
+ ```
45
+
46
+ Set your Firecrawl API key:
47
+
48
+ ```bash
49
+ FIRECRAWL_API_KEY=fc-...
50
+ ```
51
+
52
+ Create a browser instance and assign it to an agent:
53
+
54
+ ```typescript
55
+ import { Agent } from '@mastra/core/agent'
56
+ import { FirecrawlBrowser } from '@mastra/browser-firecrawl'
57
+
58
+ const browser = new FirecrawlBrowser({
59
+ apiKey: process.env.FIRECRAWL_API_KEY,
60
+ })
61
+
62
+ export const firecrawlAgent = new Agent({
63
+ id: 'firecrawl-agent',
64
+ name: 'Firecrawl Agent',
65
+ model: 'openai/gpt-5.5',
66
+ browser,
67
+ instructions: `You are a web automation assistant.
68
+
69
+ When interacting with pages:
70
+ 1. Use browser_snapshot to get the current page state and element refs
71
+ 2. Use the refs (like @e1, @e2) to target elements for clicks and typing
72
+ 3. After actions, take another snapshot to verify the result`,
73
+ })
74
+ ```
75
+
76
+ If `apiKey` is omitted, the provider reads `FIRECRAWL_API_KEY` from the environment.
77
+
78
+ ## Session scope
79
+
80
+ `FirecrawlBrowser` follows the same `scope` option as `AgentBrowser`:
81
+
82
+ - `'thread'` (default): Each conversation thread gets its own Firecrawl sandbox session. Sessions are deleted when the thread's browser closes.
83
+ - `'shared'`: One Firecrawl sandbox session is shared across all threads and deleted when the browser closes.
84
+
85
+ ```typescript
86
+ const browser = new FirecrawlBrowser({
87
+ scope: 'shared',
88
+ })
89
+ ```
90
+
91
+ ## Session options
92
+
93
+ Pass Firecrawl-specific session options under the `firecrawl` key. These map to the Firecrawl `browser()` API:
94
+
95
+ ```typescript
96
+ const browser = new FirecrawlBrowser({
97
+ firecrawl: {
98
+ ttl: 600,
99
+ activityTtl: 120,
100
+ profile: {
101
+ name: 'my-profile',
102
+ saveChanges: true,
103
+ },
104
+ },
105
+ })
106
+ ```
107
+
108
+ - `ttl`: Maximum session lifetime in seconds.
109
+ - `activityTtl`: Idle timeout in seconds before Firecrawl recycles the session.
110
+ - `profile`: Named Firecrawl profile that persists cookies and login state. Set `saveChanges: true` to save profile changes when the session ends.
111
+
112
+ > **Note:** The nested `firecrawl.profile` option refers to a profile stored in Firecrawl's infrastructure. It's different from the top-level `profile` option inherited from `AgentBrowser`, which is a local Playwright user-data directory path.
113
+
114
+ ## Self-hosted Firecrawl
115
+
116
+ To use a self-hosted Firecrawl API, set `apiUrl`:
117
+
118
+ ```typescript
119
+ const browser = new FirecrawlBrowser({
120
+ apiUrl: 'https://firecrawl.internal.example.com',
121
+ })
122
+ ```
123
+
124
+ ## Related
125
+
126
+ - [Browser overview](https://mastra.ai/docs/browser/overview)
127
+ - [AgentBrowser](https://mastra.ai/docs/browser/agent-browser)
128
+ - [Browser recording (alpha)](https://mastra.ai/docs/browser/recording)
129
+ - [FirecrawlBrowser reference](https://mastra.ai/reference/browser/firecrawl-browser)
@@ -4,10 +4,11 @@
4
4
 
5
5
  Browser support enables agents to navigate websites, interact with page elements, fill forms, and extract data. Mastra provides browser capabilities through SDK providers that wrap browser automation libraries and a CLI provider for agents that drive browsers through command-line tools.
6
6
 
7
- Mastra supports two SDK providers and one CLI provider:
7
+ Mastra supports three SDK providers and one CLI provider:
8
8
 
9
9
  - [**AgentBrowser**](https://mastra.ai/docs/browser/agent-browser): A Playwright-based provider with accessibility-first element targeting. Best for general web automation and scraping.
10
10
  - [**Stagehand**](https://mastra.ai/docs/browser/stagehand): A Browserbase provider with AI-powered element detection. Best for complex interactions that benefit from natural language selectors.
11
+ - [**FirecrawlBrowser**](https://mastra.ai/docs/browser/firecrawl): A Firecrawl Browser Sandbox provider that runs AgentBrowser tools against hosted browser sessions. Best for running automation on hosted browser sessions without managing local browser infrastructure.
11
12
  - [**BrowserViewer**](https://mastra.ai/docs/browser/browser-viewer): A CLI provider that launches Chrome and injects CDP URLs into CLI tools like agent-browser, browser-use, and browse. Best for workspace agents that drive browsers through shell commands.
12
13
  - [**Browser recording (alpha)**](https://mastra.ai/docs/browser/recording): An opt-in tool layer that saves browser sessions as Motion-JPEG AVI videos with optional captions.
13
14
 
@@ -86,7 +87,19 @@ The agent automatically receives all browser tools from the provider.
86
87
 
87
88
  ## Cloud providers
88
89
 
89
- Both SDK providers support connecting to cloud browser services instead of launching a local browser.
90
+ All SDK providers support connecting to cloud browser services instead of launching a local browser.
91
+
92
+ ### Firecrawl Browser Sandbox (FirecrawlBrowser native)
93
+
94
+ FirecrawlBrowser provisions hosted sessions through the Firecrawl API:
95
+
96
+ ```typescript
97
+ import { FirecrawlBrowser } from '@mastra/browser-firecrawl'
98
+
99
+ const browser = new FirecrawlBrowser({
100
+ apiKey: process.env.FIRECRAWL_API_KEY,
101
+ })
102
+ ```
90
103
 
91
104
  ### Browserbase (Stagehand native)
92
105
 
@@ -167,6 +180,7 @@ const browser = new AgentBrowser({
167
180
 
168
181
  - [AgentBrowser](https://mastra.ai/docs/browser/agent-browser)
169
182
  - [Stagehand](https://mastra.ai/docs/browser/stagehand)
183
+ - [Firecrawl](https://mastra.ai/docs/browser/firecrawl)
170
184
  - [Browser recording (alpha)](https://mastra.ai/docs/browser/recording)
171
185
  - [BrowserViewer](https://mastra.ai/docs/browser/browser-viewer)
172
186
  - [MastraBrowser reference](https://mastra.ai/reference/browser/mastra-browser)
@@ -2,7 +2,7 @@
2
2
 
3
3
  # More
4
4
 
5
- Mastra channels use Chat SDK adapters, so the pages in this section are not the full list of supported platforms. Use any Chat SDK platform adapter that exports an adapter factory compatible with `channels.adapters`.
5
+ Mastra channels use Chat SDK adapters, so the pages in this section aren't the full list of supported platforms. Use any Chat SDK platform adapter that exports an adapter factory compatible with `channels.adapters`.
6
6
 
7
7
  ## Adapter catalog
8
8
 
@@ -58,6 +58,7 @@ import { yourAgent } from './agents/your-agent'
58
58
  export const mastra = new Mastra({
59
59
  agents: { yourAgent },
60
60
  storage: new LibSQLStore({
61
+ id: 'mastra-storage',
61
62
  url: process.env.DATABASE_URL,
62
63
  }),
63
64
  })