@mastra/mcp-docs-server 0.13.34 → 0.13.35-alpha.0

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 (38) hide show
  1. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +12 -12
  2. package/.docs/organized/changelogs/%40mastra%2Fcore.md +31 -31
  3. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +9 -9
  4. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +9 -9
  5. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +9 -9
  6. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +9 -9
  7. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +19 -19
  8. package/.docs/organized/changelogs/%40mastra%2Flance.md +10 -10
  9. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +8 -8
  10. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +11 -11
  11. package/.docs/organized/changelogs/%40mastra%2Fpg.md +10 -10
  12. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +16 -16
  13. package/.docs/organized/changelogs/%40mastra%2Freact.md +10 -10
  14. package/.docs/organized/changelogs/%40mastra%2Fserver.md +14 -14
  15. package/.docs/organized/changelogs/create-mastra.md +3 -3
  16. package/.docs/organized/changelogs/mastra.md +9 -9
  17. package/.docs/organized/code-examples/memory-with-mongodb.md +208 -0
  18. package/.docs/raw/getting-started/project-structure.mdx +1 -1
  19. package/.docs/raw/getting-started/studio.mdx +4 -4
  20. package/.docs/raw/memory/overview.mdx +1 -1
  21. package/.docs/raw/memory/semantic-recall.mdx +4 -3
  22. package/.docs/raw/memory/storage/memory-with-libsql.mdx +141 -0
  23. package/.docs/raw/memory/storage/memory-with-pg.mdx +138 -0
  24. package/.docs/raw/memory/storage/memory-with-upstash.mdx +147 -0
  25. package/.docs/raw/observability/ai-tracing/exporters/arize.mdx +201 -0
  26. package/.docs/raw/observability/ai-tracing/overview.mdx +12 -8
  27. package/.docs/raw/reference/observability/ai-tracing/exporters/arize.mdx +160 -0
  28. package/.docs/raw/reference/observability/ai-tracing/exporters/braintrust.mdx +2 -2
  29. package/.docs/raw/reference/observability/ai-tracing/exporters/langfuse.mdx +1 -1
  30. package/.docs/raw/reference/observability/ai-tracing/exporters/langsmith.mdx +2 -2
  31. package/.docs/raw/reference/observability/ai-tracing/exporters/otel.mdx +1 -1
  32. package/.docs/raw/reference/observability/ai-tracing/interfaces.mdx +48 -21
  33. package/.docs/raw/reference/storage/mongodb.mdx +146 -0
  34. package/.docs/raw/server-db/storage.mdx +1 -0
  35. package/.docs/raw/workflows/agents-and-tools.mdx +15 -1
  36. package/.docs/raw/workflows/human-in-the-loop.mdx +268 -0
  37. package/CHANGELOG.md +7 -0
  38. package/package.json +11 -4
