@mastra/mcp-docs-server 0.13.5 → 0.13.7-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 (135) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +84 -84
  2. package/.docs/organized/changelogs/%40mastra%2Fastra.md +8 -8
  3. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +8 -8
  4. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +61 -61
  5. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +210 -210
  6. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +8 -8
  7. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +99 -99
  8. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +98 -98
  9. package/.docs/organized/changelogs/%40mastra%2Fcore.md +189 -189
  10. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +8 -8
  11. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +241 -241
  12. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +170 -170
  13. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +170 -170
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +236 -236
  15. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +109 -109
  16. package/.docs/organized/changelogs/%40mastra%2Fevals.md +80 -80
  17. package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +7 -0
  18. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +90 -90
  19. package/.docs/organized/changelogs/%40mastra%2Fgithub.md +8 -8
  20. package/.docs/organized/changelogs/%40mastra%2Flance.md +62 -0
  21. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +83 -83
  22. package/.docs/organized/changelogs/%40mastra%2Floggers.md +8 -8
  23. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +50 -50
  24. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +8 -8
  25. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +32 -32
  26. package/.docs/organized/changelogs/%40mastra%2Fmem0.md +26 -26
  27. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +145 -145
  28. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +83 -83
  29. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +76 -0
  30. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +8 -8
  31. package/.docs/organized/changelogs/%40mastra%2Fpg.md +126 -126
  32. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +8 -8
  33. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +245 -245
  34. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +8 -8
  35. package/.docs/organized/changelogs/%40mastra%2Frag.md +87 -87
  36. package/.docs/organized/changelogs/%40mastra%2Fragie.md +8 -8
  37. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +18 -0
  38. package/.docs/organized/changelogs/%40mastra%2Fserver.md +208 -208
  39. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +8 -8
  40. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +101 -101
  41. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +8 -8
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +26 -26
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +8 -8
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +8 -8
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +8 -8
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +8 -8
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +8 -8
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +71 -71
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +26 -26
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +8 -8
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +8 -8
  52. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +8 -8
  53. package/.docs/organized/changelogs/create-mastra.md +127 -127
  54. package/.docs/organized/changelogs/mastra.md +250 -250
  55. package/.docs/organized/code-examples/a2a.md +1 -1
  56. package/.docs/organized/code-examples/agent.md +6 -0
  57. package/.docs/organized/code-examples/agui.md +5 -5
  58. package/.docs/organized/code-examples/ai-sdk-useChat.md +3 -3
  59. package/.docs/organized/code-examples/ai-sdk-v5.md +201 -0
  60. package/.docs/organized/code-examples/assistant-ui.md +3 -3
  61. package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
  62. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +3 -3
  63. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +3 -3
  64. package/.docs/organized/code-examples/client-side-tools.md +3 -3
  65. package/.docs/organized/code-examples/crypto-chatbot.md +6 -6
  66. package/.docs/organized/code-examples/fireworks-r1.md +1 -1
  67. package/.docs/organized/code-examples/memory-with-mem0.md +1 -1
  68. package/.docs/organized/code-examples/memory-with-pg.md +1 -0
  69. package/.docs/organized/code-examples/openapi-spec-writer.md +3 -3
  70. package/.docs/organized/code-examples/quick-start.md +1 -1
  71. package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
  72. package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
  73. package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
  74. package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -1
  75. package/.docs/organized/code-examples/workflow-with-suspend-resume.md +181 -0
  76. package/.docs/raw/agents/agent-memory.mdx +126 -0
  77. package/.docs/raw/agents/dynamic-agents.mdx +34 -2
  78. package/.docs/raw/agents/overview.mdx +5 -0
  79. package/.docs/raw/agents/runtime-variables.mdx +1 -1
  80. package/.docs/raw/auth/index.mdx +24 -0
  81. package/.docs/raw/auth/jwt.mdx +99 -0
  82. package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +60 -26
  83. package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +6 -5
  84. package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +84 -14
  85. package/.docs/raw/deployment/cloud-providers/index.mdx +44 -9
  86. package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +9 -30
  87. package/.docs/raw/deployment/serverless-platforms/index.mdx +13 -13
  88. package/.docs/raw/evals/custom-eval.mdx +12 -12
  89. package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +291 -216
  90. package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +0 -34
  91. package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +162 -181
  92. package/.docs/raw/frameworks/servers/express.mdx +1 -1
  93. package/.docs/raw/frameworks/web-frameworks/astro.mdx +2 -2
  94. package/.docs/raw/frameworks/web-frameworks/next-js.mdx +1 -1
  95. package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +4 -4
  96. package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +1 -1
  97. package/.docs/raw/getting-started/installation.mdx +10 -7
  98. package/.docs/raw/getting-started/model-capability.mdx +1 -1
  99. package/.docs/raw/index.mdx +2 -2
  100. package/.docs/raw/memory/overview.mdx +8 -0
  101. package/.docs/raw/memory/semantic-recall.mdx +6 -0
  102. package/.docs/raw/observability/tracing.mdx +30 -0
  103. package/.docs/raw/reference/agents/agent.mdx +2 -2
  104. package/.docs/raw/reference/auth/jwt.mdx +42 -0
  105. package/.docs/raw/reference/cli/create-mastra.mdx +7 -0
  106. package/.docs/raw/reference/cli/dev.mdx +4 -3
  107. package/.docs/raw/reference/client-js/agents.mdx +10 -10
  108. package/.docs/raw/reference/client-js/error-handling.mdx +1 -21
  109. package/.docs/raw/reference/client-js/logs.mdx +2 -10
  110. package/.docs/raw/reference/client-js/mastra-client.mdx +141 -0
  111. package/.docs/raw/reference/client-js/memory.mdx +6 -18
  112. package/.docs/raw/reference/client-js/telemetry.mdx +1 -9
  113. package/.docs/raw/reference/client-js/tools.mdx +2 -10
  114. package/.docs/raw/reference/client-js/vectors.mdx +1 -9
  115. package/.docs/raw/reference/client-js/workflows-legacy.mdx +3 -11
  116. package/.docs/raw/reference/client-js/workflows.mdx +5 -13
  117. package/.docs/raw/reference/core/mastra-class.mdx +6 -0
  118. package/.docs/raw/reference/memory/query.mdx +35 -14
  119. package/.docs/raw/reference/observability/providers/dash0.mdx +2 -2
  120. package/.docs/raw/reference/observability/providers/keywordsai.mdx +73 -0
  121. package/.docs/raw/reference/storage/mssql.mdx +108 -0
  122. package/.docs/raw/reference/tools/vector-query-tool.mdx +29 -0
  123. package/.docs/raw/server-db/custom-api-routes.mdx +38 -26
  124. package/.docs/raw/tools-mcp/mcp-overview.mdx +24 -1
  125. package/.docs/raw/tools-mcp/overview.mdx +1 -1
  126. package/.docs/raw/workflows/control-flow.mdx +85 -87
  127. package/.docs/raw/workflows/input-data-mapping.mdx +31 -43
  128. package/.docs/raw/workflows/overview.mdx +22 -12
  129. package/.docs/raw/workflows/pausing-execution.mdx +49 -4
  130. package/.docs/raw/workflows/suspend-and-resume.mdx +17 -16
  131. package/.docs/raw/workflows/using-with-agents-and-tools.mdx +16 -13
  132. package/.docs/raw/workflows-legacy/overview.mdx +11 -0
  133. package/package.json +7 -9
  134. package/.docs/organized/changelogs/%40mastra%2Fagui.md +0 -302
  135. package/.docs/raw/frameworks/ai-sdk-v5.mdx +0 -91
