@mastra/mcp-docs-server 0.13.19-alpha.0 → 0.13.19-alpha.2
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/organized/changelogs/%40mastra%2Fagent-builder.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +16 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +13 -13
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +19 -19
- package/.docs/organized/changelogs/create-mastra.md +7 -7
- package/.docs/organized/changelogs/mastra.md +14 -14
- package/.docs/organized/code-examples/ai-sdk-useChat.md +1 -1
- package/.docs/organized/code-examples/workflow-with-suspend-resume.md +1 -0
- package/.docs/raw/agents/dynamic-agents.mdx +5 -5
- package/.docs/raw/agents/runtime-context.mdx +103 -0
- package/.docs/raw/auth/jwt.mdx +2 -2
- package/.docs/raw/auth/supabase.mdx +128 -0
- package/.docs/raw/deployment/overview.mdx +7 -7
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +1 -1
- package/.docs/raw/getting-started/mcp-docs-server.mdx +52 -48
- package/.docs/raw/memory/overview.mdx +2 -2
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDefaultVNextStreamOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +1 -1
- package/.docs/raw/reference/agents/getLLM.mdx +1 -1
- package/.docs/raw/reference/agents/getMemory.mdx +1 -1
- package/.docs/raw/reference/agents/getModel.mdx +1 -1
- package/.docs/raw/reference/agents/getScorers.mdx +1 -1
- package/.docs/raw/reference/agents/streamVNext.mdx +120 -29
- package/.docs/raw/reference/auth/jwt.mdx +2 -3
- package/.docs/raw/reference/auth/supabase.mdx +62 -0
- package/.docs/raw/reference/{agents → core}/getAgent.mdx +1 -2
- package/.docs/raw/reference/core/getAgentById.mdx +43 -0
- package/.docs/raw/reference/core/getAgents.mdx +35 -0
- package/.docs/raw/reference/core/getDeployer.mdx +35 -0
- package/.docs/raw/reference/core/getLogger.mdx +35 -0
- package/.docs/raw/reference/core/getLogs.mdx +92 -0
- package/.docs/raw/reference/core/getLogsByRunId.mdx +84 -0
- package/.docs/raw/reference/core/getMCPServer.mdx +49 -0
- package/.docs/raw/reference/core/getMCPServers.mdx +35 -0
- package/.docs/raw/reference/core/getMemory.mdx +35 -0
- package/.docs/raw/reference/core/getServer.mdx +35 -0
- package/.docs/raw/reference/core/getStorage.mdx +35 -0
- package/.docs/raw/reference/core/getTelemetry.mdx +35 -0
- package/.docs/raw/reference/core/getVector.mdx +43 -0
- package/.docs/raw/reference/core/getVectors.mdx +35 -0
- package/.docs/raw/reference/core/getWorkflow.mdx +49 -0
- package/.docs/raw/reference/core/getWorkflows.mdx +44 -0
- package/.docs/raw/reference/core/mastra-class.mdx +14 -178
- package/.docs/raw/reference/core/setLogger.mdx +47 -0
- package/.docs/raw/reference/core/setStorage.mdx +39 -0
- package/.docs/raw/reference/core/setTelemetry.mdx +35 -0
- package/.docs/raw/reference/tools/create-tool.mdx +1 -1
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +2 -2
- package/.docs/raw/reference/tools/vector-query-tool.mdx +2 -2
- package/.docs/raw/tools-mcp/runtime-context.mdx +63 -0
- package/.docs/raw/workflows/control-flow.mdx +2 -2
- package/.docs/raw/workflows/overview.mdx +8 -8
- package/.docs/raw/workflows/suspend-and-resume.mdx +4 -4
- package/CHANGELOG.md +17 -0
- package/package.json +5 -5
- package/.docs/raw/agents/runtime-variables.mdx +0 -116
- package/.docs/raw/reference/workflows/execute.mdx +0 -131
- package/.docs/raw/tools-mcp/dynamic-context.mdx +0 -131
- /package/.docs/raw/reference/workflows/{branch.mdx → workflow-methods/branch.mdx} +0 -0
- /package/.docs/raw/reference/workflows/{commit.mdx → workflow-methods/commit.mdx} +0 -0
- /package/.docs/raw/reference/workflows/{create-run.mdx → workflow-methods/create-run.mdx} +0 -0
- /package/.docs/raw/reference/workflows/{dountil.mdx → workflow-methods/dountil.mdx} +0 -0
- /package/.docs/raw/reference/workflows/{dowhile.mdx → workflow-methods/dowhile.mdx} +0 -0
- /package/.docs/raw/reference/workflows/{foreach.mdx → workflow-methods/foreach.mdx} +0 -0
- /package/.docs/raw/reference/workflows/{map.mdx → workflow-methods/map.mdx} +0 -0
- /package/.docs/raw/reference/workflows/{parallel.mdx → workflow-methods/parallel.mdx} +0 -0
- /package/.docs/raw/reference/workflows/{sendEvent.mdx → workflow-methods/sendEvent.mdx} +0 -0
- /package/.docs/raw/reference/workflows/{sleep.mdx → workflow-methods/sleep.mdx} +0 -0
- /package/.docs/raw/reference/workflows/{sleepUntil.mdx → workflow-methods/sleepUntil.mdx} +0 -0
- /package/.docs/raw/reference/workflows/{then.mdx → workflow-methods/then.mdx} +0 -0
- /package/.docs/raw/reference/workflows/{waitForEvent.mdx → workflow-methods/waitForEvent.mdx} +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Runtime context | Agents | Mastra Docs"
|
|
3
|
+
description: Learn how to use Mastra's RuntimeContext to provide dynamic, request-specific configuration to agents.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Agent Runtime Context
|
|
7
|
+
|
|
8
|
+
Mastra provides `RuntimeContext`, a dependency injection system that lets you configure agents with runtime variables. If you find yourself creating multiple agents that perform similar tasks, runtime context allows you to consolidate them into a single, more flexible agent.
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
The dependency injection system allows you to:
|
|
13
|
+
|
|
14
|
+
1. Pass runtime configuration variables to agents through a type-safe `runtimeContext`
|
|
15
|
+
2. Access these variables within tool execution contexts
|
|
16
|
+
3. Modify agent behavior without changing the underlying code
|
|
17
|
+
4. Share configuration across multiple tools within the same agent
|
|
18
|
+
|
|
19
|
+
## Using `runtimeContext` with agents
|
|
20
|
+
|
|
21
|
+
Agents can access `runtimeContext` via the `instructions` parameter, and retrieve variables using `runtimeContext.get()`. This allows agent behavior to adapt dynamically based on user input or external configuration, without changing the underlying implementation.
|
|
22
|
+
|
|
23
|
+
```typescript {6-7,14} filename="src/mastra/agents/test-weather-agent.ts" showLineNumbers copy
|
|
24
|
+
import { openai } from "@ai-sdk/openai";
|
|
25
|
+
import { Agent } from "@mastra/core/agent";
|
|
26
|
+
|
|
27
|
+
export const testWeatherAgent = new Agent({
|
|
28
|
+
name: "test-weather-agent",
|
|
29
|
+
instructions: async ({ runtimeContext }) => {
|
|
30
|
+
const temperatureUnit = runtimeContext.get("temperature-unit");
|
|
31
|
+
|
|
32
|
+
return `You are a weather assistant that provides current weather information for any city.
|
|
33
|
+
|
|
34
|
+
When a user asks for weather:
|
|
35
|
+
- Extract the city name from their request
|
|
36
|
+
- Respond with: temperature, feels-like temperature, humidity, wind speed, and conditions
|
|
37
|
+
- Use ${temperatureUnit} for all temperature values
|
|
38
|
+
- If no city is mentioned, ask for a city name
|
|
39
|
+
`;
|
|
40
|
+
},
|
|
41
|
+
model: openai("gpt-4o-mini")
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Example usage
|
|
46
|
+
|
|
47
|
+
In this example, `temperature-unit` is set using `runtimeContext.set()` to either **celsius** or **fahrenheit**, allowing the agent to respond with temperatures in the appropriate unit.
|
|
48
|
+
|
|
49
|
+
```typescript {12} filename="src/test-weather-agent.ts" showLineNumbers copy
|
|
50
|
+
import { mastra } from "./mastra";
|
|
51
|
+
import { RuntimeContext } from "@mastra/core/runtime-context";
|
|
52
|
+
|
|
53
|
+
const agent = mastra.getAgent("testWeatherAgent");
|
|
54
|
+
|
|
55
|
+
export type WeatherRuntimeContext = {
|
|
56
|
+
"temperature-unit": "celsius" | "fahrenheit";
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const runtimeContext = new RuntimeContext<WeatherRuntimeContext>();
|
|
60
|
+
|
|
61
|
+
runtimeContext.set("temperature-unit", "fahrenheit");
|
|
62
|
+
|
|
63
|
+
const response = await agent.generate("What's the weather in London?", {
|
|
64
|
+
runtimeContext
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
console.log(response.text);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Accessing `runtimeContext` with server middleware
|
|
71
|
+
|
|
72
|
+
You can populate `runtimeContext` dynamically in server middleware by extracting information from the request. In this example, the `temperature-unit` is set based on the Cloudflare `CF-IPCountry` header to ensure responses match the user's locale.
|
|
73
|
+
|
|
74
|
+
```typescript {2,12-21} filename="src/mastra/index.ts" showLineNumbers copy
|
|
75
|
+
import { Mastra } from "@mastra/core/mastra";
|
|
76
|
+
import { RuntimeContext } from "@mastra/core/runtime-context";
|
|
77
|
+
import { testWeatherAgent } from "./agents/test-weather-agent";
|
|
78
|
+
|
|
79
|
+
type WeatherRuntimeContext = {
|
|
80
|
+
"temperature-unit": "celsius" | "fahrenheit";
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const mastra = new Mastra({
|
|
84
|
+
agents: { testWeatherAgent },
|
|
85
|
+
server: {
|
|
86
|
+
middleware: [
|
|
87
|
+
async (context, next) => {
|
|
88
|
+
const country = context.req.header("CF-IPCountry");
|
|
89
|
+
const runtimeContext = context.get("runtimeContext") as RuntimeContext<WeatherRuntimeContext>;
|
|
90
|
+
|
|
91
|
+
runtimeContext.set("temperature-unit", country === "US" ? "fahrenheit" : "celsius");
|
|
92
|
+
|
|
93
|
+
await next();
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Related
|
|
101
|
+
|
|
102
|
+
- [Dynamic Agents](./dynamic-agents.mdx)
|
|
103
|
+
- [Tool Runtime Context](../tools-mcp/runtime-context.mdx)
|
package/.docs/raw/auth/jwt.mdx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "MastraJwtAuth"
|
|
2
|
+
title: "MastraJwtAuth Class"
|
|
3
3
|
description: "Documentation for the MastraJwtAuth class, which authenticates Mastra applications using JSON Web Tokens."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
import { Tabs, Tab } from "@/components/tabs";
|
|
7
7
|
|
|
8
|
-
# MastraJwtAuth
|
|
8
|
+
# MastraJwtAuth Class
|
|
9
9
|
|
|
10
10
|
The `MastraJwtAuth` class provides a lightweight authentication mechanism for Mastra using JSON Web Tokens (JWTs). It verifies incoming requests based on a shared secret and integrates with the Mastra server using the `experimental_auth` option.
|
|
11
11
|
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "MastraAuthSupabase Class"
|
|
3
|
+
description: "Documentation for the MastraAuthSupabase class, which authenticates Mastra applications using Supabase Auth."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { Tabs, Tab } from "@/components/tabs";
|
|
7
|
+
|
|
8
|
+
# MastraAuthSupabase Class
|
|
9
|
+
|
|
10
|
+
The `MastraAuthSupabase` class provides authentication for Mastra using Supabase Auth. It verifies incoming requests using Supabase's authentication system and integrates with the Mastra server using the `experimental_auth` option.
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
This example uses Supabase Auth. Make sure to add your Supabase credentials to your `.env` file and ensure your Supabase project is properly configured.
|
|
15
|
+
|
|
16
|
+
```env filename=".env" copy
|
|
17
|
+
SUPABASE_URL=https://your-project.supabase.co
|
|
18
|
+
SUPABASE_ANON_KEY=your-anon-key
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
> **Note:** Review your Supabase Row Level Security (RLS) settings to ensure proper data access controls.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
Before you can use the `MastraAuthSupabase` class you have to install the `@mastra/auth-supabase` package.
|
|
26
|
+
|
|
27
|
+
```bash copy
|
|
28
|
+
npm install @mastra/auth-supabase@latest
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage example
|
|
32
|
+
|
|
33
|
+
```typescript {2,7-9} filename="src/mastra/index.ts" showLineNumbers copy
|
|
34
|
+
import { Mastra } from "@mastra/core/mastra";
|
|
35
|
+
import { MastraAuthSupabase } from '@mastra/auth-supabase';
|
|
36
|
+
|
|
37
|
+
export const mastra = new Mastra({
|
|
38
|
+
// ..
|
|
39
|
+
server: {
|
|
40
|
+
experimental_auth: new MastraAuthSupabase({
|
|
41
|
+
url: process.env.SUPABASE_URL,
|
|
42
|
+
anonKey: process.env.SUPABASE_ANON_KEY
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
> **Note:** The default `authorizeUser` method checks the `isAdmin` column in the `users` table in the `public` schema. To customize user authorization, provide a custom `authorizeUser` function when constructing the provider.
|
|
49
|
+
|
|
50
|
+
> See the [MastraAuthSupabase](/reference/auth/supabase.mdx) API reference for all available configuration options.
|
|
51
|
+
|
|
52
|
+
## Client-side setup
|
|
53
|
+
|
|
54
|
+
When using Supabase auth, you'll need to retrieve the access token from Supabase on the client side and pass it to your Mastra requests.
|
|
55
|
+
|
|
56
|
+
### Retrieving the access token
|
|
57
|
+
|
|
58
|
+
Use the Supabase client to authenticate users and retrieve their access token:
|
|
59
|
+
|
|
60
|
+
```typescript filename="lib/auth.ts" showLineNumbers copy
|
|
61
|
+
import { createClient } from "@supabase/supabase-js";
|
|
62
|
+
|
|
63
|
+
const supabase = createClient("<supabase-url>", "<supabase-key>");
|
|
64
|
+
|
|
65
|
+
const authTokenResponse = await supabase.auth.signInWithPassword({
|
|
66
|
+
email: "<user's email>",
|
|
67
|
+
password: "<user's password>",
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const accessToken = authTokenResponse.data?.session?.access_token;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> Refer to the [Supabase documentation](https://supabase.com/docs/guides/auth) for other authentication methods like OAuth, magic links, and more.
|
|
74
|
+
|
|
75
|
+
## Configuring `MastraClient`
|
|
76
|
+
|
|
77
|
+
When `experimental_auth` is enabled, all requests made with `MastraClient` must include a valid Supabase access token in the `Authorization` header:
|
|
78
|
+
|
|
79
|
+
```typescript {6} filename="lib/mastra/mastra-client.ts" showLineNumbers copy
|
|
80
|
+
import { MastraClient } from "@mastra/client-js";
|
|
81
|
+
|
|
82
|
+
export const mastraClient = new MastraClient({
|
|
83
|
+
baseUrl: "https://<mastra-api-url>",
|
|
84
|
+
headers: {
|
|
85
|
+
Authorization: `Bearer ${accessToken}`
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
> **Note:** The access token must be prefixed with `Bearer` in the Authorization header.
|
|
91
|
+
|
|
92
|
+
> See [Mastra Client SDK](/docs/server-db/mastra-client.mdx) for more configuration options.
|
|
93
|
+
|
|
94
|
+
### Making authenticated requests
|
|
95
|
+
|
|
96
|
+
Once `MastraClient` is configured with the Supabase access token, you can send authenticated requests:
|
|
97
|
+
|
|
98
|
+
<Tabs items={["MastraClient", "curl"]}>
|
|
99
|
+
<Tab>
|
|
100
|
+
```tsx filename="src/components/test-agent.tsx" showLineNumbers copy
|
|
101
|
+
import { mastraClient } from "../../lib/mastra-client";
|
|
102
|
+
|
|
103
|
+
export const TestAgent = () => {
|
|
104
|
+
async function handleClick() {
|
|
105
|
+
const agent = mastraClient.getAgent("weatherAgent");
|
|
106
|
+
|
|
107
|
+
const response = await agent.generate({
|
|
108
|
+
messages: "What's the weather like in New York"
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
console.log(response);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return <button onClick={handleClick}>Test Agent</button>;
|
|
115
|
+
};
|
|
116
|
+
```
|
|
117
|
+
</Tab>
|
|
118
|
+
<Tab>
|
|
119
|
+
```bash copy
|
|
120
|
+
curl -X POST http://localhost:4111/api/agents/weatherAgent/generate \
|
|
121
|
+
-H "Content-Type: application/json" \
|
|
122
|
+
-H "Authorization: Bearer <your-supabase-access-token>" \
|
|
123
|
+
-d '{
|
|
124
|
+
"messages": "Weather in London"
|
|
125
|
+
}'
|
|
126
|
+
```
|
|
127
|
+
</Tab>
|
|
128
|
+
</Tabs>
|
|
@@ -19,19 +19,19 @@ Mastra Cloud is a deployment platform that connects to your GitHub repository, a
|
|
|
19
19
|
- Comprehensive logs and traces
|
|
20
20
|
- Custom domains for each project
|
|
21
21
|
|
|
22
|
-
[View Mastra Cloud documentation →](
|
|
22
|
+
[View Mastra Cloud documentation →](../mastra-cloud/overview.mdx)
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
### With a Web Framework
|
|
26
26
|
|
|
27
27
|
Mastra can be integrated with a variety of web frameworks. For example, see one of the following for a detailed guide.
|
|
28
28
|
|
|
29
|
-
- [With Next.js](
|
|
30
|
-
- [With Astro](
|
|
29
|
+
- [With Next.js](../frameworks/web-frameworks/next-js.mdx)
|
|
30
|
+
- [With Astro](../frameworks/web-frameworks/astro.mdx)
|
|
31
31
|
|
|
32
32
|
When integrated with a framework, Mastra typically requires no additional configuration for deployment.
|
|
33
33
|
|
|
34
|
-
[View Web Framework Integration →](
|
|
34
|
+
[View Web Framework Integration →](./web-framework.mdx)
|
|
35
35
|
|
|
36
36
|
### With a Server
|
|
37
37
|
|
|
@@ -42,7 +42,7 @@ You can deploy Mastra as a standard Node.js HTTP server, which gives you full co
|
|
|
42
42
|
- Deploy to VMs, containers, or PaaS platforms
|
|
43
43
|
- Ideal for integrating with existing Node.js applications
|
|
44
44
|
|
|
45
|
-
[Server deployment guide →](
|
|
45
|
+
[Server deployment guide →](./server-deployment.mdx)
|
|
46
46
|
|
|
47
47
|
### Serverless Platforms
|
|
48
48
|
|
|
@@ -53,7 +53,7 @@ Mastra provides platform-specific deployers for popular serverless platforms, en
|
|
|
53
53
|
- Simplified deployment process
|
|
54
54
|
- Automatic scaling through the platform
|
|
55
55
|
|
|
56
|
-
[Serverless deployment guide →](
|
|
56
|
+
[Serverless deployment guide →](./server-deployment.mdx)
|
|
57
57
|
|
|
58
58
|
## Client Configuration
|
|
59
59
|
|
|
@@ -64,7 +64,7 @@ Once your Mastra application is deployed, you'll need to configure your client t
|
|
|
64
64
|
- Retries and error handling
|
|
65
65
|
- Support for streaming responses
|
|
66
66
|
|
|
67
|
-
[Client configuration guide →](/
|
|
67
|
+
[Client configuration guide →](../server-db/mastra-client.mdx)
|
|
68
68
|
|
|
69
69
|
## Choosing a Deployment Option
|
|
70
70
|
|
|
@@ -287,7 +287,7 @@ export const mastra = new Mastra({
|
|
|
287
287
|
});
|
|
288
288
|
```
|
|
289
289
|
|
|
290
|
-
> You can then access this data in your tools via the `runtimeContext` parameter. See the [Runtime Context documentation](/docs/agents/runtime-
|
|
290
|
+
> You can then access this data in your tools via the `runtimeContext` parameter. See the [Agent Runtime Context documentation](/docs/agents/runtime-context) for more details.
|
|
291
291
|
|
|
292
292
|
## Streaming data
|
|
293
293
|
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
2
|
+
title: "MCP Docs Server | Getting Started | Mastra Docs"
|
|
3
3
|
description: "Learn how to use the Mastra MCP documentation server in your IDE to turn it into an agentic Mastra expert."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
import YouTube from "@/components/youtube";
|
|
7
7
|
import { Tabs } from "nextra/components";
|
|
8
8
|
|
|
9
|
-
# Mastra
|
|
9
|
+
# Mastra Docs Server
|
|
10
10
|
|
|
11
|
-
`@mastra/mcp-docs-server` provides direct access to Mastra
|
|
12
|
-
|
|
13
|
-
It has access to documentation, code examples, technical blog posts / feature announcements, and package changelogs which your IDE can read to help you build with Mastra.
|
|
11
|
+
The `@mastra/mcp-docs-server` package provides direct access to Mastra’s full knowledge base, including documentation, code examples, blog posts, and changelogs, via the MCP protocol. It works with Cursor, Windsurf, Cline, Claude Code, or any tool that supports MCP.
|
|
14
12
|
|
|
15
13
|
<YouTube id="vciV57lF0og" />
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
These tools are designed to help agents retrieve precise, task-specific information—whether you're adding a feature to an agent, scaffolding a new project, or exploring how something works.
|
|
18
16
|
|
|
19
17
|
## How it works
|
|
20
18
|
|
|
21
|
-
Once
|
|
19
|
+
Once installed you can write prompts and assume the agent will understand everything about Mastra.
|
|
22
20
|
|
|
23
21
|
### Add features
|
|
24
22
|
|
|
@@ -41,18 +39,18 @@ Once it's installed in your IDE you can write prompts and assume the agent will
|
|
|
41
39
|
|
|
42
40
|
**And more** - if you have a question, try asking your IDE and let it look it up for you.
|
|
43
41
|
|
|
44
|
-
## Automatic
|
|
42
|
+
## Automatic installation
|
|
45
43
|
|
|
46
44
|
For **new** projects, the MCP Docs Server can be added during installation either through the [interactive](/docs/getting-started/installation#interactive) setup prompts, or by specifying the `-m` flag using the [non-interactive](/docs/getting-started/installation#non-interactive) command.
|
|
47
45
|
|
|
48
|
-
## Manual
|
|
46
|
+
## Manual installation
|
|
49
47
|
|
|
50
48
|
To add the MCP Docs Server to an existing project, install it manually.
|
|
51
49
|
|
|
52
50
|
- **Cursor**: Edit `.cursor/mcp.json` in your project root, or `~/.cursor/mcp.json` for global configuration
|
|
53
51
|
- **Windsurf**: Edit `~/.codeium/windsurf/mcp_config.json` (only supports global configuration)
|
|
54
|
-
- **VSCode**: Either move the created `.vscode` folder into the top-level of your workspace or open the created folder as your new workspace root. Edit `~/.vscode/mcp.json` in your project root.
|
|
55
|
-
|
|
52
|
+
- **VSCode**: Either move the created `.vscode` folder into the top-level of your workspace or open the created folder as your new workspace root. Edit `~/.vscode/mcp.json` in your project root. Add the following configuration:
|
|
53
|
+
- **Claude Code**: Run the `claude mcp add` command as shown below.
|
|
56
54
|
|
|
57
55
|
### MacOS/Linux
|
|
58
56
|
|
|
@@ -63,7 +61,7 @@ The tabs help users find the correct configuration format for their IDE (Cursor,
|
|
|
63
61
|
Each tab shows the exact JSON structure and file paths needed for that IDE's MCP configuration.
|
|
64
62
|
*/}
|
|
65
63
|
|
|
66
|
-
<Tabs items={["Cursor", "Windsurf", "VSCode"]}>
|
|
64
|
+
<Tabs items={["Cursor", "Windsurf", "VSCode", "Claude Code"]}>
|
|
67
65
|
<Tabs.Tab>
|
|
68
66
|
```json
|
|
69
67
|
{
|
|
@@ -99,6 +97,11 @@ Each tab shows the exact JSON structure and file paths needed for that IDE's MCP
|
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
99
|
}
|
|
100
|
+
```
|
|
101
|
+
</Tabs.Tab>
|
|
102
|
+
<Tabs.Tab>
|
|
103
|
+
```bash
|
|
104
|
+
claude mcp add mastra -- npx -y @mastra/mcp-docs-server
|
|
102
105
|
```
|
|
103
106
|
</Tabs.Tab>
|
|
104
107
|
</Tabs>
|
|
@@ -113,7 +116,7 @@ Each tab shows the Windows-specific command structure needed for that IDE's MCP
|
|
|
113
116
|
On latest Windsurf and Cursor the direct npx command works, while it's still unconfirmed if this has been fixed for VSCode.
|
|
114
117
|
*/}
|
|
115
118
|
|
|
116
|
-
<Tabs items={["Cursor", "Windsurf", "VSCode"]}>
|
|
119
|
+
<Tabs items={["Cursor", "Windsurf", "VSCode", "Claude Code"]}>
|
|
117
120
|
<Tabs.Tab>
|
|
118
121
|
```json
|
|
119
122
|
{
|
|
@@ -149,11 +152,16 @@ On latest Windsurf and Cursor the direct npx command works, while it's still unc
|
|
|
149
152
|
}
|
|
150
153
|
}
|
|
151
154
|
}
|
|
155
|
+
```
|
|
156
|
+
</Tabs.Tab>
|
|
157
|
+
<Tabs.Tab>
|
|
158
|
+
```bash
|
|
159
|
+
claude mcp add mastra -- npx -y @mastra/mcp-docs-server
|
|
152
160
|
```
|
|
153
161
|
</Tabs.Tab>
|
|
154
162
|
</Tabs>
|
|
155
163
|
|
|
156
|
-
## After
|
|
164
|
+
## After configuration
|
|
157
165
|
|
|
158
166
|
### Cursor
|
|
159
167
|
|
|
@@ -167,25 +175,23 @@ If you followed the automatic installation, you'll see a popup when you open cur
|
|
|
167
175
|
|
|
168
176
|
Otherwise, for manual installation, do the following.
|
|
169
177
|
|
|
170
|
-
1. Open Cursor settings
|
|
171
|
-
2. Navigate to MCP settings
|
|
172
|
-
3. Click "enable" on the Mastra MCP server
|
|
173
|
-
4. If you have an agent chat open, you'll need to re-open it or start a new chat to use the MCP server
|
|
178
|
+
1. Open Cursor settings.
|
|
179
|
+
2. Navigate to MCP settings.
|
|
180
|
+
3. Click "enable" on the Mastra MCP server.
|
|
181
|
+
4. If you have an agent chat open, you'll need to re-open it or start a new chat to use the MCP server.
|
|
174
182
|
|
|
175
183
|
### Windsurf
|
|
176
184
|
|
|
177
|
-
1. Fully quit and re-open Windsurf
|
|
185
|
+
1. Fully quit and re-open Windsurf.
|
|
178
186
|
2. If tool calls start failing, go to Windsurfs MCP settings and re-start the MCP server. This is a common Windsurf MCP issue and isn't related to Mastra. Right now Cursor's MCP implementation is more stable than Windsurfs is.
|
|
179
187
|
|
|
180
188
|
In both IDEs it may take a minute for the MCP server to start the first time as it needs to download the package from npm.
|
|
181
189
|
|
|
182
190
|
### VSCode
|
|
183
191
|
|
|
184
|
-
1. Open VSCode settings
|
|
185
|
-
2. Navigate to MCP settings
|
|
186
|
-
3. Click "enable" on the Chat > MCP option
|
|
187
|
-
|
|
188
|
-
<br />
|
|
192
|
+
1. Open VSCode settings.
|
|
193
|
+
2. Navigate to MCP settings.
|
|
194
|
+
3. Click "enable" on the Chat > MCP option.
|
|
189
195
|
|
|
190
196
|
<img
|
|
191
197
|
src="/image/vscode-mcp-setting.png"
|
|
@@ -196,7 +202,6 @@ In both IDEs it may take a minute for the MCP server to start the first time as
|
|
|
196
202
|
|
|
197
203
|
MCP only works in Agent mode in VSCode. Once you are in agent mode, open the `mcp.json` file and click the "start" button. Note that the "start" button will only appear if the `.vscode` folder containing `mcp.json` is in your workspace root, or the highest level of the in-editor file explorer.
|
|
198
204
|
|
|
199
|
-
<br />
|
|
200
205
|
<img
|
|
201
206
|
src="/image/vscode-start-mcp.png"
|
|
202
207
|
alt="Settings page of VSCode to enable MCP"
|
|
@@ -206,7 +211,6 @@ MCP only works in Agent mode in VSCode. Once you are in agent mode, open the `mc
|
|
|
206
211
|
|
|
207
212
|
After starting the mcp server, click the tools button in the copilot pane to see available tools.
|
|
208
213
|
|
|
209
|
-
<br />
|
|
210
214
|
<img
|
|
211
215
|
src="/image/vscode-mcp-running.png"
|
|
212
216
|
alt="Tools page of VSCode to see available tools"
|
|
@@ -214,49 +218,49 @@ After starting the mcp server, click the tools button in the copilot pane to see
|
|
|
214
218
|
className="rounded-lg"
|
|
215
219
|
/>
|
|
216
220
|
|
|
217
|
-
## Available
|
|
221
|
+
## Available agent tools
|
|
218
222
|
|
|
219
223
|
### Documentation
|
|
220
224
|
|
|
221
225
|
Access Mastra's complete documentation:
|
|
222
226
|
|
|
223
|
-
- Getting started / installation
|
|
224
|
-
- Guides and tutorials
|
|
225
|
-
- API references
|
|
227
|
+
- Getting started / installation.
|
|
228
|
+
- Guides and tutorials.
|
|
229
|
+
- API references.
|
|
226
230
|
|
|
227
231
|
### Examples
|
|
228
232
|
|
|
229
233
|
Browse code examples:
|
|
230
234
|
|
|
231
|
-
- Complete project structures
|
|
232
|
-
- Implementation patterns
|
|
233
|
-
- Best practices
|
|
235
|
+
- Complete project structures.
|
|
236
|
+
- Implementation patterns.
|
|
237
|
+
- Best practices.
|
|
234
238
|
|
|
235
|
-
### Blog
|
|
239
|
+
### Blog posts
|
|
236
240
|
|
|
237
241
|
Search the blog for:
|
|
238
242
|
|
|
239
|
-
- Technical posts
|
|
240
|
-
- Changelog and feature announcements
|
|
241
|
-
- AI news and updates
|
|
243
|
+
- Technical posts.
|
|
244
|
+
- Changelog and feature announcements.
|
|
245
|
+
- AI news and updates.
|
|
242
246
|
|
|
243
|
-
### Package
|
|
247
|
+
### Package changes
|
|
244
248
|
|
|
245
249
|
Track updates for Mastra and `@mastra/*` packages:
|
|
246
250
|
|
|
247
|
-
- Bug fixes
|
|
248
|
-
- New features
|
|
249
|
-
- Breaking changes
|
|
251
|
+
- Bug fixes.
|
|
252
|
+
- New features.
|
|
253
|
+
- Breaking changes.
|
|
250
254
|
|
|
251
|
-
## Common
|
|
255
|
+
## Common issues
|
|
252
256
|
|
|
253
257
|
1. **Server Not Starting**
|
|
254
258
|
|
|
255
|
-
- Ensure [npx](https://docs.npmjs.com/cli/v11/commands/npx) is installed and working
|
|
256
|
-
- Check for conflicting MCP servers
|
|
257
|
-
- Verify your configuration file syntax
|
|
258
|
-
- On Windows, make sure to use the Windows-specific configuration
|
|
259
|
+
- Ensure [npx](https://docs.npmjs.com/cli/v11/commands/npx) is installed and working.
|
|
260
|
+
- Check for conflicting MCP servers.
|
|
261
|
+
- Verify your configuration file syntax.
|
|
262
|
+
- On Windows, make sure to use the Windows-specific configuration.
|
|
259
263
|
|
|
260
264
|
2. **Tool Calls Failing**
|
|
261
|
-
- Restart the MCP server and/or your IDE
|
|
262
|
-
- Update to the latest version of your IDE
|
|
265
|
+
- Restart the MCP server and/or your IDE.
|
|
266
|
+
- Update to the latest version of your IDE.
|
|
@@ -133,7 +133,7 @@ const memory = new Memory({
|
|
|
133
133
|
});
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
**Important:** Only send the newest user message in each agent call. Mastra handles retrieving and injecting the necessary history. Sending the full history yourself will cause duplication. See the [AI SDK Memory Example](../../
|
|
136
|
+
**Important:** Only send the newest user message in each agent call. Mastra handles retrieving and injecting the necessary history. Sending the full history yourself will cause duplication. See the [AI SDK Memory Example](../../docs/frameworks/agentic-uis/ai-sdk.mdx) for how to handle this with when using the `useChat` frontend hooks.
|
|
137
137
|
|
|
138
138
|
### Storage Configuration
|
|
139
139
|
|
|
@@ -176,4 +176,4 @@ For more details on enabling and configuring tracing, see [Tracing](../observabi
|
|
|
176
176
|
|
|
177
177
|
Now that you understand the core concepts, continue to [semantic recall](./semantic-recall.mdx) to learn how to add RAG memory to your Mastra agents.
|
|
178
178
|
|
|
179
|
-
Alternatively you can visit the [configuration reference](../../reference/memory/Memory.mdx) for available options
|
|
179
|
+
Alternatively you can visit the [configuration reference](../../reference/memory/Memory.mdx) for available options.
|
|
@@ -65,4 +65,4 @@ await agent.getDefaultStreamOptions({
|
|
|
65
65
|
|
|
66
66
|
- [Generating responses](../../docs/agents/overview.mdx#generating-responses)
|
|
67
67
|
- [Streaming responses](../../docs/agents/overview.mdx#streaming-responses)
|
|
68
|
-
- [Runtime
|
|
68
|
+
- [Agent Runtime Context](../../docs/agents/runtime-context.mdx)
|
|
@@ -64,4 +64,4 @@ await agent.getDefaultVNextStreamOptions({
|
|
|
64
64
|
## Related
|
|
65
65
|
|
|
66
66
|
- [Streaming with agents](../../docs/streaming/overview.mdx#streaming-with-agents)
|
|
67
|
-
- [Runtime
|
|
67
|
+
- [Agent Runtime Context](../../docs/agents/runtime-context.mdx)
|