@mastra/mcp-docs-server 0.0.0-commonjs-20250414101718
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +161 -0
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +110 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +26 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +196 -0
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Frag.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-azure.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-deepgram.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-elevenlabs.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-google.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-ibm.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-murf.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-openai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-playai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-replicate.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-speechify.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +250 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +250 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +302 -0
- package/.docs/organized/changelogs/create-mastra.md +302 -0
- package/.docs/organized/changelogs/mastra.md +302 -0
- package/.docs/organized/code-examples/agent-network.md +282 -0
- package/.docs/organized/code-examples/agent.md +388 -0
- package/.docs/organized/code-examples/ai-sdk-useChat.md +378 -0
- package/.docs/organized/code-examples/assistant-ui.md +37 -0
- package/.docs/organized/code-examples/bird-checker-with-express.md +235 -0
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +360 -0
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +250 -0
- package/.docs/organized/code-examples/client-side-tools.md +69 -0
- package/.docs/organized/code-examples/crypto-chatbot.md +96 -0
- package/.docs/organized/code-examples/fireworks-r1.md +159 -0
- package/.docs/organized/code-examples/mcp-registry-registry.md +63 -0
- package/.docs/organized/code-examples/memory-todo-agent.md +164 -0
- package/.docs/organized/code-examples/memory-with-context.md +167 -0
- package/.docs/organized/code-examples/memory-with-libsql.md +204 -0
- package/.docs/organized/code-examples/memory-with-mem0.md +121 -0
- package/.docs/organized/code-examples/memory-with-pg.md +224 -0
- package/.docs/organized/code-examples/memory-with-upstash.md +268 -0
- package/.docs/organized/code-examples/quick-start.md +129 -0
- package/.docs/organized/code-examples/stock-price-tool.md +124 -0
- package/.docs/organized/code-examples/weather-agent.md +353 -0
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +159 -0
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +111 -0
- package/.docs/organized/code-examples/workflow-with-memory.md +393 -0
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +131 -0
- package/.docs/raw/agents/adding-tools.mdx +317 -0
- package/.docs/raw/agents/adding-voice.mdx +175 -0
- package/.docs/raw/agents/agent-memory.mdx +62 -0
- package/.docs/raw/agents/mcp-guide.mdx +215 -0
- package/.docs/raw/agents/overview.mdx +303 -0
- package/.docs/raw/community/discord.mdx +12 -0
- package/.docs/raw/community/licensing.mdx +63 -0
- package/.docs/raw/deployment/client.mdx +120 -0
- package/.docs/raw/deployment/deployment.mdx +127 -0
- package/.docs/raw/deployment/server.mdx +282 -0
- package/.docs/raw/evals/custom-eval.mdx +22 -0
- package/.docs/raw/evals/overview.mdx +95 -0
- package/.docs/raw/evals/running-in-ci.mdx +81 -0
- package/.docs/raw/evals/textual-evals.mdx +54 -0
- package/.docs/raw/faq/index.mdx +63 -0
- package/.docs/raw/frameworks/ai-sdk.mdx +296 -0
- package/.docs/raw/frameworks/next-js.mdx +238 -0
- package/.docs/raw/getting-started/installation.mdx +442 -0
- package/.docs/raw/getting-started/mcp-docs-server.mdx +141 -0
- package/.docs/raw/getting-started/project-structure.mdx +80 -0
- package/.docs/raw/index.mdx +22 -0
- package/.docs/raw/integrations/index.mdx +213 -0
- package/.docs/raw/local-dev/add-to-existing-project.mdx +48 -0
- package/.docs/raw/local-dev/creating-a-new-project.mdx +54 -0
- package/.docs/raw/local-dev/mastra-dev.mdx +108 -0
- package/.docs/raw/memory/memory-processors.mdx +131 -0
- package/.docs/raw/memory/overview.mdx +119 -0
- package/.docs/raw/memory/semantic-recall.mdx +122 -0
- package/.docs/raw/memory/working-memory.mdx +87 -0
- package/.docs/raw/observability/logging.mdx +38 -0
- package/.docs/raw/observability/nextjs-tracing.mdx +108 -0
- package/.docs/raw/observability/tracing.mdx +115 -0
- package/.docs/raw/rag/chunking-and-embedding.mdx +156 -0
- package/.docs/raw/rag/overview.mdx +85 -0
- package/.docs/raw/rag/retrieval.mdx +365 -0
- package/.docs/raw/rag/vector-databases.mdx +340 -0
- package/.docs/raw/reference/agents/createTool.mdx +229 -0
- package/.docs/raw/reference/agents/generate.mdx +334 -0
- package/.docs/raw/reference/agents/getAgent.mdx +54 -0
- package/.docs/raw/reference/agents/stream.mdx +369 -0
- package/.docs/raw/reference/cli/build.mdx +55 -0
- package/.docs/raw/reference/cli/dev.mdx +134 -0
- package/.docs/raw/reference/cli/init.mdx +43 -0
- package/.docs/raw/reference/client-js/agents.mdx +107 -0
- package/.docs/raw/reference/client-js/error-handling.mdx +38 -0
- package/.docs/raw/reference/client-js/logs.mdx +24 -0
- package/.docs/raw/reference/client-js/memory.mdx +97 -0
- package/.docs/raw/reference/client-js/telemetry.mdx +20 -0
- package/.docs/raw/reference/client-js/tools.mdx +44 -0
- package/.docs/raw/reference/client-js/vectors.mdx +79 -0
- package/.docs/raw/reference/client-js/workflows.mdx +136 -0
- package/.docs/raw/reference/core/mastra-class.mdx +232 -0
- package/.docs/raw/reference/deployer/cloudflare.mdx +207 -0
- package/.docs/raw/reference/deployer/deployer.mdx +159 -0
- package/.docs/raw/reference/deployer/netlify.mdx +109 -0
- package/.docs/raw/reference/deployer/vercel.mdx +117 -0
- package/.docs/raw/reference/evals/answer-relevancy.mdx +186 -0
- package/.docs/raw/reference/evals/bias.mdx +186 -0
- package/.docs/raw/reference/evals/completeness.mdx +174 -0
- package/.docs/raw/reference/evals/content-similarity.mdx +183 -0
- package/.docs/raw/reference/evals/context-position.mdx +190 -0
- package/.docs/raw/reference/evals/context-precision.mdx +189 -0
- package/.docs/raw/reference/evals/context-relevancy.mdx +188 -0
- package/.docs/raw/reference/evals/contextual-recall.mdx +191 -0
- package/.docs/raw/reference/evals/faithfulness.mdx +193 -0
- package/.docs/raw/reference/evals/hallucination.mdx +219 -0
- package/.docs/raw/reference/evals/keyword-coverage.mdx +176 -0
- package/.docs/raw/reference/evals/prompt-alignment.mdx +238 -0
- package/.docs/raw/reference/evals/summarization.mdx +205 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +161 -0
- package/.docs/raw/reference/evals/tone-consistency.mdx +181 -0
- package/.docs/raw/reference/evals/toxicity.mdx +165 -0
- package/.docs/raw/reference/index.mdx +12 -0
- package/.docs/raw/reference/memory/Memory.mdx +212 -0
- package/.docs/raw/reference/memory/createThread.mdx +95 -0
- package/.docs/raw/reference/memory/getThreadById.mdx +46 -0
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +48 -0
- package/.docs/raw/reference/memory/query.mdx +167 -0
- package/.docs/raw/reference/networks/agent-network.mdx +159 -0
- package/.docs/raw/reference/observability/create-logger.mdx +106 -0
- package/.docs/raw/reference/observability/logger.mdx +55 -0
- package/.docs/raw/reference/observability/otel-config.mdx +120 -0
- package/.docs/raw/reference/observability/providers/braintrust.mdx +40 -0
- package/.docs/raw/reference/observability/providers/dash0.mdx +40 -0
- package/.docs/raw/reference/observability/providers/index.mdx +16 -0
- package/.docs/raw/reference/observability/providers/laminar.mdx +41 -0
- package/.docs/raw/reference/observability/providers/langfuse.mdx +51 -0
- package/.docs/raw/reference/observability/providers/langsmith.mdx +48 -0
- package/.docs/raw/reference/observability/providers/langwatch.mdx +45 -0
- package/.docs/raw/reference/observability/providers/new-relic.mdx +40 -0
- package/.docs/raw/reference/observability/providers/signoz.mdx +40 -0
- package/.docs/raw/reference/observability/providers/traceloop.mdx +40 -0
- package/.docs/raw/reference/rag/astra.mdx +258 -0
- package/.docs/raw/reference/rag/chroma.mdx +281 -0
- package/.docs/raw/reference/rag/chunk.mdx +235 -0
- package/.docs/raw/reference/rag/document.mdx +127 -0
- package/.docs/raw/reference/rag/embeddings.mdx +160 -0
- package/.docs/raw/reference/rag/extract-params.mdx +226 -0
- package/.docs/raw/reference/rag/graph-rag.mdx +182 -0
- package/.docs/raw/reference/rag/libsql.mdx +357 -0
- package/.docs/raw/reference/rag/metadata-filters.mdx +298 -0
- package/.docs/raw/reference/rag/pg.mdx +477 -0
- package/.docs/raw/reference/rag/pinecone.mdx +281 -0
- package/.docs/raw/reference/rag/qdrant.mdx +236 -0
- package/.docs/raw/reference/rag/rerank.mdx +212 -0
- package/.docs/raw/reference/rag/turbopuffer.mdx +249 -0
- package/.docs/raw/reference/rag/upstash.mdx +247 -0
- package/.docs/raw/reference/rag/vectorize.mdx +298 -0
- package/.docs/raw/reference/storage/libsql.mdx +74 -0
- package/.docs/raw/reference/storage/postgresql.mdx +48 -0
- package/.docs/raw/reference/storage/upstash.mdx +86 -0
- package/.docs/raw/reference/tools/client.mdx +207 -0
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +141 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +154 -0
- package/.docs/raw/reference/tools/mcp-configuration.mdx +206 -0
- package/.docs/raw/reference/tools/vector-query-tool.mdx +212 -0
- package/.docs/raw/reference/voice/composite-voice.mdx +140 -0
- package/.docs/raw/reference/voice/deepgram.mdx +164 -0
- package/.docs/raw/reference/voice/elevenlabs.mdx +216 -0
- package/.docs/raw/reference/voice/google.mdx +198 -0
- package/.docs/raw/reference/voice/mastra-voice.mdx +394 -0
- package/.docs/raw/reference/voice/murf.mdx +251 -0
- package/.docs/raw/reference/voice/openai-realtime.mdx +431 -0
- package/.docs/raw/reference/voice/openai.mdx +168 -0
- package/.docs/raw/reference/voice/playai.mdx +159 -0
- package/.docs/raw/reference/voice/sarvam.mdx +260 -0
- package/.docs/raw/reference/voice/speechify.mdx +145 -0
- package/.docs/raw/reference/voice/voice.answer.mdx +122 -0
- package/.docs/raw/reference/voice/voice.connect.mdx +124 -0
- package/.docs/raw/reference/voice/voice.listen.mdx +195 -0
- package/.docs/raw/reference/voice/voice.on.mdx +189 -0
- package/.docs/raw/reference/voice/voice.send.mdx +118 -0
- package/.docs/raw/reference/voice/voice.speak.mdx +203 -0
- package/.docs/raw/reference/workflows/after.mdx +88 -0
- package/.docs/raw/reference/workflows/afterEvent.mdx +76 -0
- package/.docs/raw/reference/workflows/commit.mdx +37 -0
- package/.docs/raw/reference/workflows/createRun.mdx +77 -0
- package/.docs/raw/reference/workflows/else.mdx +72 -0
- package/.docs/raw/reference/workflows/events.mdx +305 -0
- package/.docs/raw/reference/workflows/execute.mdx +110 -0
- package/.docs/raw/reference/workflows/if.mdx +107 -0
- package/.docs/raw/reference/workflows/resume.mdx +155 -0
- package/.docs/raw/reference/workflows/resumeWithEvent.mdx +133 -0
- package/.docs/raw/reference/workflows/snapshots.mdx +207 -0
- package/.docs/raw/reference/workflows/start.mdx +84 -0
- package/.docs/raw/reference/workflows/step-class.mdx +100 -0
- package/.docs/raw/reference/workflows/step-condition.mdx +134 -0
- package/.docs/raw/reference/workflows/step-function.mdx +92 -0
- package/.docs/raw/reference/workflows/step-options.mdx +69 -0
- package/.docs/raw/reference/workflows/step-retries.mdx +203 -0
- package/.docs/raw/reference/workflows/suspend.mdx +70 -0
- package/.docs/raw/reference/workflows/then.mdx +74 -0
- package/.docs/raw/reference/workflows/until.mdx +165 -0
- package/.docs/raw/reference/workflows/watch.mdx +118 -0
- package/.docs/raw/reference/workflows/while.mdx +168 -0
- package/.docs/raw/reference/workflows/workflow.mdx +233 -0
- package/.docs/raw/storage/overview.mdx +378 -0
- package/.docs/raw/voice/overview.mdx +135 -0
- package/.docs/raw/voice/speech-to-text.mdx +45 -0
- package/.docs/raw/voice/text-to-speech.mdx +52 -0
- package/.docs/raw/voice/voice-to-voice.mdx +310 -0
- package/.docs/raw/workflows/control-flow.mdx +778 -0
- package/.docs/raw/workflows/dynamic-workflows.mdx +236 -0
- package/.docs/raw/workflows/error-handling.mdx +183 -0
- package/.docs/raw/workflows/nested-workflows.mdx +352 -0
- package/.docs/raw/workflows/overview.mdx +203 -0
- package/.docs/raw/workflows/steps.mdx +108 -0
- package/.docs/raw/workflows/suspend-and-resume.mdx +404 -0
- package/.docs/raw/workflows/variables.mdx +313 -0
- package/LICENSE.md +46 -0
- package/README.md +129 -0
- package/dist/_tsup-dts-rollup.d.ts +149 -0
- package/dist/chunk-QWYMT5LP.js +194 -0
- package/dist/prepare-docs/prepare.d.ts +1 -0
- package/dist/prepare-docs/prepare.js +1 -0
- package/dist/stdio.d.ts +1 -0
- package/dist/stdio.js +518 -0
- package/package.json +60 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Error Handling
|
|
2
|
+
|
|
3
|
+
The Mastra Client SDK includes built-in retry mechanism and error handling capabilities.
|
|
4
|
+
|
|
5
|
+
## Error Handling
|
|
6
|
+
|
|
7
|
+
All API methods can throw errors that you can catch and handle:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
try {
|
|
11
|
+
const agent = client.getAgent("agent-id");
|
|
12
|
+
const response = await agent.generate({
|
|
13
|
+
messages: [{ role: "user", content: "Hello" }],
|
|
14
|
+
});
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error("An error occurred:", error.message);
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Retry Mechanism
|
|
21
|
+
|
|
22
|
+
The client automatically retries failed requests with exponential backoff:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
const client = new MastraClient({
|
|
26
|
+
baseUrl: "http://localhost:4111",
|
|
27
|
+
retries: 3, // Number of retry attempts
|
|
28
|
+
backoffMs: 300, // Initial backoff time
|
|
29
|
+
maxBackoffMs: 5000, // Maximum backoff time
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### How Retries Work
|
|
34
|
+
|
|
35
|
+
1. First attempt fails → Wait 300ms
|
|
36
|
+
2. Second attempt fails → Wait 600ms
|
|
37
|
+
3. Third attempt fails → Wait 1200ms
|
|
38
|
+
4. Final attempt fails → Throw error
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Logs API
|
|
2
|
+
|
|
3
|
+
The Logs API provides methods to access and query system logs and debugging information in Mastra.
|
|
4
|
+
|
|
5
|
+
## Getting Logs
|
|
6
|
+
|
|
7
|
+
Retrieve system logs with optional filtering:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
const logs = await client.getLogs({
|
|
11
|
+
transportId: "transport-1",
|
|
12
|
+
});
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Getting Logs for a Specific Run
|
|
16
|
+
|
|
17
|
+
Retrieve logs for a specific execution run:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
const runLogs = await client.getLogForRun({
|
|
21
|
+
runId: "run-1",
|
|
22
|
+
transportId: "transport-1",
|
|
23
|
+
});
|
|
24
|
+
```
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Memory API
|
|
2
|
+
|
|
3
|
+
The Memory API provides methods to manage conversation threads and message history in Mastra.
|
|
4
|
+
|
|
5
|
+
## Memory Thread Operations
|
|
6
|
+
|
|
7
|
+
### Get All Threads
|
|
8
|
+
|
|
9
|
+
Retrieve all memory threads for a specific resource:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
const threads = await client.getMemoryThreads({
|
|
13
|
+
resourceId: "resource-1",
|
|
14
|
+
agentId: "agent-1"
|
|
15
|
+
});
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Create a New Thread
|
|
19
|
+
|
|
20
|
+
Create a new memory thread:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
const thread = await client.createMemoryThread({
|
|
24
|
+
title: "New Conversation",
|
|
25
|
+
metadata: { category: "support" },
|
|
26
|
+
resourceid: "resource-1",
|
|
27
|
+
agentId: "agent-1"
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Working with a Specific Thread
|
|
32
|
+
|
|
33
|
+
Get an instance of a specific memory thread:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
const thread = client.getMemoryThread("thread-id", "agent-id");
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Thread Methods
|
|
40
|
+
|
|
41
|
+
### Get Thread Details
|
|
42
|
+
|
|
43
|
+
Retrieve details about a specific thread:
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
const details = await thread.get();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Update Thread
|
|
50
|
+
|
|
51
|
+
Update thread properties:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
const updated = await thread.update({
|
|
55
|
+
title: "Updated Title",
|
|
56
|
+
metadata: { status: "resolved" },
|
|
57
|
+
resourceid: "resource-1",
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Delete Thread
|
|
62
|
+
|
|
63
|
+
Delete a thread and its messages:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
await thread.delete();
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Message Operations
|
|
70
|
+
|
|
71
|
+
### Save Messages
|
|
72
|
+
|
|
73
|
+
Save messages to memory:
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
const savedMessages = await client.saveMessageToMemory({
|
|
77
|
+
messages: [
|
|
78
|
+
{
|
|
79
|
+
role: "user",
|
|
80
|
+
content: "Hello!",
|
|
81
|
+
id: "1",
|
|
82
|
+
threadId: "thread-1",
|
|
83
|
+
createdAt: new Date(),
|
|
84
|
+
type: "text",
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
agentId: "agent-1"
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Get Memory Status
|
|
92
|
+
|
|
93
|
+
Check the status of the memory system:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
const status = await client.getMemoryStatus("agent-id");
|
|
97
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Telemetry API
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
## Getting Traces
|
|
6
|
+
|
|
7
|
+
Retrieve traces with optional filtering and pagination:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
const telemetry = await client.getTelemetry({
|
|
11
|
+
name: "trace-name", // Optional: Filter by trace name
|
|
12
|
+
scope: "scope-name", // Optional: Filter by scope
|
|
13
|
+
page: 1, // Optional: Page number for pagination
|
|
14
|
+
perPage: 10, // Optional: Number of items per page
|
|
15
|
+
attribute: {
|
|
16
|
+
// Optional: Filter by custom attributes
|
|
17
|
+
key: "value",
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
```
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Tools API
|
|
2
|
+
|
|
3
|
+
The Tools API provides methods to interact with and execute tools available in the Mastra platform.
|
|
4
|
+
|
|
5
|
+
## Getting All Tools
|
|
6
|
+
|
|
7
|
+
Retrieve a list of all available tools:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
const tools = await client.getTools();
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Working with a Specific Tool
|
|
14
|
+
|
|
15
|
+
Get an instance of a specific tool:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
const tool = client.getTool("tool-id");
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Tool Methods
|
|
22
|
+
|
|
23
|
+
### Get Tool Details
|
|
24
|
+
|
|
25
|
+
Retrieve detailed information about a tool:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
const details = await tool.details();
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Execute Tool
|
|
32
|
+
|
|
33
|
+
Execute a tool with specific arguments:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
const result = await tool.execute({
|
|
37
|
+
args: {
|
|
38
|
+
param1: "value1",
|
|
39
|
+
param2: "value2",
|
|
40
|
+
},
|
|
41
|
+
threadId: "thread-1", // Optional: Thread context
|
|
42
|
+
resourceid: "resource-1", // Optional: Resource identifier
|
|
43
|
+
});
|
|
44
|
+
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Vectors API
|
|
2
|
+
|
|
3
|
+
The Vectors API provides methods to work with vector embeddings for semantic search and similarity matching in Mastra.
|
|
4
|
+
|
|
5
|
+
## Working with Vectors
|
|
6
|
+
|
|
7
|
+
Get an instance of a vector store:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
const vector = client.getVector("vector-name");
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Vector Methods
|
|
14
|
+
|
|
15
|
+
### Get Vector Index Details
|
|
16
|
+
|
|
17
|
+
Retrieve information about a specific vector index:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
const details = await vector.details("index-name");
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Create Vector Index
|
|
24
|
+
|
|
25
|
+
Create a new vector index:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
const result = await vector.createIndex({
|
|
29
|
+
indexName: "new-index",
|
|
30
|
+
dimension: 128,
|
|
31
|
+
metric: "cosine", // 'cosine', 'euclidean', or 'dotproduct'
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Upsert Vectors
|
|
36
|
+
|
|
37
|
+
Add or update vectors in an index:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
const ids = await vector.upsert({
|
|
41
|
+
indexName: "my-index",
|
|
42
|
+
vectors: [
|
|
43
|
+
[0.1, 0.2, 0.3], // First vector
|
|
44
|
+
[0.4, 0.5, 0.6], // Second vector
|
|
45
|
+
],
|
|
46
|
+
metadata: [{ label: "first" }, { label: "second" }],
|
|
47
|
+
ids: ["id1", "id2"], // Optional: Custom IDs
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Query Vectors
|
|
52
|
+
|
|
53
|
+
Search for similar vectors:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
const results = await vector.query({
|
|
57
|
+
indexName: "my-index",
|
|
58
|
+
queryVector: [0.1, 0.2, 0.3],
|
|
59
|
+
topK: 10,
|
|
60
|
+
filter: { label: "first" }, // Optional: Metadata filter
|
|
61
|
+
includeVector: true, // Optional: Include vectors in results
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Get All Indexes
|
|
66
|
+
|
|
67
|
+
List all available indexes:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const indexes = await vector.getIndexes();
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Delete Index
|
|
74
|
+
|
|
75
|
+
Delete a vector index:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
const result = await vector.delete("index-name");
|
|
79
|
+
```
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Workflows API
|
|
2
|
+
|
|
3
|
+
The Workflows API provides methods to interact with and execute automated workflows in Mastra.
|
|
4
|
+
|
|
5
|
+
## Getting All Workflows
|
|
6
|
+
|
|
7
|
+
Retrieve a list of all available workflows:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
const workflows = await client.getWorkflows();
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Working with a Specific Workflow
|
|
14
|
+
|
|
15
|
+
Get an instance of a specific workflow:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
const workflow = client.getWorkflow("workflow-id");
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Workflow Methods
|
|
22
|
+
|
|
23
|
+
### Get Workflow Details
|
|
24
|
+
|
|
25
|
+
Retrieve detailed information about a workflow:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
const details = await workflow.details();
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Start workflow run asynchronously
|
|
32
|
+
|
|
33
|
+
Start a workflow run with triggerData and await full run results:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
const {runId} = workflow.createRun()
|
|
37
|
+
|
|
38
|
+
const result = await workflow.startAsync({
|
|
39
|
+
runId,
|
|
40
|
+
triggerData: {
|
|
41
|
+
param1: "value1",
|
|
42
|
+
param2: "value2",
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Resume Workflow run asynchronously
|
|
48
|
+
|
|
49
|
+
Resume a suspended workflow step and await full run result:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
const {runId} = createRun({runId: prevRunId})
|
|
53
|
+
|
|
54
|
+
const result = await workflow.resumeAsync({
|
|
55
|
+
runId,
|
|
56
|
+
stepId: "step-id",
|
|
57
|
+
contextData: { key: "value" },
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Watch Workflow
|
|
62
|
+
|
|
63
|
+
Watch workflow transitions
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
try{
|
|
67
|
+
// Get workflow instance
|
|
68
|
+
const workflow = client.getWorkflow("workflow-id");
|
|
69
|
+
|
|
70
|
+
// Create a workflow run
|
|
71
|
+
const {runId} = workflow.createRun()
|
|
72
|
+
|
|
73
|
+
// Watch workflow run
|
|
74
|
+
workflow.watch({runId},(record)=>{
|
|
75
|
+
// Every new record is the latest transition state of the workflow run
|
|
76
|
+
|
|
77
|
+
console.log({
|
|
78
|
+
activePaths: record.activePaths,
|
|
79
|
+
results: record.results,
|
|
80
|
+
timestamp: record.timestamp,
|
|
81
|
+
runId: record.runId
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Start workflow run
|
|
86
|
+
workflow.start({
|
|
87
|
+
runId,
|
|
88
|
+
triggerData: {
|
|
89
|
+
city: 'New York',
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}catch(e){
|
|
93
|
+
console.error(e);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
### Resume Workflow
|
|
97
|
+
|
|
98
|
+
Resume workflow run and watch workflow step transitions
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
try{
|
|
102
|
+
//To resume a workflow run, when a step is suspended
|
|
103
|
+
const {run} = createRun({runId: prevRunId})
|
|
104
|
+
|
|
105
|
+
//Watch run
|
|
106
|
+
workflow.watch({runId},(record)=>{
|
|
107
|
+
// Every new record is the latest transition state of the workflow run
|
|
108
|
+
|
|
109
|
+
console.log({
|
|
110
|
+
activePaths: record.activePaths,
|
|
111
|
+
results: record.results,
|
|
112
|
+
timestamp: record.timestamp,
|
|
113
|
+
runId: record.runId
|
|
114
|
+
});
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
//resume run
|
|
118
|
+
workflow.resume({
|
|
119
|
+
runId,
|
|
120
|
+
stepId: "step-id",
|
|
121
|
+
contextData: { key: "value" },
|
|
122
|
+
});
|
|
123
|
+
}catch(e){
|
|
124
|
+
console.error(e);
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Workflow run result
|
|
129
|
+
A workflow run result yields the following:
|
|
130
|
+
|
|
131
|
+
| Field | Type | Description |
|
|
132
|
+
|-------|------|-------------|
|
|
133
|
+
| `activePaths` | `Record<string, { status: string; suspendPayload?: any; stepPath: string[] }>` | Currently active paths in the workflow with their execution status |
|
|
134
|
+
| `results` | `CoreWorkflowRunResult<any, any, any>['results']` | Results from the workflow execution |
|
|
135
|
+
| `timestamp` | `number` | Unix timestamp of when this transition occurred |
|
|
136
|
+
| `runId` | `string` | Unique identifier for this workflow run instance |
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Mastra Core"
|
|
3
|
+
description: Documentation for the Mastra Class, the core entry point for managing agents, workflows, and server endpoints.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# The Mastra Class
|
|
7
|
+
|
|
8
|
+
The Mastra class is the core entry point for your application. It manages agents, workflows, and server endpoints.
|
|
9
|
+
|
|
10
|
+
## Constructor Options
|
|
11
|
+
|
|
12
|
+
<PropertiesTable
|
|
13
|
+
content={[
|
|
14
|
+
{
|
|
15
|
+
name: "agents",
|
|
16
|
+
type: "Agent[]",
|
|
17
|
+
description: "Array of Agent instances to register",
|
|
18
|
+
isOptional: true,
|
|
19
|
+
defaultValue: "[]",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "tools",
|
|
23
|
+
type: "Record<string, ToolApi>",
|
|
24
|
+
description:
|
|
25
|
+
"Custom tools to register. Structured as a key-value pair, with keys being the tool name and values being the tool function.",
|
|
26
|
+
isOptional: true,
|
|
27
|
+
defaultValue: "{}",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "storage",
|
|
31
|
+
type: "MastraStorage",
|
|
32
|
+
description: "Storage engine instance for persisting data",
|
|
33
|
+
isOptional: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "vectors",
|
|
37
|
+
type: "Record<string, MastraVector>",
|
|
38
|
+
description:
|
|
39
|
+
"Vector store instance, used for semantic search and vector-based tools (eg Pinecone, PgVector or Qdrant)",
|
|
40
|
+
isOptional: true,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "logger",
|
|
44
|
+
type: "Logger",
|
|
45
|
+
description: "Logger instance created with createLogger()",
|
|
46
|
+
isOptional: true,
|
|
47
|
+
defaultValue: "Console logger with INFO level",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "workflows",
|
|
51
|
+
type: "Record<string, Workflow>",
|
|
52
|
+
description: "Workflows to register. Structured as a key-value pair, with keys being the workflow name and values being the workflow instance.",
|
|
53
|
+
isOptional: true,
|
|
54
|
+
defaultValue: "{}",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "serverMiddleware",
|
|
58
|
+
type: "Array<{ handler: (c: any, next: () => Promise<void>) => Promise<Response | void>; path?: string; }>",
|
|
59
|
+
description: "Server middleware functions to be applied to API routes. Each middleware can specify a path pattern (defaults to '/api/*').",
|
|
60
|
+
isOptional: true,
|
|
61
|
+
defaultValue: "[]",
|
|
62
|
+
},
|
|
63
|
+
]}
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
## Initialization
|
|
67
|
+
|
|
68
|
+
The Mastra class is typically initialized in your `src/mastra/index.ts` file:
|
|
69
|
+
|
|
70
|
+
```typescript copy filename=src/mastra/index.ts
|
|
71
|
+
import { Mastra } from "@mastra/core";
|
|
72
|
+
import { createLogger } from "@mastra/core/logger";
|
|
73
|
+
|
|
74
|
+
// Basic initialization
|
|
75
|
+
export const mastra = new Mastra({});
|
|
76
|
+
|
|
77
|
+
// Full initialization with all options
|
|
78
|
+
export const mastra = new Mastra({
|
|
79
|
+
agents: {},
|
|
80
|
+
workflows: [],
|
|
81
|
+
integrations: [],
|
|
82
|
+
logger: createLogger({
|
|
83
|
+
name: "My Project",
|
|
84
|
+
level: "info",
|
|
85
|
+
}),
|
|
86
|
+
storage: {},
|
|
87
|
+
tools: {},
|
|
88
|
+
vectors: {},
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
You can think of the `Mastra` class as a top-level registry. When you register tools with Mastra, your registered agents and workflows can use them. When you register integrations with Mastra, agents, workflows, and tools can use them.
|
|
93
|
+
|
|
94
|
+
## Methods
|
|
95
|
+
|
|
96
|
+
<PropertiesTable
|
|
97
|
+
content={[
|
|
98
|
+
{
|
|
99
|
+
name: "getAgent(name)",
|
|
100
|
+
type: "Agent",
|
|
101
|
+
description:
|
|
102
|
+
"Returns an agent instance by id. Throws if agent not found.",
|
|
103
|
+
example: 'const agent = mastra.getAgent("agentOne");',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "getAgents()",
|
|
107
|
+
type: "Record<string, Agent>",
|
|
108
|
+
description:
|
|
109
|
+
"Returns all registered agents as a key-value object.",
|
|
110
|
+
example: 'const agents = mastra.getAgents();',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "getWorkflow(id, { serialized })",
|
|
114
|
+
type: "Workflow",
|
|
115
|
+
description:
|
|
116
|
+
"Returns a workflow instance by id. The serialized option (default: false) returns a simplified representation with just the name.",
|
|
117
|
+
example: 'const workflow = mastra.getWorkflow("myWorkflow");',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "getWorkflows({ serialized })",
|
|
121
|
+
type: "Record<string, Workflow>",
|
|
122
|
+
description:
|
|
123
|
+
"Returns all registered workflows. The serialized option (default: false) returns simplified representations.",
|
|
124
|
+
example: 'const workflows = mastra.getWorkflows();',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "getVector(name)",
|
|
128
|
+
type: "MastraVector",
|
|
129
|
+
description:
|
|
130
|
+
"Returns a vector store instance by name. Throws if not found.",
|
|
131
|
+
example: 'const vectorStore = mastra.getVector("myVectorStore");',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "getVectors()",
|
|
135
|
+
type: "Record<string, MastraVector>",
|
|
136
|
+
description:
|
|
137
|
+
"Returns all registered vector stores as a key-value object.",
|
|
138
|
+
example: 'const vectorStores = mastra.getVectors();',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: "getDeployer()",
|
|
142
|
+
type: "MastraDeployer | undefined",
|
|
143
|
+
description:
|
|
144
|
+
"Returns the configured deployer instance, if any.",
|
|
145
|
+
example: 'const deployer = mastra.getDeployer();',
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "getStorage()",
|
|
149
|
+
type: "MastraStorage | undefined",
|
|
150
|
+
description:
|
|
151
|
+
"Returns the configured storage instance.",
|
|
152
|
+
example: 'const storage = mastra.getStorage();',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "getMemory()",
|
|
156
|
+
type: "MastraMemory | undefined",
|
|
157
|
+
description:
|
|
158
|
+
"Returns the configured memory instance. Note: This is deprecated, memory should be added to agents directly.",
|
|
159
|
+
example: 'const memory = mastra.getMemory();',
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "getServerMiddleware()",
|
|
163
|
+
type: "Array<{ handler: Function; path: string; }>",
|
|
164
|
+
description:
|
|
165
|
+
"Returns the configured server middleware functions.",
|
|
166
|
+
example: 'const middleware = mastra.getServerMiddleware();',
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "setStorage(storage)",
|
|
170
|
+
type: "void",
|
|
171
|
+
description:
|
|
172
|
+
"Sets the storage instance for the Mastra instance.",
|
|
173
|
+
example: 'mastra.setStorage(new DefaultStorage());',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "setLogger({ logger })",
|
|
177
|
+
type: "void",
|
|
178
|
+
description:
|
|
179
|
+
"Sets the logger for all components (agents, workflows, etc.).",
|
|
180
|
+
example: 'mastra.setLogger({ logger: createLogger({ name: "MyLogger" }) });',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "setTelemetry(telemetry)",
|
|
184
|
+
type: "void",
|
|
185
|
+
description:
|
|
186
|
+
"Sets the telemetry configuration for all components.",
|
|
187
|
+
example: 'mastra.setTelemetry({ export: { type: "console" } });',
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: "getLogger()",
|
|
191
|
+
type: "Logger",
|
|
192
|
+
description:
|
|
193
|
+
"Gets the configured logger instance.",
|
|
194
|
+
example: 'const logger = mastra.getLogger();',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: "getTelemetry()",
|
|
198
|
+
type: "Telemetry | undefined",
|
|
199
|
+
description:
|
|
200
|
+
"Gets the configured telemetry instance.",
|
|
201
|
+
example: 'const telemetry = mastra.getTelemetry();',
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: "getLogsByRunId({ runId, transportId })",
|
|
205
|
+
type: "Promise<any>",
|
|
206
|
+
description:
|
|
207
|
+
"Retrieves logs for a specific run ID and transport ID.",
|
|
208
|
+
example: 'const logs = await mastra.getLogsByRunId({ runId: "123", transportId: "456" });',
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
name: "getLogs(transportId)",
|
|
212
|
+
type: "Promise<any>",
|
|
213
|
+
description:
|
|
214
|
+
"Retrieves all logs for a specific transport ID.",
|
|
215
|
+
example: 'const logs = await mastra.getLogs("transportId");',
|
|
216
|
+
},
|
|
217
|
+
]}
|
|
218
|
+
/>
|
|
219
|
+
|
|
220
|
+
## Error Handling
|
|
221
|
+
|
|
222
|
+
The Mastra class methods throw typed errors that can be caught:
|
|
223
|
+
|
|
224
|
+
```typescript copy
|
|
225
|
+
try {
|
|
226
|
+
const tool = mastra.getTool("nonexistentTool");
|
|
227
|
+
} catch (error) {
|
|
228
|
+
if (error instanceof Error) {
|
|
229
|
+
console.log(error.message); // "Tool with name nonexistentTool not found"
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
```
|