@@ -7,20 +7,12 @@ description: Learn how to interact with and execute automated legacy workflows i
7
7
 
8
8
  The Workflows (Legacy) API provides methods to interact with and execute automated legacy workflows in Mastra.
9
9
 
10
- ## Initialize Mastra Client
11
-
12
- ```typescript
13
- import { MastraClient } from "@mastra/client-js";
14
-
15
- const client = new MastraClient();
16
- ```
17
-
18
10
  ## Getting All Legacy Workflows
19
11
 
20
12
  Retrieve a list of all available legacy workflows:
21
13
 
22
14
  ```typescript
23
- const workflows = await client.getLegacyWorkflows();
15
+ const workflows = await mastraClient.getLegacyWorkflows();
24
16
  ```
25
17
 
26
18
  ## Working with a Specific Legacy Workflow
@@ -28,7 +20,7 @@ const workflows = await client.getLegacyWorkflows();
28
20
  Get an instance of a specific legacy workflow:
29
21
 
30
22
  ```typescript
31
- const workflow = client.getLegacyWorkflow("workflow-id");
23
+ const workflow = mastraClient.getLegacyWorkflow("workflow-id");
32
24
  ```
33
25
 
34
26
  ## Legacy Workflow Methods
@@ -78,7 +70,7 @@ Watch legacy workflow transitions
78
70
  ```typescript
79
71
  try {
80
72
  // Get workflow instance
81
- const workflow = client.getLegacyWorkflow("workflow-id");
73
+ const workflow = mastraClient.getLegacyWorkflow("workflow-id");
82
74
 
83
75
  // Create a workflow run
84
76
  const { runId } = workflow.createRun();
@@ -7,20 +7,12 @@ description: Learn how to interact with and execute automated workflows in Mastr
7
7
 
8
8
  The Workflows API provides methods to interact with and execute automated workflows in Mastra.
9
9
 
10
- ## Initialize Mastra Client
11
-
12
- ```typescript
13
- import { MastraClient } from "@mastra/client-js";
14
-
15
- const client = new MastraClient();
16
- ```
17
-
18
10
  ## Getting All Workflows
19
11
 
20
12
  Retrieve a list of all available workflows:
21
13
 
22
14
  ```typescript
23
- const workflows = await client.getWorkflows();
15
+ const workflows = await mastraClient.getWorkflows();
24
16
  ```
25
17
 
26
18
  ## Working with a Specific Workflow
@@ -34,7 +26,7 @@ export const testWorkflow = createWorkflow({
34
26
  ```
