@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.
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +84 -84
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +61 -61
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +210 -210
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +99 -99
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +98 -98
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +189 -189
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +241 -241
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +170 -170
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +170 -170
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +236 -236
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +109 -109
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +80 -80
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +7 -0
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +90 -90
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Flance.md +62 -0
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +83 -83
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +50 -50
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +32 -32
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +145 -145
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +83 -83
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +76 -0
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +126 -126
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +245 -245
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Frag.md +87 -87
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +18 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +208 -208
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +101 -101
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +71 -71
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +8 -8
- package/.docs/organized/changelogs/create-mastra.md +127 -127
- package/.docs/organized/changelogs/mastra.md +250 -250
- package/.docs/organized/code-examples/a2a.md +1 -1
- package/.docs/organized/code-examples/agent.md +6 -0
- package/.docs/organized/code-examples/agui.md +5 -5
- package/.docs/organized/code-examples/ai-sdk-useChat.md +3 -3
- package/.docs/organized/code-examples/ai-sdk-v5.md +201 -0
- package/.docs/organized/code-examples/assistant-ui.md +3 -3
- package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +3 -3
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +3 -3
- package/.docs/organized/code-examples/client-side-tools.md +3 -3
- package/.docs/organized/code-examples/crypto-chatbot.md +6 -6
- package/.docs/organized/code-examples/fireworks-r1.md +1 -1
- package/.docs/organized/code-examples/memory-with-mem0.md +1 -1
- package/.docs/organized/code-examples/memory-with-pg.md +1 -0
- package/.docs/organized/code-examples/openapi-spec-writer.md +3 -3
- package/.docs/organized/code-examples/quick-start.md +1 -1
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-suspend-resume.md +181 -0
- package/.docs/raw/agents/agent-memory.mdx +126 -0
- package/.docs/raw/agents/dynamic-agents.mdx +34 -2
- package/.docs/raw/agents/overview.mdx +5 -0
- package/.docs/raw/agents/runtime-variables.mdx +1 -1
- package/.docs/raw/auth/index.mdx +24 -0
- package/.docs/raw/auth/jwt.mdx +99 -0
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +60 -26
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +6 -5
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +84 -14
- package/.docs/raw/deployment/cloud-providers/index.mdx +44 -9
- package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +9 -30
- package/.docs/raw/deployment/serverless-platforms/index.mdx +13 -13
- package/.docs/raw/evals/custom-eval.mdx +12 -12
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +291 -216
- package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +0 -34
- package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +162 -181
- package/.docs/raw/frameworks/servers/express.mdx +1 -1
- package/.docs/raw/frameworks/web-frameworks/astro.mdx +2 -2
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +1 -1
- package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +4 -4
- package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +1 -1
- package/.docs/raw/getting-started/installation.mdx +10 -7
- package/.docs/raw/getting-started/model-capability.mdx +1 -1
- package/.docs/raw/index.mdx +2 -2
- package/.docs/raw/memory/overview.mdx +8 -0
- package/.docs/raw/memory/semantic-recall.mdx +6 -0
- package/.docs/raw/observability/tracing.mdx +30 -0
- package/.docs/raw/reference/agents/agent.mdx +2 -2
- package/.docs/raw/reference/auth/jwt.mdx +42 -0
- package/.docs/raw/reference/cli/create-mastra.mdx +7 -0
- package/.docs/raw/reference/cli/dev.mdx +4 -3
- package/.docs/raw/reference/client-js/agents.mdx +10 -10
- package/.docs/raw/reference/client-js/error-handling.mdx +1 -21
- package/.docs/raw/reference/client-js/logs.mdx +2 -10
- package/.docs/raw/reference/client-js/mastra-client.mdx +141 -0
- package/.docs/raw/reference/client-js/memory.mdx +6 -18
- package/.docs/raw/reference/client-js/telemetry.mdx +1 -9
- package/.docs/raw/reference/client-js/tools.mdx +2 -10
- package/.docs/raw/reference/client-js/vectors.mdx +1 -9
- package/.docs/raw/reference/client-js/workflows-legacy.mdx +3 -11
- package/.docs/raw/reference/client-js/workflows.mdx +5 -13
- package/.docs/raw/reference/core/mastra-class.mdx +6 -0
- package/.docs/raw/reference/memory/query.mdx +35 -14
- package/.docs/raw/reference/observability/providers/dash0.mdx +2 -2
- package/.docs/raw/reference/observability/providers/keywordsai.mdx +73 -0
- package/.docs/raw/reference/storage/mssql.mdx +108 -0
- package/.docs/raw/reference/tools/vector-query-tool.mdx +29 -0
- package/.docs/raw/server-db/custom-api-routes.mdx +38 -26
- package/.docs/raw/tools-mcp/mcp-overview.mdx +24 -1
- package/.docs/raw/tools-mcp/overview.mdx +1 -1
- package/.docs/raw/workflows/control-flow.mdx +85 -87
- package/.docs/raw/workflows/input-data-mapping.mdx +31 -43
- package/.docs/raw/workflows/overview.mdx +22 -12
- package/.docs/raw/workflows/pausing-execution.mdx +49 -4
- package/.docs/raw/workflows/suspend-and-resume.mdx +17 -16
- package/.docs/raw/workflows/using-with-agents-and-tools.mdx +16 -13
- package/.docs/raw/workflows-legacy/overview.mdx +11 -0
- package/package.json +7 -9
- package/.docs/organized/changelogs/%40mastra%2Fagui.md +0 -302
- 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
|
|
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
|
|
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
|
|
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
|
package/.docs/raw/index.mdx
CHANGED
|
@@ -9,14 +9,14 @@ Mastra is an open-source TypeScript agent framework.
|
|
|
9
9
|
|
|
10
10
|
It's designed to give you the primitives you need to build AI applications and features.
|
|
11
11
|
|
|
12
|
-
You can use Mastra to build [AI agents](/docs/agents/overview.mdx) that have memory and can execute functions, or chain LLM calls in deterministic [workflows](/docs/workflows/overview.mdx). You can chat with your agents in Mastra's [local dev
|
|
12
|
+
You can use Mastra to build [AI agents](/docs/agents/overview.mdx) that have memory and can execute functions, or chain LLM calls in deterministic [workflows](/docs/workflows/overview.mdx). You can chat with your agents in Mastra's [local dev playground](/docs/server-db/local-dev-playground.mdx), feed them application-specific knowledge with [RAG](/docs/rag/overview.mdx), and score their outputs with Mastra's [evals](/docs/evals/overview.mdx).
|
|
13
13
|
|
|
14
14
|
The main features include:
|
|
15
15
|
|
|
16
16
|
- **[Model routing](https://sdk.vercel.ai/docs/introduction)**: Mastra uses the [Vercel AI SDK](https://sdk.vercel.ai/docs/introduction) for model routing, providing a unified interface to interact with any LLM provider including OpenAI, Anthropic, and Google Gemini.
|
|
17
17
|
- **[Agent memory and tool calling](/docs/agents/agent-memory.mdx)**: With Mastra, you can give your agent tools (functions) that it can call. You can persist agent memory and retrieve it based on recency, semantic similarity, or conversation thread.
|
|
18
18
|
- **[Workflow graphs](/docs/workflows/overview.mdx)**: When you want to execute LLM calls in a deterministic way, Mastra gives you a graph-based workflow engine. You can define discrete steps, log inputs and outputs at each step of each run, and pipe them into an observability tool. Mastra workflows have a simple syntax for control flow (`.then()`, `.branch()`, `.parallel()`) that allows branching and chaining.
|
|
19
|
-
- **[Agent development
|
|
19
|
+
- **[Agent development playground](/docs/server-db/local-dev-playground.mdx)**: When you're developing an agent locally, you can chat with it and see its state and memory in Mastra's agent development environment.
|
|
20
20
|
- **[Retrieval-augmented generation (RAG)](/docs/rag/overview.mdx)**: Mastra gives you APIs to process documents (text, HTML, Markdown, JSON) into chunks, create embeddings, and store them in a vector database. At query time, it retrieves relevant chunks to ground LLM responses in your data, with a unified API on top of multiple vector stores (Pinecone, pgvector, etc) and embedding providers (OpenAI, Cohere, etc).
|
|
21
21
|
- **[Deployment](/docs/deployment/deployment.mdx)**: Mastra supports bundling your agents and workflows within an existing React, Next.js, or Node.js application, or into standalone endpoints. The Mastra deploy helper lets you easily bundle agents and workflows into a Node.js server using Hono, or deploy it onto a serverless platform like Vercel, Cloudflare Workers, or Netlify.
|
|
22
22
|
- **[Evals](/docs/evals/overview.mdx)**: Mastra provides automated evaluation metrics that use model-graded, rule-based, and statistical methods to assess LLM outputs, with built-in metrics for toxicity, bias, relevance, and factual accuracy. You can also define your own evals.
|
|
@@ -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",
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "MastraJwtAuth"
|
|
3
|
+
description: "API reference for the MastraJwtAuth class, which authenticates Mastra applications using JSON Web Tokens."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# MastraJwtAuth
|
|
7
|
+
|
|
8
|
+
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.
|
|
9
|
+
|
|
10
|
+
## Usage example
|
|
11
|
+
|
|
12
|
+
```typescript filename="src/mastra/index.ts" showLineNumbers copy
|
|
13
|
+
import { Mastra } from "@mastra/core/mastra";
|
|
14
|
+
import { MastraJwtAuth } from '@mastra/auth';
|
|
15
|
+
|
|
16
|
+
export const mastra = new Mastra({
|
|
17
|
+
// ..
|
|
18
|
+
server: {
|
|
19
|
+
experimental_auth: new MastraJwtAuth({
|
|
20
|
+
secret: "<your-secret>"
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Constructor parameters
|
|
27
|
+
|
|
28
|
+
<PropertiesTable
|
|
29
|
+
content={[
|
|
30
|
+
{
|
|
31
|
+
name: "secret",
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "A unique string used to sign and verify JSON Web Tokens (JWTs) for authenticating incoming requests.",
|
|
34
|
+
isOptional: false,
|
|
35
|
+
},
|
|
36
|
+
]}
|
|
37
|
+
/>
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## Related
|
|
41
|
+
|
|
42
|
+
[MastraJwtAuth](/docs/auth/jwt.mdx)
|
|
@@ -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/
|
|
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
|
|
|
@@ -7,20 +7,12 @@ description: Learn how to interact with Mastra AI agents, including generating r
|
|
|
7
7
|
|
|
8
8
|
The Agents API provides methods to interact with Mastra AI agents, including generating responses, streaming interactions, and managing agent tools.
|
|
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 Agents
|
|
19
11
|
|
|
20
12
|
Retrieve a list of all available agents:
|
|
21
13
|
|
|
22
14
|
```typescript
|
|
23
|
-
const agents = await
|
|
15
|
+
const agents = await mastraClient.getAgents();
|
|
24
16
|
```
|
|
25
17
|
|
|
26
18
|
## Working with a Specific Agent
|
|
@@ -28,7 +20,7 @@ const agents = await client.getAgents();
|
|
|
28
20
|
Get an instance of a specific agent:
|
|
29
21
|
|
|
30
22
|
```typescript
|
|
31
|
-
const agent =
|
|
23
|
+
const agent = mastraClient.getAgent("agent-id");
|
|
32
24
|
```
|
|
33
25
|
|
|
34
26
|
## Agent Methods
|
|
@@ -89,6 +81,14 @@ response.processDataStream({
|
|
|
89
81
|
},
|
|
90
82
|
});
|
|
91
83
|
|
|
84
|
+
// Process text stream with the processTextStream util
|
|
85
|
+
// (used with structured output)
|
|
86
|
+
response.processTextStream({
|
|
87
|
+
onTextPart: text => {
|
|
88
|
+
process.stdout.write(text);
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
92
|
// You can also read from response body directly
|
|
93
93
|
const reader = response.body.getReader();
|
|
94
94
|
while (true) {
|
|
@@ -13,7 +13,7 @@ All API methods can throw errors that you can catch and handle:
|
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
try {
|
|
16
|
-
const agent =
|
|
16
|
+
const agent = mastraClient.getAgent("agent-id");
|
|
17
17
|
const response = await agent.generate({
|
|
18
18
|
messages: [{ role: "user", content: "Hello" }],
|
|
19
19
|
});
|
|
@@ -21,23 +21,3 @@ try {
|
|
|
21
21
|
console.error("An error occurred:", error.message);
|
|
22
22
|
}
|
|
23
23
|
```
|
|
24
|
-
|
|
25
|
-
## Retry Mechanism
|
|
26
|
-
|
|
27
|
-
The client automatically retries failed requests with exponential backoff:
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
const client = new MastraClient({
|
|
31
|
-
baseUrl: "http://localhost:4111",
|
|
32
|
-
retries: 3, // Number of retry attempts
|
|
33
|
-
backoffMs: 300, // Initial backoff time
|
|
34
|
-
maxBackoffMs: 5000, // Maximum backoff time
|
|
35
|
-
});
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### How Retries Work
|
|
39
|
-
|
|
40
|
-
1. First attempt fails → Wait 300ms
|
|
41
|
-
2. Second attempt fails → Wait 600ms
|
|
42
|
-
3. Third attempt fails → Wait 1200ms
|
|
43
|
-
4. Final attempt fails → Throw error
|
|
@@ -7,20 +7,12 @@ description: Learn how to access and query system logs and debugging information
|
|
|
7
7
|
|
|
8
8
|
The Logs API provides methods to access and query system logs and debugging information 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 Logs
|
|
19
11
|
|
|
20
12
|
Retrieve system logs with optional filtering:
|
|
21
13
|
|
|
22
14
|
```typescript
|
|
23
|
-
const logs = await
|
|
15
|
+
const logs = await mastraClient.getLogs({
|
|
24
16
|
transportId: "transport-1",
|
|
25
17
|
});
|
|
26
18
|
```
|
|
@@ -30,7 +22,7 @@ const logs = await client.getLogs({
|
|
|
30
22
|
Retrieve logs for a specific execution run:
|
|
31
23
|
|
|
32
24
|
```typescript
|
|
33
|
-
const runLogs = await
|
|
25
|
+
const runLogs = await mastraClient.getLogForRun({
|
|
34
26
|
runId: "run-1",
|
|
35
27
|
transportId: "transport-1",
|
|
36
28
|
});
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: MastraClient
|
|
3
|
+
description: Learn how to interact with Mastra using the client-js SDK.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Mastra Client SDK
|
|
7
|
+
|
|
8
|
+
The Mastra Client SDK provides a simple and type-safe interface for interacting with your [Mastra Server](/docs/deployment/server-deployment.mdx) from your client environment.
|
|
9
|
+
|
|
10
|
+
## Usage example
|
|
11
|
+
|
|
12
|
+
```typescript filename="lib/mastra/mastra-client.ts" showLineNumbers copy
|
|
13
|
+
import { MastraClient } from "@mastra/client-js";
|
|
14
|
+
|
|
15
|
+
export const mastraClient = new MastraClient({
|
|
16
|
+
baseUrl: "http://localhost:4111/",
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Parameters
|
|
21
|
+
|
|
22
|
+
<PropertiesTable
|
|
23
|
+
content={[
|
|
24
|
+
{
|
|
25
|
+
name: "baseUrl",
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "The base URL for the Mastra API. All requests will be sent relative to this URL.",
|
|
28
|
+
isOptional: false,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "retries",
|
|
32
|
+
type: "number",
|
|
33
|
+
description: "The number of times a request will be retried on failure before throwing an error.",
|
|
34
|
+
isOptional: true,
|
|
35
|
+
defaultValue: "3",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "backoffMs",
|
|
39
|
+
type: "number",
|
|
40
|
+
description: "The initial delay in milliseconds before retrying a failed request. This value is doubled with each retry (exponential backoff).",
|
|
41
|
+
isOptional: true,
|
|
42
|
+
defaultValue: "300",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "maxBackoffMs",
|
|
46
|
+
type: "number",
|
|
47
|
+
description: "The maximum backoff time in milliseconds. Prevents retries from waiting too long between attempts.",
|
|
48
|
+
isOptional: true,
|
|
49
|
+
defaultValue: "5000",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "headers",
|
|
53
|
+
type: "Record<string, string>",
|
|
54
|
+
description: "An object containing custom HTTP headers to include with every request.",
|
|
55
|
+
isOptional: true,
|
|
56
|
+
},
|
|
57
|
+
]}
|
|
58
|
+
/>
|
|
59
|
+
|
|
60
|
+
## Methods
|
|
61
|
+
|
|
62
|
+
<PropertiesTable
|
|
63
|
+
content={[
|
|
64
|
+
{
|
|
65
|
+
name: "getAgents()",
|
|
66
|
+
type: "Promise<Record<string, GetAgentResponse>>",
|
|
67
|
+
description: "Returns all available agent instances.",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "getAgent(agentId)",
|
|
71
|
+
type: "Agent",
|
|
72
|
+
description: "Retrieves a specific agent instance by ID.",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "getMemoryThreads(params)",
|
|
76
|
+
type: "Promise<StorageThreadType[]>",
|
|
77
|
+
description: "Retrieves memory threads for the specified resource and agent. Requires a `resourceId` and an `agentId`.",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "createMemoryThread(params)",
|
|
81
|
+
type: "Promise<MemoryThread>",
|
|
82
|
+
description: "Creates a new memory thread with the given parameters.",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "getMemoryThread(threadId)",
|
|
86
|
+
type: "Promise<MemoryThread>",
|
|
87
|
+
description: "Fetches a specific memory thread by ID.",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "saveMessageToMemory(params)",
|
|
91
|
+
type: "Promise<void>",
|
|
92
|
+
description: "Saves one or more messages to the memory system.",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "getMemoryStatus()",
|
|
96
|
+
type: "Promise<MemoryStatus>",
|
|
97
|
+
description: "Returns the current status of the memory system.",
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "getTools()",
|
|
101
|
+
type: "Record<string, Tool>",
|
|
102
|
+
description: "Returns all available tools.",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "getTool(toolId)",
|
|
106
|
+
type: "Tool",
|
|
107
|
+
description: "Retrieves a specific tool instance by ID.",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "getWorkflows()",
|
|
111
|
+
type: "Record<string, Workflow>",
|
|
112
|
+
description: "Returns all available workflow instances.",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "getWorkflow(workflowId)",
|
|
116
|
+
type: "Workflow",
|
|
117
|
+
description: "Retrieves a specific workflow instance by ID.",
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "getVector(vectorName)",
|
|
121
|
+
type: "MastraVector",
|
|
122
|
+
description: "Returns a vector store instance by name.",
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "getLogs(params)",
|
|
126
|
+
type: "Promise<LogEntry[]>",
|
|
127
|
+
description: "Fetches system logs matching the provided filters.",
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "getLog(params)",
|
|
131
|
+
type: "Promise<LogEntry>",
|
|
132
|
+
description: "Retrieves a specific log entry by ID or filter.",
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "getLogTransports()",
|
|
136
|
+
type: "string[]",
|
|
137
|
+
description: "Returns the list of configured log transport types.",
|
|
138
|
+
},
|
|
139
|
+
]}
|
|
140
|
+
/>
|
|
141
|
+
|
|
@@ -7,22 +7,12 @@ description: Learn how to manage conversation threads and message history in Mas
|
|
|
7
7
|
|
|
8
8
|
The Memory API provides methods to manage conversation threads and message history 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
|
-
## Memory Thread Operations
|
|
19
|
-
|
|
20
10
|
### Get All Threads
|
|
21
11
|
|
|
22
12
|
Retrieve all memory threads for a specific resource:
|
|
23
13
|
|
|
24
14
|
```typescript
|
|
25
|
-
const threads = await
|
|
15
|
+
const threads = await mastraClient.getMemoryThreads({
|
|
26
16
|
resourceId: "resource-1",
|
|
27
17
|
agentId: "agent-1",
|
|
28
18
|
});
|
|
@@ -33,10 +23,10 @@ const threads = await client.getMemoryThreads({
|
|
|
33
23
|
Create a new memory thread:
|
|
34
24
|
|
|
35
25
|
```typescript
|
|
36
|
-
const thread = await
|
|
26
|
+
const thread = await mastraClient.createMemoryThread({
|
|
37
27
|
title: "New Conversation",
|
|
38
28
|
metadata: { category: "support" },
|
|
39
|
-
|
|
29
|
+
resourceId: "resource-1",
|
|
40
30
|
agentId: "agent-1",
|
|
41
31
|
});
|
|
42
32
|
```
|
|
@@ -46,7 +36,7 @@ const thread = await client.createMemoryThread({
|
|
|
46
36
|
Get an instance of a specific memory thread:
|
|
47
37
|
|
|
48
38
|
```typescript
|
|
49
|
-
const thread =
|
|
39
|
+
const thread = mastraClient.getMemoryThread("thread-id", "agent-id");
|
|
50
40
|
```
|
|
51
41
|
|
|
52
42
|
## Thread Methods
|
|
@@ -79,8 +69,6 @@ Delete a thread and its messages:
|
|
|
79
69
|
await thread.delete();
|
|
80
70
|
```
|
|
81
71
|
|
|
82
|
-
|
|
83
|
-
|
|
84
72
|
## Message Operations
|
|
85
73
|
|
|
86
74
|
### Save Messages
|
|
@@ -88,7 +76,7 @@ await thread.delete();
|
|
|
88
76
|
Save messages to memory:
|
|
89
77
|
|
|
90
78
|
```typescript
|
|
91
|
-
const savedMessages = await
|
|
79
|
+
const savedMessages = await mastraClient.saveMessageToMemory({
|
|
92
80
|
messages: [
|
|
93
81
|
{
|
|
94
82
|
role: "user",
|
|
@@ -120,5 +108,5 @@ const { messages } = await thread.getMessages({ limit: 10 });
|
|
|
120
108
|
Check the status of the memory system:
|
|
121
109
|
|
|
122
110
|
```typescript
|
|
123
|
-
const status = await
|
|
111
|
+
const status = await mastraClient.getMemoryStatus("agent-id");
|
|
124
112
|
```
|
|
@@ -7,20 +7,12 @@ description: Learn how to retrieve and analyze traces from your Mastra applicati
|
|
|
7
7
|
|
|
8
8
|
The Telemetry API provides methods to retrieve and analyze traces from your Mastra application. This helps you monitor and debug your application's behavior and performance.
|
|
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 Traces
|
|
19
11
|
|
|
20
12
|
Retrieve traces with optional filtering and pagination:
|
|
21
13
|
|
|
22
14
|
```typescript
|
|
23
|
-
const telemetry = await
|
|
15
|
+
const telemetry = await mastraClient.getTelemetry({
|
|
24
16
|
name: "trace-name", // Optional: Filter by trace name
|
|
25
17
|
scope: "scope-name", // Optional: Filter by scope
|
|
26
18
|
page: 1, // Optional: Page number for pagination
|
|
@@ -7,20 +7,12 @@ description: Learn how to interact with and execute tools available in the Mastr
|
|
|
7
7
|
|
|
8
8
|
The Tools API provides methods to interact with and execute tools available in the Mastra platform.
|
|
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 Tools
|
|
19
11
|
|
|
20
12
|
Retrieve a list of all available tools:
|
|
21
13
|
|
|
22
14
|
```typescript
|
|
23
|
-
const tools = await
|
|
15
|
+
const tools = await mastraClient.getTools();
|
|
24
16
|
```
|
|
25
17
|
|
|
26
18
|
## Working with a Specific Tool
|
|
@@ -28,7 +20,7 @@ const tools = await client.getTools();
|
|
|
28
20
|
Get an instance of a specific tool:
|
|
29
21
|
|
|
30
22
|
```typescript
|
|
31
|
-
const tool =
|
|
23
|
+
const tool = mastraClient.getTool("tool-id");
|
|
32
24
|
```
|
|
33
25
|
|
|
34
26
|
## Tool Methods
|
|
@@ -7,20 +7,12 @@ description: Learn how to work with vector embeddings for semantic search and si
|
|
|
7
7
|
|
|
8
8
|
The Vectors API provides methods to work with vector embeddings for semantic search and similarity matching 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
|
## Working with Vectors
|
|
19
11
|
|
|
20
12
|
Get an instance of a vector store:
|
|
21
13
|
|
|
22
14
|
```typescript
|
|
23
|
-
const vector =
|
|
15
|
+
const vector = mastraClient.getVector("vector-name");
|
|
24
16
|
```
|
|
25
17
|
|
|
26
18
|
## Vector Methods
|