@mastra/mcp-docs-server 0.13.5 → 0.13.6

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 (80) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +76 -76
  2. package/.docs/organized/changelogs/%40mastra%2Fagui.md +61 -61
  3. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +54 -54
  4. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +194 -194
  5. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +75 -75
  6. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +91 -91
  7. package/.docs/organized/changelogs/%40mastra%2Fcore.md +171 -171
  8. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +237 -237
  9. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +143 -143
  10. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +143 -143
  11. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +233 -233
  12. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +84 -84
  13. package/.docs/organized/changelogs/%40mastra%2Fevals.md +56 -56
  14. package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +7 -0
  15. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +62 -62
  16. package/.docs/organized/changelogs/%40mastra%2Flance.md +55 -0
  17. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +56 -56
  18. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +25 -25
  19. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +25 -25
  20. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +119 -119
  21. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +58 -58
  22. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +69 -0
  23. package/.docs/organized/changelogs/%40mastra%2Fpg.md +119 -119
  24. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +244 -244
  25. package/.docs/organized/changelogs/%40mastra%2Frag.md +61 -61
  26. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +18 -0
  27. package/.docs/organized/changelogs/%40mastra%2Fserver.md +195 -195
  28. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +76 -76
  29. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +44 -44
  30. package/.docs/organized/changelogs/create-mastra.md +119 -119
  31. package/.docs/organized/changelogs/mastra.md +256 -256
  32. package/.docs/organized/code-examples/agent.md +6 -0
  33. package/.docs/organized/code-examples/agui.md +3 -3
  34. package/.docs/organized/code-examples/ai-sdk-useChat.md +2 -2
  35. package/.docs/organized/code-examples/ai-sdk-v5.md +201 -0
  36. package/.docs/organized/code-examples/assistant-ui.md +2 -2
  37. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +2 -2
  38. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +2 -2
  39. package/.docs/organized/code-examples/client-side-tools.md +1 -1
  40. package/.docs/organized/code-examples/crypto-chatbot.md +5 -5
  41. package/.docs/organized/code-examples/openapi-spec-writer.md +2 -2
  42. package/.docs/organized/code-examples/workflow-with-suspend-resume.md +181 -0
  43. package/.docs/raw/agents/agent-memory.mdx +126 -0
  44. package/.docs/raw/agents/dynamic-agents.mdx +34 -2
  45. package/.docs/raw/agents/overview.mdx +5 -0
  46. package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +60 -26
  47. package/.docs/raw/deployment/cloud-providers/index.mdx +44 -9
  48. package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +9 -30
  49. package/.docs/raw/deployment/serverless-platforms/index.mdx +13 -13
  50. package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +291 -216
  51. package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +0 -34
  52. package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +162 -181
  53. package/.docs/raw/frameworks/servers/express.mdx +1 -1
  54. package/.docs/raw/frameworks/web-frameworks/astro.mdx +2 -2
  55. package/.docs/raw/frameworks/web-frameworks/next-js.mdx +1 -1
  56. package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +4 -4
  57. package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +1 -1
  58. package/.docs/raw/getting-started/installation.mdx +10 -7
  59. package/.docs/raw/getting-started/model-capability.mdx +1 -1
  60. package/.docs/raw/memory/overview.mdx +8 -0
  61. package/.docs/raw/memory/semantic-recall.mdx +6 -0
  62. package/.docs/raw/observability/tracing.mdx +30 -0
  63. package/.docs/raw/reference/agents/agent.mdx +2 -2
  64. package/.docs/raw/reference/cli/create-mastra.mdx +7 -0
  65. package/.docs/raw/reference/cli/dev.mdx +4 -3
  66. package/.docs/raw/reference/client-js/agents.mdx +8 -0
  67. package/.docs/raw/reference/memory/query.mdx +35 -14
  68. package/.docs/raw/reference/observability/providers/keywordsai.mdx +73 -0
  69. package/.docs/raw/reference/storage/mssql.mdx +108 -0
  70. package/.docs/raw/server-db/custom-api-routes.mdx +38 -26
  71. package/.docs/raw/tools-mcp/mcp-overview.mdx +24 -1
  72. package/.docs/raw/workflows/control-flow.mdx +85 -87
  73. package/.docs/raw/workflows/input-data-mapping.mdx +31 -43
  74. package/.docs/raw/workflows/overview.mdx +22 -12
  75. package/.docs/raw/workflows/pausing-execution.mdx +49 -4
  76. package/.docs/raw/workflows/suspend-and-resume.mdx +17 -16
  77. package/.docs/raw/workflows/using-with-agents-and-tools.mdx +16 -13
  78. package/.docs/raw/workflows-legacy/overview.mdx +11 -0
  79. package/package.json +6 -8
  80. package/.docs/raw/frameworks/ai-sdk-v5.mdx +0 -91