35
27
 
36
28
  ```typescript
37
- const workflow = client.getWorkflow("testWorkflow");
29
+ const workflow = mastraClient.getWorkflow("testWorkflow");
38
30
  ```
39
31
 
40
32
  ## Workflow Methods
@@ -82,7 +74,7 @@ Watch workflow transitions:
82
74
 
83
75
  ```typescript
84
76
  try {
85
- const workflow = client.getWorkflow("testWorkflow");
77
+ const workflow = mastraClient.getWorkflow("testWorkflow");
86
78
 
87
79
  const run = await workflow.createRun();
88
80
 
@@ -107,7 +99,7 @@ Resume workflow run and watch workflow step transitions:
107
99
 
108
100
  ```typescript
109
101
  try {
110
- const workflow = client.getWorkflow("testWorkflow");
102
+ const workflow = mastraClient.getWorkflow("testWorkflow");
111
103
 
112
104
  const run = await workflow.createRun({ runId: prevRunId });
113
105
 
@@ -131,7 +123,7 @@ Get the result of a workflow run:
131
123
 
132
124
  ```typescript
133
125
  try {
134
- const workflow = client.getWorkflow("testWorkflow");
126
+ const workflow = mastraClient.getWorkflow("testWorkflow");
135
127
 
136
128
  const run = await workflow.createRun();
137
129
 
@@ -87,6 +87,12 @@ The constructor accepts an optional `Config` object to customize its behavior an
87
87
  isOptional: true,
88
88
  defaultValue: "Console logger with INFO level",
89
89
  },
90
+ {
91
+ name: "idGenerator",
92
+ type: "() => string",
93
+ description: "Custom ID generator function. Used by agents, workflows, memory, and other components to generate unique identifiers.",
94
+ isOptional: true,
95
+ },
90
96
  {
91
97
  name: "workflows",
92
98
  type: "Record<string, Workflow>",
@@ -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
 
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  title: "Reference: Dash0 Integration | Mastra Observability Docs"
3
- description: Documentation for integrating Mastra with Dash0, an Open Telementry native observability solution.
3
+ description: Documentation for integrating Mastra with Dash0, an Open Telemetry native observability solution.
4
4
  ---
5
5
 
6
6
  # Dash0
7
7
 
8
- Dash0, an Open Telementry native observability solution that provides full-stack monitoring capabilities as well as integrations with other CNCF projects like Perses and Prometheus.
8
+ Dash0, an Open Telemetry native observability solution that provides full-stack monitoring capabilities as well as integrations with other CNCF projects like Perses and Prometheus.
9
9
 
10
10
  ## Configuration
11
11
 
@@ -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.
@@ -554,6 +554,35 @@ For more information on runtime context, please see:
554
554
  - [Runtime Variables](../../docs/agents/runtime-variables)
555
555
  - [Dynamic Context](../../docs/tools-mcp/dynamic-context)
556
556
 
557
+ ## Usage Without a Mastra Server
558
+
559
+ The tool can be used by itself to retrieve documents matching a query:
560
+ ```typescript copy showLineNumbers filename="src/index.ts"
561
+ import { openai } from "@ai-sdk/openai";
562
+ import { RuntimeContext } from "@mastra/core/runtime-context";
563
+ import { createVectorQueryTool } from "@mastra/rag";
564
+ import { PgVector } from "@mastra/pg";
565
+
566
+ const pgVector = new PgVector({
567
+ connectionString: process.env.POSTGRES_CONNECTION_STRING!,
568
+ });
569
+
570
+ const vectorQueryTool = createVectorQueryTool({
571
+ vectorStoreName: "pgVector", // optional since we're passing in a store
572
+ vectorStore: pgVector,
573
+ indexName: "embeddings",
574
+ model: openai.embedding("text-embedding-3-small"),
575
+ });
576
+
577
+ const runtimeContext = new RuntimeContext();
578
+ const queryResult = await vectorQueryTool.execute({
579
+ context: { queryText: "foo", topK: 1 },
580
+ runtimeContext,
581
+ });
582
+
583
+ console.log(queryResult.sources);
584
+ ```
585
+
557
586
  ## Tool Details
558
587
 
559
588
  The tool is created with:
@@ -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
 
@@ -56,7 +56,7 @@ To make tools available to an agent, you configure them in the agent's definitio
56
56
 
57
57
  ## Compatibility Layer for Tool Schemas
58
58
 
59
- Different models interpret schemas differely. Some error when certain schema properties are passed and some ignore certain schema properties but don't throw an error. Mastra adds a compatibility layer for tool schemas, ensuring tools work consistently across different model providers and that the schema constraints are respected.
59
+ Different models interpret schemas differently. Some error when certain schema properties are passed and some ignore certain schema properties but don't throw an error. Mastra adds a compatibility layer for tool schemas, ensuring tools work consistently across different model providers and that the schema constraints are respected.
60
60
 
61
61
  Some providers that we include this layer for:
62
62