@mastra/mcp-docs-server 1.1.6 → 1.1.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.
- package/.docs/course/02-agent-tools-mcp/07-what-is-zapier-mcp.md +10 -1
- package/.docs/course/02-agent-tools-mcp/08-getting-zapier-mcp-url.md +14 -9
- package/.docs/course/02-agent-tools-mcp/09-updating-mcp-config-zapier.md +13 -1
- package/.docs/course/02-agent-tools-mcp/12-troubleshooting-zapier.md +10 -8
- package/.docs/course/02-agent-tools-mcp/13-what-is-github-mcp.md +1 -1
- package/.docs/course/02-agent-tools-mcp/14-getting-github-mcp-url.md +28 -20
- package/.docs/course/02-agent-tools-mcp/15-updating-mcp-config-github.md +18 -2
- package/.docs/course/02-agent-tools-mcp/18-troubleshooting-github.md +5 -5
- package/.docs/course/02-agent-tools-mcp/20-updating-mcp-config-hackernews.md +11 -1
- package/.docs/course/02-agent-tools-mcp/26-updating-mcp-config-filesystem.md +11 -1
- package/.docs/course/02-agent-tools-mcp/32-conclusion.md +1 -1
- package/.docs/docs/agents/using-tools.md +34 -0
- package/.docs/docs/deployment/studio.md +8 -0
- package/.docs/docs/memory/observational-memory.md +3 -5
- package/.docs/docs/server/auth/better-auth.md +23 -6
- package/.docs/docs/workspace/sandbox.md +2 -0
- package/.docs/guides/deployment/vercel.md +19 -0
- package/.docs/guides/index.md +20 -1
- package/.docs/models/gateways/netlify.md +11 -6
- package/.docs/models/gateways/openrouter.md +4 -1
- package/.docs/models/gateways/vercel.md +13 -3
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/aihubmix.md +7 -1
- package/.docs/models/providers/anthropic.md +3 -2
- package/.docs/models/providers/baseten.md +7 -5
- package/.docs/models/providers/chutes.md +2 -1
- package/.docs/models/providers/cloudferro-sherlock.md +74 -0
- package/.docs/models/providers/evroc.md +83 -0
- package/.docs/models/providers/fireworks-ai.md +20 -26
- package/.docs/models/providers/firmware.md +2 -1
- package/.docs/models/providers/friendli.md +5 -6
- package/.docs/models/providers/google.md +3 -1
- package/.docs/models/providers/meganova.md +89 -0
- package/.docs/models/providers/opencode-go.md +73 -0
- package/.docs/models/providers/opencode.md +33 -33
- package/.docs/models/providers/perplexity-agent.md +113 -0
- package/.docs/models/providers/perplexity.md +2 -1
- package/.docs/models/providers/poe.md +2 -1
- package/.docs/models/providers/qihang-ai.md +79 -0
- package/.docs/models/providers/qiniu-ai.md +146 -0
- package/.docs/models/providers/siliconflow-cn.md +5 -1
- package/.docs/models/providers/togetherai.md +2 -1
- package/.docs/models/providers/zenmux.md +5 -1
- package/.docs/models/providers.md +7 -0
- package/.docs/reference/agents/network.md +38 -1
- package/.docs/reference/ai-sdk/with-mastra.md +5 -1
- package/.docs/reference/deployer/vercel.md +28 -3
- package/.docs/reference/harness/harness-class.md +58 -6
- package/.docs/reference/index.md +1 -1
- package/.docs/reference/memory/cloneThread.md +13 -1
- package/.docs/reference/memory/observational-memory.md +4 -2
- package/.docs/reference/streaming/agents/stream.md +34 -0
- package/.docs/reference/tools/create-tool.md +48 -0
- package/.docs/reference/workspace/daytona-sandbox.md +580 -0
- package/.docs/reference/workspace/s3-filesystem.md +2 -0
- package/CHANGELOG.md +16 -0
- package/LICENSE.md +15 -0
- package/package.json +6 -6
- package/.docs/docs/mastra-code/configuration.md +0 -299
- package/.docs/docs/mastra-code/customization.md +0 -228
- package/.docs/docs/mastra-code/modes.md +0 -104
- package/.docs/docs/mastra-code/overview.md +0 -135
- package/.docs/docs/mastra-code/tools.md +0 -229
- package/.docs/reference/mastra-code/createMastraCode.md +0 -108
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Adding the Zapier MCP Server
|
|
2
2
|
|
|
3
|
-
In this step,
|
|
3
|
+
In this step, you'll add the Zapier MCP server to your agent, giving it access to email, social media, and many other integrations available through Zapier.
|
|
4
4
|
|
|
5
5
|
## What is Zapier MCP?
|
|
6
6
|
|
|
@@ -12,3 +12,12 @@ Zapier MCP is a server that provides access to thousands of apps and services th
|
|
|
12
12
|
- And many more
|
|
13
13
|
|
|
14
14
|
By integrating the Zapier MCP server with your Mastra agent, you can give it access to all these services without having to write custom tool functions for each one. This significantly expands your agent's capabilities and makes it more useful for a wide range of tasks.
|
|
15
|
+
|
|
16
|
+
## Authentication
|
|
17
|
+
|
|
18
|
+
Zapier MCP requires authentication to connect. You will need two things from Zapier:
|
|
19
|
+
|
|
20
|
+
1. **MCP Server URL**: The endpoint your agent connects to
|
|
21
|
+
2. **API Key**: A secret key sent with every request to prove your identity
|
|
22
|
+
|
|
23
|
+
The next step walks through getting both of these from the Zapier dashboard.
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
# Getting a Zapier MCP URL
|
|
1
|
+
# Getting a Zapier MCP URL and API key
|
|
2
2
|
|
|
3
|
-
First, you'll need to get a Zapier MCP URL. This
|
|
3
|
+
First, you'll need to get a Zapier MCP URL and API key. This requires:
|
|
4
4
|
|
|
5
|
-
1. Creating a Zapier account if you don't have one
|
|
6
|
-
2.
|
|
7
|
-
3.
|
|
5
|
+
1. Creating a Zapier account at [zapier.com](https://zapier.com) if you don't have one
|
|
6
|
+
2. Going to [mcp.zapier.com](https://mcp.zapier.com) and selecting **+ New MCP Server**
|
|
7
|
+
3. Choosing **OpenAI API** as the client type: This provides API Key authentication, which works well with custom MCP clients like Mastra
|
|
8
|
+
4. Adding tools to your server (e.g., search for "Gmail" and add "Find Email" and "Send Email")
|
|
9
|
+
5. Selecting the **Connect** tab to find your **MCP Server URL** and **API Key** (select **Rotate token** to generate one if needed)
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
**Important:** Copy your API key immediately when it is shown. Zapier only displays it once. If you lose it, generate a new one by selecting **Rotate token**.
|
|
12
|
+
|
|
13
|
+
Add both values to your `.env` file:
|
|
10
14
|
|
|
11
15
|
```bash
|
|
12
|
-
# Add
|
|
13
|
-
ZAPIER_MCP_URL=https://
|
|
16
|
+
# Add these to your .env file
|
|
17
|
+
ZAPIER_MCP_URL=https://mcp.zapier.com/api/v1/connect
|
|
18
|
+
ZAPIER_MCP_API_KEY=your-api-key-here
|
|
14
19
|
```
|
|
15
20
|
|
|
16
|
-
Using
|
|
21
|
+
Using environment variables keeps your credentials out of your source code. Ensure `.env` is listed in your `.gitignore` file.
|
|
@@ -7,11 +7,23 @@ const mcp = new MCPClient({
|
|
|
7
7
|
servers: {
|
|
8
8
|
zapier: {
|
|
9
9
|
url: new URL(process.env.ZAPIER_MCP_URL || ''),
|
|
10
|
+
requestInit: {
|
|
11
|
+
headers: {
|
|
12
|
+
Authorization: `Bearer ${process.env.ZAPIER_MCP_API_KEY}`,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
10
15
|
},
|
|
11
16
|
},
|
|
12
17
|
})
|
|
13
18
|
```
|
|
14
19
|
|
|
15
|
-
This configuration tells your agent how to connect to the Zapier MCP server.
|
|
20
|
+
This configuration tells your agent how to connect to the Zapier MCP server. Here is what each part does:
|
|
21
|
+
|
|
22
|
+
- **`zapier`**: A unique identifier for this server in your configuration
|
|
23
|
+
- **`url`**: The Zapier MCP server endpoint, read from your `.env` file
|
|
24
|
+
- **`requestInit.headers`**: HTTP headers sent with every request to the server
|
|
25
|
+
- **`Authorization: Bearer ...`**: Your API key, sent as a Bearer token to authenticate with Zapier
|
|
16
26
|
|
|
17
27
|
The `new URL()` constructor creates a URL object from the string provided by the environment variable. The `|| ""` part provides a default empty string in case the environment variable is not set, which prevents your application from crashing if the environment variable is missing.
|
|
28
|
+
|
|
29
|
+
The `requestInit` option lets you customize HTTP requests to the MCP server. Zapier requires an `Authorization` header with your API key in `Bearer {apiKey}` format to verify your identity on every request.
|
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
If your agent can't access the Zapier tools, check:
|
|
4
4
|
|
|
5
|
-
1. That your
|
|
6
|
-
2. That
|
|
7
|
-
3. That
|
|
5
|
+
1. That your `.env` file has both `ZAPIER_MCP_URL` and `ZAPIER_MCP_API_KEY` set
|
|
6
|
+
2. That your MCP config includes `requestInit.headers` with the `Authorization: Bearer` header
|
|
7
|
+
3. That you've added actions to your Zapier MCP server at [mcp.zapier.com](https://mcp.zapier.com)
|
|
8
|
+
4. That the tools are properly loaded by checking the Tools tab in the playground
|
|
8
9
|
|
|
9
10
|
Common issues include:
|
|
10
11
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
12
|
+
- **401 "Missing OAuth authorization header"**: Your config is missing the `requestInit.headers` block. Zapier MCP requires an `Authorization` header on every request.
|
|
13
|
+
- **401 "Invalid OAuth token"**: Your API key is incorrect or expired. Copy it again from the Zapier MCP dashboard (**Connect** tab), or select **Rotate token** to generate a new one.
|
|
14
|
+
- **No tools besides `zapier_get_configuration_url`**: You haven't added actions (e.g., Gmail) to your MCP server on the Zapier dashboard, or you haven't connected your app accounts.
|
|
15
|
+
- **Environment variables not loading**: Restart your development server after changing `.env` values. Environment variables are read at startup.
|
|
14
16
|
|
|
15
|
-
If you're having trouble,
|
|
17
|
+
If you're having trouble, check the terminal output when running `npm run dev` for error messages. The MCPClient logs connection errors with details about what went wrong.
|
|
16
18
|
|
|
17
|
-
In the next step,
|
|
19
|
+
In the next step, you'll add the GitHub MCP server to give your agent the ability to monitor and interact with GitHub repositories.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Adding the GitHub MCP Server
|
|
2
2
|
|
|
3
|
-
In this step, we'll add the
|
|
3
|
+
In this step, we'll add the official GitHub MCP server to our agent, which will give it the ability to monitor and interact with GitHub repositories.
|
|
4
4
|
|
|
5
5
|
## What is the GitHub MCP Server?
|
|
6
6
|
|
|
@@ -1,32 +1,40 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Setting Up the GitHub MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
To connect your agent to GitHub, we'll use the [official GitHub MCP server](https://github.com/github/github-mcp-server). GitHub hosts this server remotely at `https://api.githubcopilot.com/mcp/`, and authentication is done with a GitHub Personal Access Token passed in the request headers.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
2. Creating a personal access token with your GitHub account
|
|
7
|
-
3. Getting your unique MCP URL via the Smithery packages
|
|
5
|
+
## Creating a GitHub Personal Access Token
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
You'll need a GitHub Personal Access Token (PAT) to authenticate with the server.
|
|
8
|
+
|
|
9
|
+
1. Go to [GitHub Settings > Developer settings > Personal access tokens > Fine-grained tokens](https://github.com/settings/personal-access-tokens/new)
|
|
10
|
+
2. Give it a descriptive name (e.g., "Mastra Agent")
|
|
11
|
+
3. Select the repositories you want your agent to access
|
|
12
|
+
4. Under **Repository permissions**, grant at minimum:
|
|
13
|
+
- **Issues**: Read
|
|
14
|
+
- **Pull requests**: Read
|
|
15
|
+
- **Contents**: Read
|
|
16
|
+
- **Metadata**: Read (selected by default)
|
|
17
|
+
5. Click **Generate token** and copy it
|
|
18
|
+
|
|
19
|
+
Add the token to your `.env` file:
|
|
10
20
|
|
|
11
21
|
```bash
|
|
12
22
|
# Add this to your .env file
|
|
13
|
-
|
|
14
|
-
SMITHERY_PROFILE=your_smithery_profile_name
|
|
23
|
+
GITHUB_PERSONAL_ACCESS_TOKEN=your_github_token
|
|
15
24
|
```
|
|
16
25
|
|
|
17
|
-
Using an environment variable keeps your
|
|
26
|
+
Using an environment variable keeps your token secure and prevents it from being committed to your repository.
|
|
18
27
|
|
|
19
|
-
|
|
28
|
+
:::note
|
|
29
|
+
If you prefer to run the GitHub MCP server locally instead of using the hosted endpoint, you can use `npx` as a stdio transport:
|
|
20
30
|
|
|
21
|
-
```
|
|
22
|
-
|
|
31
|
+
```typescript
|
|
32
|
+
github: {
|
|
33
|
+
command: 'npx',
|
|
34
|
+
args: ['-y', '@modelcontextprotocol/server-github'],
|
|
35
|
+
env: { GITHUB_PERSONAL_ACCESS_TOKEN: process.env.GITHUB_PERSONAL_ACCESS_TOKEN },
|
|
36
|
+
}
|
|
23
37
|
```
|
|
24
38
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const smitheryGithubMCPServerUrl = createSmitheryUrl('https://server.smithery.ai/@smithery-ai/github', {
|
|
29
|
-
apiKey: process.env.SMITHERY_API_KEY,
|
|
30
|
-
profile: process.env.SMITHERY_PROFILE,
|
|
31
|
-
})
|
|
32
|
-
```
|
|
39
|
+
This does not require access to `api.githubcopilot.com` and works the same way as the hosted option.
|
|
40
|
+
:::
|
|
@@ -7,14 +7,30 @@ const mcp = new MCPClient({
|
|
|
7
7
|
servers: {
|
|
8
8
|
zapier: {
|
|
9
9
|
url: new URL(process.env.ZAPIER_MCP_URL || ''),
|
|
10
|
+
requestInit: {
|
|
11
|
+
headers: {
|
|
12
|
+
Authorization: `Bearer ${process.env.ZAPIER_MCP_API_KEY}`,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
10
15
|
},
|
|
11
16
|
github: {
|
|
12
|
-
url:
|
|
17
|
+
url: new URL('https://api.githubcopilot.com/mcp/'),
|
|
18
|
+
requestInit: {
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: `Bearer ${process.env.GITHUB_PERSONAL_ACCESS_TOKEN}`,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
13
23
|
},
|
|
14
24
|
},
|
|
15
25
|
})
|
|
16
26
|
```
|
|
17
27
|
|
|
18
|
-
This configuration adds the GitHub MCP server alongside the Zapier server we added in the previous step. The `github` key is a unique identifier for this server in your configuration
|
|
28
|
+
This configuration adds the GitHub MCP server alongside the Zapier server we added in the previous step. The `github` key is a unique identifier for this server in your configuration.
|
|
29
|
+
|
|
30
|
+
**How it works:**
|
|
31
|
+
|
|
32
|
+
- The `url` property points to GitHub's hosted remote MCP server
|
|
33
|
+
- The `requestInit.headers` property passes your Personal Access Token for authentication
|
|
34
|
+
- The server uses Streamable HTTP transport, the same protocol used by the Zapier server
|
|
19
35
|
|
|
20
36
|
By adding multiple servers to your MCP configuration, you're building a more versatile agent that can access a wider range of tools and services. Each server adds its own set of capabilities to your agent.
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
If your agent can't access the GitHub tools, check:
|
|
4
4
|
|
|
5
|
-
1. That your
|
|
6
|
-
2. That
|
|
5
|
+
1. That your `GITHUB_PERSONAL_ACCESS_TOKEN` is set correctly in your `.env` file
|
|
6
|
+
2. That your token has the required repository permissions (Issues, Pull requests, Contents, Metadata)
|
|
7
7
|
3. That the tools are properly loaded by checking the Tools tab in the playground
|
|
8
8
|
|
|
9
9
|
Common issues include:
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
11
|
+
- Missing or expired Personal Access Token — generate a new one at [GitHub Settings](https://github.com/settings/personal-access-tokens)
|
|
12
|
+
- Insufficient token permissions — ensure your token has read access to the repositories you're targeting
|
|
13
|
+
- Network issues preventing the connection to `api.githubcopilot.com`
|
|
14
14
|
|
|
15
15
|
If you're having trouble, try checking the console logs for any error messages related to the GitHub MCP server. These can provide valuable clues about what might be going wrong.
|
|
16
16
|
|
|
@@ -9,9 +9,19 @@ const mcp = new MCPClient({
|
|
|
9
9
|
servers: {
|
|
10
10
|
zapier: {
|
|
11
11
|
url: new URL(process.env.ZAPIER_MCP_URL || ''),
|
|
12
|
+
requestInit: {
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: `Bearer ${process.env.ZAPIER_MCP_API_KEY}`,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
12
17
|
},
|
|
13
18
|
github: {
|
|
14
|
-
url: new URL(
|
|
19
|
+
url: new URL('https://api.githubcopilot.com/mcp/'),
|
|
20
|
+
requestInit: {
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${process.env.GITHUB_PERSONAL_ACCESS_TOKEN}`,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
15
25
|
},
|
|
16
26
|
hackernews: {
|
|
17
27
|
command: 'npx',
|
|
@@ -9,9 +9,19 @@ const mcp = new MCPClient({
|
|
|
9
9
|
servers: {
|
|
10
10
|
zapier: {
|
|
11
11
|
url: new URL(process.env.ZAPIER_MCP_URL || ''),
|
|
12
|
+
requestInit: {
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: `Bearer ${process.env.ZAPIER_MCP_API_KEY}`,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
12
17
|
},
|
|
13
18
|
github: {
|
|
14
|
-
url: new URL(
|
|
19
|
+
url: new URL('https://api.githubcopilot.com/mcp/'),
|
|
20
|
+
requestInit: {
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${process.env.GITHUB_PERSONAL_ACCESS_TOKEN}`,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
15
25
|
},
|
|
16
26
|
hackernews: {
|
|
17
27
|
command: 'npx',
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Congratulations! You've successfully enhanced your Mastra agent with MCP servers, giving it powerful capabilities including:
|
|
4
4
|
|
|
5
5
|
1. Email and social media integration through Zapier
|
|
6
|
-
2. GitHub monitoring through the
|
|
6
|
+
2. GitHub monitoring through the official GitHub MCP server
|
|
7
7
|
3. Tech news access through the Hacker News MCP server
|
|
8
8
|
4. Local file management through the Filesystem MCP server
|
|
9
9
|
5. Enhanced memory for personalized interactions
|
|
@@ -36,6 +36,40 @@ export const weatherTool = createTool({
|
|
|
36
36
|
})
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
## Shaping output for the model
|
|
40
|
+
|
|
41
|
+
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.
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
export const weatherTool = createTool({
|
|
45
|
+
// ...other config
|
|
46
|
+
execute: async ({ location }) => {
|
|
47
|
+
const response = await fetch(`https://wttr.in/${location}?format=j1`)
|
|
48
|
+
const data = await response.json()
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
location,
|
|
52
|
+
temperature: data.current_condition[0].temp_F,
|
|
53
|
+
condition: data.current_condition[0].weatherDesc[0].value,
|
|
54
|
+
weatherIconUrl: data.current_condition[0].weatherIconUrl[0].value,
|
|
55
|
+
source: data,
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
toModelOutput: output => {
|
|
59
|
+
return {
|
|
60
|
+
type: 'content',
|
|
61
|
+
value: [
|
|
62
|
+
{
|
|
63
|
+
type: 'text',
|
|
64
|
+
text: `${output.location}: ${output.temperature}F and ${output.condition}`,
|
|
65
|
+
},
|
|
66
|
+
{ type: 'image-url', url: output.weatherIconUrl },
|
|
67
|
+
],
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
```
|
|
72
|
+
|
|
39
73
|
## Adding tools to an agent
|
|
40
74
|
|
|
41
75
|
To make a tool available to an agent, add it to `tools`. Mentioning available tools and their general purpose in the agent's system prompt helps the agent decide when to call a tool and when not to.
|
|
@@ -49,6 +49,14 @@ mastra studio
|
|
|
49
49
|
|
|
50
50
|
Open [localhost:3000](http://localhost:3000) in your browser to see the Studio UI. By default, it will attempt to connect to a Mastra server running at `http://localhost:4111`. If it doesn't find one there, you'll see a form where you can enter your Mastra instance URL and API prefix.
|
|
51
51
|
|
|
52
|
+
If you're hosting Studio under a subpath (for example `/agents` behind Nginx), set `MASTRA_STUDIO_BASE_PATH` before starting Studio:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
MASTRA_STUDIO_BASE_PATH=/agents mastra studio
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This updates the HTML base URL and static asset routing so the standalone Studio works correctly under that subpath.
|
|
59
|
+
|
|
52
60
|
The command uses Node's built-in `http` module and [`serve-handler`](https://www.npmjs.com/package/serve-handler) to serve the static files.
|
|
53
61
|
|
|
54
62
|
## Running a server
|
|
@@ -85,13 +85,11 @@ The result is a three-tier system:
|
|
|
85
85
|
|
|
86
86
|
## Models
|
|
87
87
|
|
|
88
|
-
The Observer and Reflector run in the background. Any model that works with Mastra's model routing (
|
|
88
|
+
The Observer and Reflector run in the background. Any model that works with Mastra's [model routing](https://mastra.ai/models) (`provider/model`) can be used. When using `observationalMemory: true`, the default model is `google/gemini-2.5-flash`. When passing a config object, a `model` must be explicitly set.
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
Generally speaking, we recommend using a model that has a large context window (128K+ tokens) and is fast enough to run in the background without slowing down your actions.
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
We've also tested `deepseek`, `qwen3`, and `glm-4.7` for the Observer. For the Reflector, make sure the model's context window can fit all observations. Note that Claude 4.5 models currently don't work well as observer or reflector.
|
|
92
|
+
If you're unsure which model to use, start with the default `google/gemini-2.5-flash`. We've also successfully tested `openai/gpt-5-mini`, `anthropic/claude-haiku-4-5`, `deepseek/deepseek-reasoner`, `qwen3`, and `glm-4.7`.
|
|
95
93
|
|
|
96
94
|
```typescript
|
|
97
95
|
const memory = new Memory({
|
|
@@ -122,7 +122,21 @@ When auth is enabled, requests to Mastra's built-in routes require authenticatio
|
|
|
122
122
|
|
|
123
123
|
### Cookie session (recommended)
|
|
124
124
|
|
|
125
|
-
If your Better Auth setup uses cookies, configure the client to send credentials
|
|
125
|
+
If your Better Auth setup uses cookies, configure the client to send credentials. For cross-origin requests (e.g. Next.js on `:3000` calling Mastra on `:4111`), enable CORS credentials on the Mastra server:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
export const mastra = new Mastra({
|
|
129
|
+
server: {
|
|
130
|
+
auth: mastraAuth,
|
|
131
|
+
cors: {
|
|
132
|
+
origin: 'http://localhost:3000', // your frontend origin
|
|
133
|
+
credentials: true,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
})
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Then configure the client to include credentials:
|
|
126
140
|
|
|
127
141
|
```ts
|
|
128
142
|
import { MastraClient } from '@mastra/client-js'
|
|
@@ -148,15 +162,18 @@ await fetch('http://localhost:4111/api/agents/weatherAgent/generate', {
|
|
|
148
162
|
|
|
149
163
|
### Bearer token
|
|
150
164
|
|
|
151
|
-
|
|
165
|
+
You can pass the signed session token as a Bearer token. Retrieve it from your Better Auth client session and include it in the `Authorization` header:
|
|
152
166
|
|
|
153
167
|
```ts
|
|
154
168
|
import { MastraClient } from '@mastra/client-js'
|
|
169
|
+
import { authClient } from './auth-client' // your Better Auth client
|
|
170
|
+
|
|
171
|
+
const session = await authClient.getSession()
|
|
155
172
|
|
|
156
173
|
export const mastraClient = new MastraClient({
|
|
157
174
|
baseUrl: 'http://localhost:4111',
|
|
158
175
|
headers: {
|
|
159
|
-
Authorization: `Bearer ${
|
|
176
|
+
Authorization: `Bearer ${session.data?.session.token}`,
|
|
160
177
|
},
|
|
161
178
|
})
|
|
162
179
|
```
|
|
@@ -196,8 +213,8 @@ curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
|
|
|
196
213
|
|
|
197
214
|
## Troubleshooting
|
|
198
215
|
|
|
199
|
-
- **401
|
|
200
|
-
- **Cookies not sent**: set `credentials: "include"` in `MastraClient` and
|
|
201
|
-
- **
|
|
216
|
+
- **401 on every request**: confirm your Better Auth handler is mounted and your app can create a valid session. Check that your client sends either a session cookie or an `Authorization: Bearer <signed-token>` header.
|
|
217
|
+
- **Cookies not sent cross-origin**: set `credentials: "include"` in `MastraClient` and configure `server.cors` with your frontend origin and `credentials: true`.
|
|
218
|
+
- **Bearer token rejected**: ensure you pass the full signed session token (from `authClient.getSession()`), not a raw or unsigned token.
|
|
202
219
|
- **Base URL issues**: set `baseURL` in `betterAuth({ ... })` or set `BETTER_AUTH_URL`.
|
|
203
220
|
- **DB connection errors**: verify `DATABASE_URL` and database provider configuration.
|
|
@@ -19,6 +19,7 @@ When you assign a workspace with a sandbox to an agent, Mastra automatically inc
|
|
|
19
19
|
Available providers:
|
|
20
20
|
|
|
21
21
|
- [`LocalSandbox`](https://mastra.ai/reference/workspace/local-sandbox) - Executes commands on the local machine
|
|
22
|
+
- [`DaytonaSandbox`](https://mastra.ai/reference/workspace/daytona-sandbox) - Executes commands in isolated Daytona cloud sandboxes
|
|
22
23
|
- [`E2BSandbox`](https://mastra.ai/reference/workspace/e2b-sandbox) - Executes commands in isolated E2B cloud sandboxes
|
|
23
24
|
|
|
24
25
|
## Basic usage
|
|
@@ -58,6 +59,7 @@ When you configure a sandbox on a workspace, agents receive the `execute_command
|
|
|
58
59
|
## Related
|
|
59
60
|
|
|
60
61
|
- [`LocalSandbox` reference](https://mastra.ai/reference/workspace/local-sandbox)
|
|
62
|
+
- [`DaytonaSandbox` reference](https://mastra.ai/reference/workspace/daytona-sandbox)
|
|
61
63
|
- [`E2BSandbox` reference](https://mastra.ai/reference/workspace/e2b-sandbox)
|
|
62
64
|
- [Workspace overview](https://mastra.ai/docs/workspace/overview)
|
|
63
65
|
- [Filesystem](https://mastra.ai/docs/workspace/filesystem)
|
|
@@ -67,6 +67,25 @@ export const mastra = new Mastra({
|
|
|
67
67
|
|
|
68
68
|
> **Warning:** Set up [authentication](https://mastra.ai/docs/server/auth) before exposing your endpoints publicly.
|
|
69
69
|
|
|
70
|
+
## Studio
|
|
71
|
+
|
|
72
|
+
You can deploy [Studio](https://mastra.ai/docs/getting-started/studio) alongside your API by enabling the `studio` option. Studio is deployed as static assets served from Vercel's Edge CDN, so it doesn't consume function invocations.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { Mastra } from '@mastra/core'
|
|
76
|
+
import { VercelDeployer } from '@mastra/deployer-vercel'
|
|
77
|
+
|
|
78
|
+
export const mastra = new Mastra({
|
|
79
|
+
deployer: new VercelDeployer({
|
|
80
|
+
studio: true,
|
|
81
|
+
}),
|
|
82
|
+
})
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
After deploying, Studio is available at the root URL (`https://<your-project>.vercel.app/`) and the API remains at `/api/*`. Studio automatically connects to the API on the same origin — no additional environment variables are needed.
|
|
86
|
+
|
|
87
|
+
> **Warning:** Once Studio is connected to your Mastra server, it has full access to your agents, workflows, and tools. Be sure to secure it properly in production (e.g. behind authentication, VPN, etc.) to prevent unauthorized access.
|
|
88
|
+
|
|
70
89
|
## Optional overrides
|
|
71
90
|
|
|
72
91
|
The Vercel deployer supports configuration options that are written to the Vercel Output API function config. See the [`VercelDeployer` reference](https://mastra.ai/reference/deployer/vercel) for available options like `maxDuration`, `memory`, and `regions`.
|
package/.docs/guides/index.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
1
|
# Mastra Guides
|
|
2
2
|
|
|
3
|
-
Mastra offers a variety of guides to help you build and work with Mastra, from building agents and workflows to using the Mastra SDK and API, and implementing different UI frameworks.
|
|
3
|
+
Mastra offers a variety of guides to help you build and work with Mastra, from building agents and workflows to using the Mastra SDK and API, and implementing different UI frameworks. Explore the guides below to find the resources you need to get started and build with Mastra.
|
|
4
|
+
|
|
5
|
+
## New project
|
|
6
|
+
|
|
7
|
+
The `create mastra` command is the fastest way to build your first agent. It walks you through setup and generates an example agent you can run and adapt in [Studio](https://mastra.ai/docs/getting-started/studio) right away. You can always integrate Mastra with your framework or UI when you’re ready.
|
|
8
|
+
|
|
9
|
+
- [Quickstart](https://mastra.ai/guides/getting-started/quickstart)
|
|
10
|
+
|
|
11
|
+
## Integrate with your framework
|
|
12
|
+
|
|
13
|
+
Add Mastra to an existing project, or scaffold a new Mastra-powered app if you’re starting from scratch.
|
|
14
|
+
|
|
15
|
+
- [Next.js](https://mastra.ai/guides/getting-started/next-js)
|
|
16
|
+
- [React](https://mastra.ai/guides/getting-started/vite-react)
|
|
17
|
+
- [SvelteKit](https://mastra.ai/guides/getting-started/sveltekit)
|
|
18
|
+
- [Astro](https://mastra.ai/guides/getting-started/astro)
|
|
19
|
+
- [Nuxt](https://mastra.ai/guides/getting-started/nuxt)
|
|
20
|
+
- [Express](https://mastra.ai/guides/getting-started/express)
|
|
21
|
+
- [Hono](https://mastra.ai/guides/getting-started/hono)
|
|
22
|
+
- [Electron](https://mastra.ai/guides/getting-started/electron)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Netlify
|
|
2
2
|
|
|
3
|
-
Netlify AI Gateway provides unified access to multiple providers with built-in caching and observability. Access
|
|
3
|
+
Netlify AI Gateway provides unified access to multiple providers with built-in caching and observability. Access 56 models through Mastra's model router.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Netlify documentation](https://docs.netlify.com/build/ai-gateway/overview/).
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ const agent = new Agent({
|
|
|
13
13
|
id: "my-agent",
|
|
14
14
|
name: "My Agent",
|
|
15
15
|
instructions: "You are a helpful assistant",
|
|
16
|
-
model: "netlify/anthropic/claude-3-
|
|
16
|
+
model: "netlify/anthropic/claude-3-haiku-20240307"
|
|
17
17
|
});
|
|
18
18
|
```
|
|
19
19
|
|
|
@@ -23,7 +23,8 @@ const agent = new Agent({
|
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
25
|
# Use gateway API key
|
|
26
|
-
|
|
26
|
+
NETLIFY_TOKEN=your-netlify-token
|
|
27
|
+
NETLIFY_SITE_ID=your-netlify-site-id
|
|
27
28
|
|
|
28
29
|
# Or use provider API keys directly
|
|
29
30
|
OPENAI_API_KEY=sk-...
|
|
@@ -34,8 +35,6 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
34
35
|
|
|
35
36
|
| Model |
|
|
36
37
|
| ---------------------------------------------- |
|
|
37
|
-
| `anthropic/claude-3-5-haiku-20241022` |
|
|
38
|
-
| `anthropic/claude-3-7-sonnet-20250219` |
|
|
39
38
|
| `anthropic/claude-3-haiku-20240307` |
|
|
40
39
|
| `anthropic/claude-haiku-4-5` |
|
|
41
40
|
| `anthropic/claude-haiku-4-5-20251001` |
|
|
@@ -48,6 +47,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
48
47
|
| `anthropic/claude-sonnet-4-20250514` |
|
|
49
48
|
| `anthropic/claude-sonnet-4-5` |
|
|
50
49
|
| `anthropic/claude-sonnet-4-5-20250929` |
|
|
50
|
+
| `anthropic/claude-sonnet-4-6` |
|
|
51
51
|
| `gemini/gemini-2.0-flash` |
|
|
52
52
|
| `gemini/gemini-2.0-flash-lite` |
|
|
53
53
|
| `gemini/gemini-2.5-flash` |
|
|
@@ -58,9 +58,12 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
58
58
|
| `gemini/gemini-3-flash-preview` |
|
|
59
59
|
| `gemini/gemini-3-pro-image-preview` |
|
|
60
60
|
| `gemini/gemini-3-pro-preview` |
|
|
61
|
+
| `gemini/gemini-3.1-flash-image-preview` |
|
|
62
|
+
| `gemini/gemini-3.1-flash-lite-preview` |
|
|
63
|
+
| `gemini/gemini-3.1-pro-preview` |
|
|
64
|
+
| `gemini/gemini-3.1-pro-preview-customtools` |
|
|
61
65
|
| `gemini/gemini-flash-latest` |
|
|
62
66
|
| `gemini/gemini-flash-lite-latest` |
|
|
63
|
-
| `openai/codex-mini-latest` |
|
|
64
67
|
| `openai/gpt-4.1` |
|
|
65
68
|
| `openai/gpt-4.1-mini` |
|
|
66
69
|
| `openai/gpt-4.1-nano` |
|
|
@@ -83,6 +86,8 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
83
86
|
| `openai/gpt-5.2-codex` |
|
|
84
87
|
| `openai/gpt-5.2-pro` |
|
|
85
88
|
| `openai/gpt-5.2-pro-2025-12-11` |
|
|
89
|
+
| `openai/gpt-5.3-chat-latest` |
|
|
90
|
+
| `openai/gpt-5.3-codex` |
|
|
86
91
|
| `openai/o3` |
|
|
87
92
|
| `openai/o3-mini` |
|
|
88
93
|
| `openai/o4-mini` |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenRouter
|
|
2
2
|
|
|
3
|
-
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
3
|
+
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 186 models through Mastra's model router.
|
|
4
4
|
|
|
5
5
|
Learn more in the [OpenRouter documentation](https://openrouter.ai/models).
|
|
6
6
|
|
|
@@ -44,6 +44,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
44
44
|
| `anthropic/claude-opus-4.6` |
|
|
45
45
|
| `anthropic/claude-sonnet-4` |
|
|
46
46
|
| `anthropic/claude-sonnet-4.5` |
|
|
47
|
+
| `anthropic/claude-sonnet-4.6` |
|
|
47
48
|
| `arcee-ai/trinity-large-preview:free` |
|
|
48
49
|
| `arcee-ai/trinity-mini:free` |
|
|
49
50
|
| `black-forest-labs/flux.2-flex` |
|
|
@@ -78,6 +79,8 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
78
79
|
| `google/gemini-2.5-pro-preview-06-05` |
|
|
79
80
|
| `google/gemini-3-flash-preview` |
|
|
80
81
|
| `google/gemini-3-pro-preview` |
|
|
82
|
+
| `google/gemini-3.1-pro-preview` |
|
|
83
|
+
| `google/gemini-3.1-pro-preview-customtools` |
|
|
81
84
|
| `google/gemma-2-9b-it` |
|
|
82
85
|
| `google/gemma-3-12b-it` |
|
|
83
86
|
| `google/gemma-3-12b-it:free` |
|