@@ -79,7 +79,7 @@ OPENAI_API_KEY=<your-api-key>
79
79
  ```
80
80
  > This example uses OpenAI. Each LLM provider uses a unique name. See [Model Capabilities](/docs/getting-started/model-capability) for more information.
81
81
 
82
- You can now launch the [Mastra Development Server](/docs/local-dev/mastra-dev) and test your agent using the Mastra Playground.
82
+ You can now launch the [Mastra Development Server](/docs/server-db/local-dev-playground) and test your agent using the Mastra Playground.
83
83
 
84
84
  </Steps>
85
85
 
@@ -114,7 +114,7 @@ This helps users manually set up a Mastra project with their preferred package m
114
114
 
115
115
  npm install typescript tsx @types/node mastra@latest --save-dev
116
116
 
117
- npm install @mastra/core@latest zod @ai-sdk/openai
117
+ npm install @mastra/core@latest zod@^3 @ai-sdk/openai
118
118
  ```
119
119
 
120
120
  </Tab>
@@ -124,7 +124,7 @@ This helps users manually set up a Mastra project with their preferred package m
124
124
 
125
125
  pnpm add typescript tsx @types/node mastra@latest --save-dev
126
126
 
127
- pnpm add @mastra/core@latest zod @ai-sdk/openai
127
+ pnpm add @mastra/core@latest zod@^3 @ai-sdk/openai
128
128
  ```
129
129
 
130
130
  </Tab>
@@ -134,7 +134,7 @@ This helps users manually set up a Mastra project with their preferred package m
134
134
 
135
135
  yarn add typescript tsx @types/node mastra@latest --dev
136
136
 
137
- yarn add @mastra/core@latest zod @ai-sdk/openai
137
+ yarn add @mastra/core@latest zod@^3 @ai-sdk/openai
138
138
  ```
139
139
 
140
140
  </Tab>
@@ -144,7 +144,7 @@ This helps users manually set up a Mastra project with their preferred package m
144
144
 
145
145
  bun add typescript tsx @types/node mastra@latest --dev
146
146
 
147
- bun add @mastra/core@latest zod @ai-sdk/openai
147
+ bun add @mastra/core@latest zod@^3 @ai-sdk/openai
148
148
  ```
149
149
 
150
150
  </Tab>
@@ -295,7 +295,7 @@ export const mastra = new Mastra({
295
295
  });
296
296
  ```
297
297
 
298
- You can now launch the [Mastra Development Server](/docs/local-dev/mastra-dev) and test your agent using the Mastra Playground.
298
+ You can now launch the [Mastra Development Server](/docs/server-db/local-dev-playground) and test your agent using the Mastra Playground.
299
299
 
300
300
  </Steps>
301
301
 
@@ -317,5 +317,8 @@ To install Mastra in an existing project, use the `mastra init` command.
317
317
 
318
318
  ## Next steps
319
319
 