@@ -0,0 +1,146 @@
1
+ ---
2
+ title: "MongoDB Storage | Storage System | Mastra Core"
3
+ description: Documentation for the MongoDB storage implementation in Mastra.
4
+ ---
5
+
6
+ # MongoDB Storage
7
+
8
+ The MongoDB storage implementation provides a scalable storage solution using MongoDB databases with support for both document storage and vector operations.
9
+
10
+ ## Installation
11
+
12
+ ```bash copy
13
+ npm install @mastra/mongodb@latest
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ Ensure you have a MongoDB Atlas Local (via Docker) or MongoDB Atlas Cloud instance with Atlas Search enabled. MongoDB 7.0+ is recommended.
19
+
20
+ ```typescript copy showLineNumbers
21
+ import { MongoDBStore } from "@mastra/mongodb";
22
+
23
+ const storage = new MongoDBStore({
24
+ url: process.env.MONGODB_URL,
25
+ dbName: process.env.MONGODB_DATABASE,
26
+ });
27
+ ```
28
+
29
+ ## Parameters
30
+
31
+ <PropertiesTable
32
+ content={[
33
+ {
34
+ name: "url",
35
+ type: "string",
36
+ description:
37
+ "MongoDB connection string (e.g., mongodb+srv://user:password@cluster.mongodb.net)",
38
+ isOptional: false,
39
+ },
40
+ {
41
+ name: "dbName",
42
+ type: "string",
43
+ description:
44
+ "The name of the database you want the storage to use.",
45
+ isOptional: false,
46
+ },
47
+ {
48
+ name: "options",
49
+ type: "MongoClientOptions",
50
+ description:
51
+ "MongoDB client options for advanced configuration (SSL, connection pooling, etc.). See advanced configuration [here](https://www.mongodb.com/docs/drivers/node/current/connect/connection-options/).",
52
+ isOptional: true,
53
+ }
54
+ ]}
55
+ />
56
+
57
+ ## Constructor Examples
58
+
59
+ You can instantiate `MongoDBStore` in the following ways:
60
+
61
+ ```ts
62
+ import { MongoDBStore } from "@mastra/mongodb";
63
+
64
+ // Basic connection without custom options
65
+ const store1 = new MongoDBStore({
66
+ url: "mongodb+srv://user:password@cluster.mongodb.net",
67
+ dbName: "mastra_storage",
68
+ });
69
+
70
+ // Using connection string with options
71
+ const store2 = new MongoDBStore({
72
+ url: "mongodb+srv://user:password@cluster.mongodb.net",
73
+ dbName: "mastra_storage",
74
+ options: {
75
+ retryWrites: true,
76
+ maxPoolSize: 10,
77
+ serverSelectionTimeoutMS: 5000,
78
+ socketTimeoutMS: 45000,
79
+ },
80
+ });
81
+ ```
82
+
83
+ ## Additional Notes
84
+
85
+ ### Collection Management
86
+
87
+ The storage implementation handles collection creation and management automatically. It creates the following collections:
88
+
89
+ - `mastra_workflow_snapshot`: Stores workflow state and execution data
90
+ - `mastra_evals`: Stores evaluation results and metadata
91
+ - `mastra_threads`: Stores conversation threads
92
+ - `mastra_messages`: Stores individual messages
93
+ - `mastra_traces`: Stores telemetry and tracing data
94
+ - `mastra_scorers`: Stores scoring and evaluation data
95
+ - `mastra_resources`: Stores resource working memory data
96
+
97
+ ## Vector Search Capabilities
98
+
99
+ MongoDB storage includes built-in vector search capabilities for AI applications:
100
+
101
+ ### Vector Index Creation
102
+
103
+ ```typescript copy
104
+ import { MongoDBVector } from "@mastra/mongodb";
105
+
106
+ const vectorStore = new MongoDBVector({
107
+ url: process.env.MONGODB_URL,
108
+ dbName: process.env.MONGODB_DATABASE,
109
+ });
110
+
111
+ // Create a vector index for embeddings
112
+ await vectorStore.createIndex({
113
+ indexName: "document_embeddings",
114
+ dimension: 1536,
115
+ });
116
+ ```
117
+
118
+ ### Vector Operations
119
+
120
+ ```typescript copy
121
+ // Store vectors with metadata
122
+ await vectorStore.upsert({
123
+ indexName: "document_embeddings",
124
+ vectors: [
125
+ {
126
+ id: "doc-1",
127
+ values: [0.1, 0.2, 0.3, ...], // 1536-dimensional vector
128
+ metadata: {
129
+ title: "Document Title",
130
+ category: "technical",
131
+ source: "api-docs",
132
+ },
133
+ },
134
+ ],
135
+ });
136
+
137
+ // Similarity search
138
+ const results = await vectorStore.query({
139
+ indexName: "document_embeddings",
140
+ vector: queryEmbedding,
141
+ topK: 5,
142
+ filter: {
143
+ category: "technical",
144
+ },
145
+ });
146
+ ```
@@ -512,3 +512,4 @@ Mastra supports the following providers:
512
512
  - For local development, check out [LibSQL Storage](../../reference/storage/libsql.mdx)
513
513
  - For production, check out [PostgreSQL Storage](../../reference/storage/postgresql.mdx)
514
514
  - For serverless deployments, check out [Upstash Storage](../../reference/storage/upstash.mdx)
515
+ - For document-based storage, check out [MongoDB Storage](../../reference/storage/mongodb.mdx)
@@ -63,7 +63,21 @@ export const testWorkflow = createWorkflow({
63
63
  .commit();
64
64
  ```
65
65
 
66
- > See [Input Data Mapping](./input-data-mapping.mdx) for more information.
66
+ > See [Input Data Mapping](./input-data-mapping.mdx) for more information.
67
+
68
+ Mastra agents use a default schema that expects a `prompt` string as input and returns a `text` string as output:
69
+
70
+ ```json
71
+ {
72
+ inputSchema: {
73
+ prompt: string
74
+ },
75
+ outputSchema: {
76
+ text: string
77
+ }
78
+ }
79
+ ```
80
+
67
81
 
68
82
  ## Using tools in workflows