320
- - [Local Development](/docs/local-dev/mastra-dev)
320
+ - [Local Development](/docs/server-db/local-dev-playground)
321
321
  - [Deploy to Mastra Cloud](/docs/deployment/overview)
322
+
323
+
324
+ /docs/server-db/local-dev-playground
@@ -1,4 +1,4 @@
1
- ## Model Capabilities
1
+ # Model Capabilities
2
2
 
3
3
  import { ProviderTable } from "@/components/provider-table";
4
4
 
@@ -156,6 +156,14 @@ const agent = new Agent({
156
156
  - [Postgres](/examples/memory/memory-with-pg)
157
157
  - [Upstash](/examples/memory/memory-with-upstash)
158
158
 
159
+ ## Viewing Retrieved Messages
160
+
161
+ If tracing is enabled in your Mastra deployment and memory is configured either with `lastMessages` and/or `semanticRecall`, the agent’s trace output will show all messages retrieved for context—including both recent conversation history and messages recalled via semantic recall.
162
+
163
+ This is helpful for debugging, understanding agent decisions, and verifying that the agent is retrieving the right information for each request.
164
+
165
+ For more details on enabling and configuring tracing, see [Tracing](../observability/tracing).
166
+
159
167
  ## Next Steps
160
168
 
161
169
  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.
@@ -149,3 +149,9 @@ You might want to disable semantic recall in scenarios like:
149
149
 
150
150
  - When conversation history provide sufficient context for the current conversation.
151
151
  - In performance-sensitive applications, like realtime two-way audio, where the added latency of creating embeddings and running vector queries is noticeable.
152
+
153
+ ## Viewing Recalled Messages
154
+
155
+ When tracing is enabled, any messages retrieved via semantic recall will appear in the agent’s trace output, alongside recent conversation history (if configured).
156
+
157
+ For more info on viewing message traces, see [Viewing Retrieved Messages](./overview.mdx#viewing-retrieved-messages).
@@ -105,6 +105,36 @@ Here's what a traced agent interaction looks like in [SigNoz](https://signoz.io)
105
105
 
106
106
  For a complete list of supported observability providers and their configuration details, see the [Observability Providers reference](../../reference/observability/providers/).
107
107
 
108
+ ### Custom Instrumentation files
109
+
110
+ You can define custom instrumentation files in your Mastra project by placing them in the `/mastra` folder. Mastra automatically detects and bundles these files instead of using the default instrumentation.
111
+
112
+ #### Supported File Types
113
+
114
+ Mastra looks for instrumentation files with these extensions:
115
+ - `instrumentation.js`
116
+ - `instrumentation.ts`
117
+ - `instrumentation.mjs`
118
+
119
+ #### Example
120
+
121
+ ```ts filename="/mastra/instrumentation.ts" showLineNumbers copy
122
+ import { NodeSDK } from '@opentelemetry/sdk-node';
123
+ import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
124
+ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
125
+
126
+ const sdk = new NodeSDK({
127
+ traceExporter: new OTLPTraceExporter({
128
+ url: 'http://localhost:4318/v1/traces',
129
+ }),
130
+ instrumentations: [getNodeAutoInstrumentations()],
131
+ });
132
+
133
+ sdk.start();
134
+ ```
135
+
136
+ When Mastra finds a custom instrumentation file, it automatically replaces the default instrumentation and bundles it during the build process.
137
+
108
138
  ### Next.js-specific Tracing steps
109
139
 
110
140
  If you're using Next.js, you have three additional configuration steps:
@@ -88,10 +88,10 @@ constructor(config: AgentConfig<TAgentId, TTools, TMetrics>)
88
88
  },
89
89
  {
90
90
  name: "memory",
91
- type: "MastraMemory",
91
+ type: "MastraMemory | ({ runtimeContext: RuntimeContext }) => MastraMemory | Promise<MastraMemory>",
92
92
  isOptional: true,
93
93
  description:
94
- "Memory system for the agent to store and retrieve information.",
94
+ "Memory system for the agent to store and retrieve information. Can be a static memory instance or a function that returns a memory instance based on runtime context.",
95
95
  },
96
96
  {
97
97
  name: "voice",
@@ -68,6 +68,13 @@ create-mastra [options]
68
68
  description: "Do not include example code",
69
69
  isOptional: true,
70
70
  },
71
+ {
72
+ name: "--template",
73
+ type: "string",
74
+ description:
75
+ "Create project from a template (use template name, public GitHub URL, or leave blank to select from list)",
76
+ isOptional: true,
77
+ },
71
78
  {
72
79
  name: "--timeout",
73
80
  type: "number",
@@ -44,13 +44,13 @@ mastra dev [options]
44
44
  },
45
45
  {
46
46
  name: "--env",
47
- type: "string",
47
+ type: "string",
48
48
  description: "Path to custom environment file",
49
49
  isOptional: true,
50
50
  },
51
51
  {
52
52
  name: "--inspect",
53
- type: "boolean",
53
+ type: "boolean",
54
54
  description: "Start the dev server in inspect mode for debugging (cannot be used with --inspect-brk)",
55
55
  isOptional: true,
56
56
  },
@@ -123,6 +123,7 @@ Workflows are expected to be exported from `src/mastra/workflows` (or the config
123
123
  - **GET `/api/memory/threads`**: Get all threads.
124
124
  - **GET `/api/memory/threads/:threadId`**: Get thread by ID.
125
125
  - **GET `/api/memory/threads/:threadId/messages`**: Get messages for a thread.
126
+ - **GET `/api/memory/threads/:threadId/messages/paginated`**: Get paginated messages for a thread.
126
127
  - **POST `/api/memory/threads`**: Create a new thread.
127
128
  - **PATCH `/api/memory/threads/:threadId`**: Update a thread.
128
129
  - **DELETE `/api/memory/threads/:threadId`**: Delete a thread.
@@ -154,7 +155,7 @@ Workflows are expected to be exported from `src/mastra/workflows` (or the config
154
155
 
155
156
  ## Additional Notes
156
157
 
157
- The port defaults to 4111. Both the port and hostname can be configured via the mastra server config. See [Launch Development Server](/docs/local-dev/mastra-dev#launch-development-server) for configuration details.
158
+ The port defaults to 4111. Both the port and hostname can be configured via the mastra server config. See [Launch Development Server](/docs/server-db/local-dev-playground) for configuration details.
158
159
 
159
160
  Make sure you have your environment variables set up in your `.env.development` or `.env` file for any providers you use (e.g., `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, etc.).
160
161
 
@@ -89,6 +89,14 @@ response.processDataStream({
89
89
  },
90
90
  });
91
91
 
92
+ // Process text stream with the processTextStream util
93
+ // (used with structured output)
94
+ response.processTextStream({
95
+ onTextPart: text => {
96
+ process.stdout.write(text);
97
+ },
98
+ });
99
+
92
100
  // You can also read from response body directly
93
101
  const reader = response.body.getReader();
94
102
  while (true) {
@@ -1,6 +1,6 @@
1
1
  # query
2
2
 
3
- Retrieves messages from a specific thread, with support for pagination and filtering options.
3
+ Retrieves messages from a specific thread, with support for pagination, filtering options, and semantic search.
4
4
 
5
5
  ## Usage Example
6
6
 
@@ -12,7 +12,7 @@ const memory = new Memory({
12
12
  });
13
13
 
14
14
  // Get last 50 messages
15
- const { messages, uiMessages } = await memory.query({
15
+ const { messages, uiMessages, messagesV2 } = await memory.query({
16
16
  threadId: "thread-123",
17
17
  selectBy: {
18
18
  last: 50,
@@ -43,7 +43,7 @@ const { messages } = await memory.query({
43
43
  vectorSearchString: "What was discussed about deployment?",
44
44
  },
45
45
  threadConfig: {
46
- historySearch: true,
46
+ semanticRecall: true,
47
47
  },
48
48
  });
49
49
  ```
@@ -69,13 +69,13 @@ const { messages } = await memory.query({
69
69
  {
70
70
  name: "selectBy",
71
71
  type: "object",
72
- description: "Options for filtering messages",
72
+ description: "Options for filtering and selecting messages",
73
73
  isOptional: true,
74
74
  },
75
75
  {
76
76
  name: "threadConfig",
77
77
  type: "MemoryConfig",
78
- description: "Configuration options for message retrieval",
78
+ description: "Configuration options for message retrieval and semantic search",
79
79
  isOptional: true,
80
80
  },
81
81
  ]}
@@ -88,7 +88,7 @@ const { messages } = await memory.query({
88
88
  {
89
89
  name: "vectorSearchString",
90
90
  type: "string",
91
- description: "Search string for finding semantically similar messages",
91
+ description: "Search string for finding semantically similar messages. Requires semantic recall to be enabled in threadConfig.",
92
92
  isOptional: true,
93
93
  },
94
94
  {
@@ -102,9 +102,9 @@ const { messages } = await memory.query({
102
102
  {
103
103
  name: "include",
104
104
  type: "array",
105
- description: "Array of message IDs to include with context",
105
+ description: "Array of specific message IDs to include with optional context messages",
106
106
  isOptional: true,
107
- },
107
+ }
108
108
  ]}
109
109
  />
110
110
 
@@ -118,6 +118,12 @@ const { messages } = await memory.query({
118
118
  description: "ID of the message to include",
119
119
  isOptional: false,
120
120
  },
121
+ {
122
+ name: "threadId",
123
+ type: "string",
124
+ description: "Optional thread ID (defaults to the main threadId parameter)",
125
+ isOptional: true,
126
+ },
121
127
  {
122
128
  name: "withPreviousMessages",
123
129
  type: "number",
@@ -142,22 +148,37 @@ const { messages } = await memory.query({
142
148
  {
143
149
  name: "messages",
144
150
  type: "CoreMessage[]",
145
- description: "Array of retrieved messages in their core format",
151
+ description: "Array of retrieved messages in their core format (v1 format for backwards compatibility)",
146
152
  },
147
153
  {
148
154
  name: "uiMessages",
149
- type: "AiMessage[]",
150
- description: "Array of messages formatted for UI display",
155
+ type: "UIMessage[]",
156
+ description: "Array of messages formatted for UI display, including proper threading of tool calls and results",
157
+ },
158
+ {
159
+ name: "messagesV2",
160
+ type: "MastraMessageV2[]",
161
+ description: "Array of messages in the v2 format, the current internal message format",
151
162
  },
152
163
  ]}
153
164
  />
154
165
 
155
166
  ## Additional Notes
156
167
 
157
- The `query` function returns two different message formats:
168
+ The `query` function returns three different message formats:
169
+
170
+ - `messages`: Core message format (v1) used for backwards compatibility with older APIs
171
+ - `uiMessages`: Formatted messages suitable for UI display, including proper threading of tool calls and results
172
+ - `messagesV2`: The current internal message format with enhanced structure and metadata
173
+
174
+ ### Semantic Search
175
+
176
+ When using `vectorSearchString`, ensure that:
177
+ - Semantic recall is enabled in your `threadConfig`
178
+ - A vector database is configured in your Memory instance
179
+ - An embedding model is provided
158
180
 
159
- - `messages`: Core message format used internally
160
- - `uiMessages`: Formatted messages suitable for UI display, including proper threading of tool calls and results
181
+ The function will automatically include context messages around semantically similar results based on the configured `messageRange`.
161
182
 
162
183
  ### Related
163
184
 
@@ -0,0 +1,73 @@
1
+ ---
2
+ title: "Reference: Keywords AI Integration | Mastra Observability Docs"
3
+ description: Documentation for integrating Keywords AI (an observability platform for LLM applications) with Mastra.
4
+ ---
5
+
6
+ ## Keywords AI
7
+
8
+ [Keywords AI](https://docs.keywordsai.co/get-started/overview) is a full-stack LLM engineering platform that helps developers and PMs build reliable AI products faster. In a shared workspace, product teams can build, monitor, and improve AI performance.
9
+
10
+ This tutorial shows how to set up Keywords AI tracing with [Mastra](https://mastra.ai/) to monitor and trace your AI-powered applications.
11
+
12
+ To help you get started quickly, we’ve provided a pre-built example. You can find the code [on GitHub](https://github.com/Keywords-AI/keywordsai-example-projects/tree/main/mastra-ai-weather-agent).
13
+
14
+
15
+ ## Setup
16
+
17
+ Here's the tutorial about the Mastra Weather Agent example.
18
+
19
+ ### 1. Install Dependencies
20
+
21
+ ```bash copy
22
+ pnpm install
23
+ ```
24
+
25
+ ### 2. Environment Variables
26
+
27
+ Copy the example environment file and add your API keys:
28
+
29
+ ```bash copy
30
+ cp .env.local.example .env.local
31
+ ```
32
+
33
+ Update .env.local with your credentials:
34
+
35
+ ```bash .env.local copy
36
+ OPENAI_API_KEY=your-openai-api-key
37
+ KEYWORDSAI_API_KEY=your-keywordsai-api-key
38
+ KEYWORDSAI_BASE_URL=https://api.keywordsai.co
39
+ ```
40
+
41
+ ### 3. Setup Mastra client with Keywords AI tracing
42
+
43
+ Configure with KeywordsAI telemetry in `src/mastra/index.ts`:
44
+
45
+ ```typescript filename="src/mastra/index.ts" showLineNumbers copy
46
+
47
+ import { Mastra } from "@mastra/core/mastra";
48
+ import { KeywordsAIExporter } from "@keywordsai/exporter-vercel";
49
+
50
+ telemetry: {
51
+ serviceName: "keywordai-mastra-example",
52
+ enabled: true,
53
+ export: {
54
+ type: "custom",
55
+ exporter: new KeywordsAIExporter({
56
+ apiKey: process.env.KEYWORDSAI_API_KEY,
57
+ baseUrl: process.env.KEYWORDSAI_BASE_URL,
58
+ debug: true,
59
+ })
60
+ }
61
+ }
62
+ ```
63
+
64
+ ### 3. Run the Project
65
+
66
+ ```bash copy
67
+ mastra dev
68
+ ```
69
+ This opens the Mastra playground where you can interact with the weather agent.
70
+
71
+ ## Observability
72
+
73
+ Once configured, you can view your traces and analytics in the [Keywords AI platform](https://platform.keywordsai.co/platform/traces).
@@ -0,0 +1,108 @@
1
+ ---
2
+ title: "MSSQL Storage | Storage System | Mastra Core"
3
+ description: Documentation for the MSSQL storage implementation in Mastra.
4
+ ---
5
+
6
+ # MSSQL Storage
7
+
8
+ The MSSQL storage implementation provides a production-ready storage solution using Microsoft SQL Server databases.
9
+
10
+ ## Installation
11
+
12
+ ```bash copy
13
+ npm install @mastra/mssql@latest
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```typescript copy showLineNumbers
19
+ import { MSSQLStore } from "@mastra/mssql";
20
+
21
+ const storage = new MSSQLStore({
22
+ connectionString: process.env.DATABASE_URL,
23
+ });
24
+ ```
25
+
26
+ ## Parameters
27
+
28
+ <PropertiesTable
29
+ content={[
30
+ {
31
+ name: "connectionString",
32
+ type: "string",
33
+ description:
34
+ "MSSQL connection string (e.g., mssql://user:pass@host:1433/dbname)",
35
+ isOptional: false,
36
+ },
37
+ {
38
+ name: "schemaName",
39
+ type: "string",
40
+ description:
41
+ "The name of the schema you want the storage to use. Will use the default schema if not provided.",
42
+ isOptional: true,
43
+ },
44
+ ]}
45
+ />
46
+
47
+ ## Constructor Examples
48
+
49
+ You can instantiate `MSSQLStore` in the following ways:
50
+
51
+ ```ts
52
+ import { MSSQLStore } from "@mastra/mssql";
53
+
54
+ // Using a connection string only
55
+ const store1 = new MSSQLStore({
56
+ connectionString: "mssql://user:password@localhost:1433/mydb",
57
+ });
58
+
59
+ // Using a connection string with a custom schema name
60
+ const store2 = new MSSQLStore({
61
+ connectionString: "mssql://user:password@localhost:1433/mydb",
62
+ schemaName: "custom_schema", // optional
63
+ });
64
+
65
+ // Using individual connection parameters
66
+ const store4 = new MSSQLStore({
67
+ server: "localhost",
68
+ port: 1433,
69
+ database: "mydb",
70
+ user: "user",
71
+ password: "password",
72
+ });
73
+
74
+ // Individual parameters with schemaName
75
+ const store5 = new MSSQLStore({
76
+ server: "localhost",
77
+ port: 1433,
78
+ database: "mydb",
79
+ user: "user",
80
+ password: "password",
81
+ schemaName: "custom_schema", // optional
82
+ });
83
+ ```
84
+
85
+ ## Additional Notes
86
+
87
+ ### Schema Management
88
+
89
+ The storage implementation handles schema creation and updates automatically. It creates the following tables:
90
+
91
+ - `threads`: Stores conversation threads
92
+ - `messages`: Stores individual messages
93
+ - `metadata`: Stores additional metadata for threads and messages
94
+
95
+ ### Direct Database and Pool Access
96
+
97
+ `MSSQLStore` exposes the mssql connection pool as public fields:
98
+
99
+ ```typescript
100
+ store.pool // mssql connection pool instance
101
+ ```
102
+
103
+ This enables direct queries and custom transaction management. When using these fields:
104
+ - You are responsible for proper connection and transaction handling.
105
+ - Closing the store (`store.close()`) will destroy the associated connection pool.
106
+ - Direct access bypasses any additional logic or validation provided by MSSQLStore methods.
107
+
108
+ This approach is intended for advanced scenarios where low-level access is required.
@@ -5,18 +5,16 @@ description: "Expose additional HTTP endpoints from your Mastra server."
5
5
 
6
6
  # Custom API Routes
7
7
 
8
- By default Mastra automatically exposes registered agents and workflows via the
9
- server. For additional behaviour you can define your own HTTP routes.
8
+ By default Mastra automatically exposes registered agents and workflows via the server. For additional behavior you can define your own HTTP routes.
10
9
 
11
- Routes are provided with a helper `registerApiRoute` from `@mastra/core/server`.
12
- Routes can live in the same file as the `Mastra` instance but separating them
13
- helps keep configuration concise.
10
+ Routes are provided with a helper `registerApiRoute` from `@mastra/core/server`. Routes can live in the same file as the `Mastra` instance but separating them helps keep configuration concise.
14
11
 
15
- ```typescript copy showLineNumbers
16
- import { Mastra } from "@mastra/core";
12
+ ```typescript filename="src/mastra/index.ts" copy showLineNumbers
13
+ import { Mastra } from "@mastra/core/mastra";
17
14
  import { registerApiRoute } from "@mastra/core/server";
18
15
 
19
16
  export const mastra = new Mastra({
17
+ // ...
20
18
  server: {
21
19
  apiRoutes: [
22
20
  registerApiRoute("/my-custom-route", {
@@ -25,7 +23,7 @@ export const mastra = new Mastra({
25
23
  const mastra = c.get("mastra");
26
24
  const agents = await mastra.getAgent("my-agent");
27
25
 
28
- return c.json({ message: "Hello, world!" });
26
+ return c.json({ message: "Custom route" });
29
27
  },
30
28
  }),
31
29
  ],
@@ -33,23 +31,37 @@ export const mastra = new Mastra({
33
31
  });
34
32
  ```
35
33
 
36
- Each route's handler receives the Hono `Context`. Within the handler you can
37
- access the `Mastra` instance to fetch or call agents and workflows.
38
-
39
- To add route-specific middleware pass a `middleware` array when calling
40
- `registerApiRoute`.
41
-
42
- ```typescript copy showLineNumbers
43
- registerApiRoute("/my-custom-route", {
44
- method: "GET",
45
- middleware: [
46
- async (c, next) => {
47
- console.log(`${c.req.method} ${c.req.url}`);
48
- await next();
49
- },
50
- ],
51
- handler: async (c) => {
52
- return c.json({ message: "My route with custom middleware" });
53
- },
34
+ Once registered, a custom route will be accessible from the root of the server. For example:
35
+
36
+ ```bash
37
+ curl http://localhost:4111/my-custom-route
38
+ ```
39
+
40
+ Each route's handler receives the Hono `Context`. Within the handler you can access the `Mastra` instance to fetch or call agents and workflows.
41
+
42
+ To add route-specific middleware pass a `middleware` array when calling `registerApiRoute`.
43
+
44
+ ```typescript filename="src/mastra/index.ts" copy showLineNumbers
45
+ import { Mastra } from "@mastra/core/mastra";
46
+ import { registerApiRoute } from "@mastra/core/server";
47
+
48
+ export const mastra = new Mastra({
49
+ // ...
50
+ server: {
51
+ apiRoutes: [
52
+ registerApiRoute("/my-custom-route", {
53
+ method: "GET",
54
+ middleware: [
55
+ async (c, next) => {
56
+ console.log(`${c.req.method} ${c.req.url}`);
57
+ await next();
58
+ }
59
+ ],
60
+ handler: async (c) => {
61
+ return c.json({ message: "Custom route with middleware" });
62
+ }
63
+ })
64
+ ]
65
+ }
54
66
  });
55
67
  ```
@@ -122,7 +122,30 @@ The tabs help users understand how to connect to various MCP server providers an
122
122
  Each tab shows the specific URL patterns and configuration needed for that registry service.
123
123
  */}
124
124
 
125
- <Tabs items={["mcp.run", "Composio.dev", "Smithery.ai", "Ampersand"]}>
125
+ <Tabs items={["Klavis AI", "mcp.run", "Composio.dev", "Smithery.ai", "Ampersand"]}>
126
+ <Tabs.Tab>
127
+ [Klavis AI](https://klavis.ai) provides hosted, enterprise-authenticated, high-quality MCP servers.
128
+
129
+ ```typescript
130
+ import { MCPClient } from "@mastra/mcp";
131
+
132
+ const mcp = new MCPClient({
133
+ servers: {
134
+ salesforce: {
135
+ url: new URL("https://salesforce-mcp-server.klavis.ai/mcp/?instance_id={private-instance-id}"),
136
+ },
137
+ hubspot: {
138
+ url: new URL("https://hubspot-mcp-server.klavis.ai/mcp/?instance_id={private-instance-id}"),
139
+ },
140
+ },
141
+ });
142
+ ```
143
+
144
+ Klavis AI offers enterprise-grade authentication and security for production deployments.
145
+
146
+ For more details on how to integrate Mastra with Klavis, check out their [documentation](https://docs.klavis.ai/documentation/ai-platform-integration/mastra).
147
+
148
+ </Tabs.Tab>
126
149
  <Tabs.Tab>
127
150
  [mcp.run](https://www.mcp.run/) provides pre-authenticated, managed MCP servers. Tools are grouped into Profiles, each with a unique, signed URL.
128
151