69
83
 
@@ -0,0 +1,268 @@
1
+ ---
2
+ title: "Human in the Loop | Workflows | Mastra Docs"
3
+ description: Example of using Mastra to create workflows with multi-turn human/agent interaction points using suspend/resume and dountil methods.
4
+ ---
5
+
6
+ import { GithubLink } from "@/components/github-link";
7
+
8
+ # Human-in-the-loop
9
+
10
+ Human-in-the-loop workflows enable ongoing interaction between humans and AI agents, allowing for complex decision-making processes that require multiple rounds of input and response. These workflows can suspend execution at specific points, wait for human input, and continue processing based on the responses received.
11
+
12
+ In this example, the multi-turn workflow is used to create a Heads Up game that demonstrates how to create interactive workflows using suspend/resume functionality and conditional logic with `dountil` to repeat a workflow step until a specific condition is met.
13
+
14
+ This example consists of three main components:
15
+
16
+ 1. A [**Famous Person Agent**](#famous-person-agent) that generates a famous person's name.
17
+ 2. A [**Game Agent**](#game-agent) that handles the gameplay.
18
+ 3. A [**Multi-Turn Workflow**](#multi-turn-workflow) that orchestrates the interaction.
19
+
20
+ ## Prerequisites
21
+
22
+ This example uses the `openai` model. Make sure to add the following to your `.env` file:
23
+
24
+ ```bash filename=".env" copy
25
+ OPENAI_API_KEY=<your-api-key>
26
+ ```
27
+
28
+ ## Famous person agent
29
+
30
+ The `famousPersonAgent` generates a unique name each time the game is played, using semantic memory to avoid repeating suggestions.
31
+
32
+ ```typescript filename="src/mastra/agents/example-famous-person-agent.ts" showLineNumbers copy
33
+ import { openai } from "@ai-sdk/openai";
34
+ import { Agent } from "@mastra/core/agent";
35
+ import { Memory } from "@mastra/memory";
36
+ import { LibSQLVector } from "@mastra/libsql";
37
+
38
+ export const famousPersonAgent = new Agent({
39
+ name: "Famous Person Generator",
40
+ instructions: `You are a famous person generator for a "Heads Up" guessing game.
41
+
42
+ Generate the name of a well-known famous person who:
43
+ - Is recognizable to most people
44
+ - Has distinctive characteristics that can be described with yes/no questions
45
+ - Is appropriate for all audiences
46
+ - Has a clear, unambiguous name
47
+
48
+ IMPORTANT: Use your memory to check what famous people you've already suggested and NEVER repeat a person you've already suggested.
49
+
50
+ Examples: Albert Einstein, Beyoncé, Leonardo da Vinci, Oprah Winfrey, Michael Jordan
51
+
52
+ Return only the person's name, nothing else.`,
53
+ model: openai("gpt-4o"),
54
+ memory: new Memory({
55
+ vector: new LibSQLVector({
56
+ connectionUrl: "file:../mastra.db"
57
+ }),
58
+ embedder: openai.embedding("text-embedding-3-small"),
59
+ options: {
60
+ lastMessages: 5,
61
+ semanticRecall: {
62
+ topK: 10,
63
+ messageRange: 1
64
+ }
65
+ }
66
+ })
67
+ });
68
+ ```
69
+
70
+ > See [Agent](../../reference/agents/agent.mdx) for a full list of configuration options.
71
+
72
+ ## Game agent
73
+
74
+ The `gameAgent` handles user interactions by responding to questions and validating guesses.
75
+
76
+ ```typescript filename="src/mastra/agents/example-game-agent.ts" showLineNumbers copy
77
+ import { openai } from "@ai-sdk/openai";
78
+ import { Agent } from "@mastra/core/agent";
79
+
80
+ export const gameAgent = new Agent({
81
+ name: "Game Agent",
82
+ instructions: `You are a helpful game assistant for a "Heads Up" guessing game.
83
+
84
+ CRITICAL: You know the famous person's name but you must NEVER reveal it in any response.
85
+
86
+ When a user asks a question about the famous person:
87
+ - Answer truthfully based on the famous person provided
88
+ - Keep responses concise and friendly
89
+ - NEVER mention the person's name, even if it seems natural
90
+ - NEVER reveal gender, nationality, or other characteristics unless specifically asked about them
91
+ - Answer yes/no questions with clear "Yes" or "No" responses
92
+ - Be consistent - same question asked differently should get the same answer
93
+ - Ask for clarification if a question is unclear
94
+ - If multiple questions are asked at once, ask them to ask one at a time
95
+
96
+ When they make a guess:
97
+ - If correct: Congratulate them warmly
98
+ - If incorrect: Politely correct them and encourage them to try again
99
+
100
+ Encourage players to make a guess when they seem to have enough information.
101
+
102
+ You must return a JSON object with:
103
+ - response: Your response to the user
104
+ - gameWon: true if they guessed correctly, false otherwise`,
105
+ model: openai("gpt-4o")
106
+ });
107
+ ```
108
+
109
+
110
+ ## Multi-turn workflow
111
+
112
+ The workflow coordinates the full interaction using `suspend`/`resume` to pause for human input and `dountil` to repeat the game loop until a condition is met.
113
+
114
+ The `startStep` generates a name using the `famousPersonAgent`, while the `gameStep` runs the interaction through the `gameAgent`, which handles both questions and guesses and produces structured output that includes a `gameWon` boolean.
115
+
116
+ ```typescript filename="src/mastra/workflows/example-heads-up-workflow.ts" showLineNumbers copy
117
+ import { createWorkflow, createStep } from '@mastra/core/workflows';
118
+ import { z } from 'zod';
119
+
120
+ const startStep = createStep({
121
+ id: 'start-step',
122
+ description: 'Get the name of a famous person',
123
+ inputSchema: z.object({
124
+ start: z.boolean(),
125
+ }),
126
+ outputSchema: z.object({
127
+ famousPerson: z.string(),
128
+ guessCount: z.number(),
129
+ }),
130
+ execute: async ({ mastra }) => {
131
+ const agent = mastra.getAgent('famousPersonAgent');
132
+ const response = await agent.generate("Generate a famous person's name", {
133
+ temperature: 1.2,
134
+ topP: 0.9,
135
+ memory: {
136
+ resource: 'heads-up-game',
137
+ thread: 'famous-person-generator',
138
+ },
139
+ });
140
+ const famousPerson = response.text.trim();
141
+ return { famousPerson, guessCount: 0 };
142
+ },
143
+ });
144
+
145
+ const gameStep = createStep({
146
+ id: 'game-step',
147
+ description: 'Handles the question-answer-continue loop',
148
+ inputSchema: z.object({
149
+ famousPerson: z.string(),
150
+ guessCount: z.number(),
151
+ }),
152
+ resumeSchema: z.object({
153
+ userMessage: z.string(),
154
+ }),
155
+ suspendSchema: z.object({
156
+ suspendResponse: z.string(),
157
+ }),
158
+ outputSchema: z.object({
159
+ famousPerson: z.string(),
160
+ gameWon: z.boolean(),
161
+ agentResponse: z.string(),
162
+ guessCount: z.number(),
163
+ }),
164
+ execute: async ({ inputData, mastra, resumeData, suspend }) => {
165
+ let { famousPerson, guessCount } = inputData;
166
+ const { userMessage } = resumeData ?? {};
167
+
168
+ if (!userMessage) {
169
+ return await suspend({
170
+ suspendResponse: "I'm thinking of a famous person. Ask me yes/no questions to figure out who it is!",
171
+ });
172
+ }
173
+
174
+ const agent = mastra.getAgent('gameAgent');
175
+ const response = await agent.generate(
176
+ `
177
+ The famous person is: ${famousPerson}
178
+ The user said: "${userMessage}"
179
+ Please respond appropriately. If this is a guess, tell me if it's correct.
180
+ `,
181
+ {
182
+ structuredOutput: {
183
+ schema: z.object({
184
+ response: z.string(),
185
+ gameWon: z.boolean(),
186
+ })
187
+ },
188
+ },
189
+ );
190
+
191
+ const { response: agentResponse, gameWon } = response.object;
192
+
193
+ guessCount++;
194
+
195
+ return { famousPerson, gameWon, agentResponse, guessCount };
196
+ },
197
+ });
198
+
199
+ const winStep = createStep({
200
+ id: 'win-step',
201
+ description: 'Handle game win logic',
202
+ inputSchema: z.object({
203
+ famousPerson: z.string(),
204
+ gameWon: z.boolean(),
205
+ agentResponse: z.string(),
206
+ guessCount: z.number(),
207
+ }),
208
+ outputSchema: z.object({
209
+ famousPerson: z.string(),
210
+ gameWon: z.boolean(),
211
+ guessCount: z.number(),
212
+ }),
213
+ execute: async ({ inputData }) => {
214
+ const { famousPerson, gameWon, guessCount } = inputData;
215
+
216
+ console.log('famousPerson: ', famousPerson);
217
+ console.log('gameWon: ', gameWon);
218
+ console.log('guessCount: ', guessCount);
219
+
220
+ return { famousPerson, gameWon, guessCount };
221
+ },
222
+ });
223
+
224
+ export const headsUpWorkflow = createWorkflow({
225
+ id: 'heads-up-workflow',
226
+ inputSchema: z.object({
227
+ start: z.boolean(),
228
+ }),
229
+ outputSchema: z.object({
230
+ famousPerson: z.string(),
231
+ gameWon: z.boolean(),
232
+ guessCount: z.number(),
233
+ }),
234
+ })
235
+ .then(startStep)
236
+ .dountil(gameStep, async ({ inputData: { gameWon } }) => gameWon)
237
+ .then(winStep)
238
+ .commit();
239
+
240
+ ```
241
+ > See [Workflow](../../reference/workflows/workflow.mdx) for a full list of configuration options.
242
+
243
+ ## Registering the agents and workflow
244
+
245
+ To use a workflow or an agent, register them in your main Mastra instance.
246
+
247
+ ```typescript filename="src/mastra/index.ts" showLineNumbers copy
248
+ import { Mastra } from "@mastra/core/mastra";
249
+
250
+ import { headsUpWorkflow } from "./workflows/example-heads-up-workflow";
251
+ import { famousPersonAgent } from "./agents/example-famous-person-agent";
252
+ import { gameAgent } from "./agents/example-game-agent";
253
+
254
+ export const mastra = new Mastra({
255
+ workflows: { headsUpWorkflow },
256
+ agents: { famousPersonAgent, gameAgent }
257
+ });
258
+ ```
259
+
260
+ <GithubLink
261
+ marginTop='mt-16'
262
+ link="https://github.com/mastra-ai/mastra/blob/main/examples/heads-up-game/"
263
+ />
264
+
265
+ ## Related
266
+
267
+ - [Running Workflows](./running-workflows.mdx)
268
+ - [Control Flow](../../docs/workflows/control-flow.mdx)
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @mastra/mcp-docs-server
2
2
 
3
+ ## 0.13.35-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`f743dbb`](https://github.com/mastra-ai/mastra/commit/f743dbb8b40d1627b5c10c0e6fc154f4ebb6e394), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`2060766`](https://github.com/mastra-ai/mastra/commit/20607667bf78ea104cca3e15dfb93ae0b62c9d18), [`2c4438b`](https://github.com/mastra-ai/mastra/commit/2c4438b87817ab7eed818c7990fef010475af1a3)]:
8
+ - @mastra/core@0.23.0-alpha.0
9
+
3
10
  ## 0.13.34
4
11
 
5
12
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp-docs-server",
3
- "version": "0.13.34",
3
+ "version": "0.13.35-alpha.0",
4
4
  "description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -33,7 +33,7 @@
33
33
  "uuid": "^11.1.0",
34
34
  "zod": "^3.25.76",
35
35
  "zod-to-json-schema": "^3.24.6",
36
- "@mastra/core": "0.22.2",
36
+ "@mastra/core": "0.23.0-alpha.0",
37
37
  "@mastra/mcp": "^0.14.0"
38
38
  },
39
39
  "devDependencies": {
@@ -49,8 +49,8 @@
49
49
  "tsx": "^4.19.4",
50
50
  "typescript": "^5.8.3",
51
51
  "vitest": "^3.2.4",
52
- "@internal/lint": "0.0.53",
53
- "@mastra/core": "0.22.2"
52
+ "@mastra/core": "0.23.0-alpha.0",
53
+ "@internal/lint": "0.0.53"
54
54
  },
55
55
  "homepage": "https://mastra.ai",
56
56
  "repository": {
@@ -61,6 +61,13 @@
61
61
  "bugs": {
62
62
  "url": "https://github.com/mastra-ai/mastra/issues"
63
63
  },
64
+ "publishConfig": {
65
+ "access": "public",
66
+ "publish-branch": [
67
+ "main",
68
+ "0.x"
69
+ ]
70
+ },
64
71
  "scripts": {
65
72
  "prepare-docs": "cross-env PREPARE=true node dist/prepare-docs/prepare.js",
66
73
  "build:cli": "tsup src/stdio.ts src/prepare-docs/prepare.ts --format esm --no-dts --treeshake=smallest --splitting && tsc -p tsconfig.build.json",