@mastra/mcp-docs-server 1.0.0-beta.13 → 1.0.0-beta.15
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%2Fagent-builder.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +78 -78
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +195 -195
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +173 -173
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +195 -195
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +195 -195
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +248 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +338 -338
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +41 -41
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +195 -195
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Flance.md +195 -195
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +195 -195
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +139 -139
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +219 -219
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +219 -219
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +235 -235
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +102 -102
- package/.docs/organized/changelogs/%40mastra%2Frag.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Freact.md +77 -70
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +218 -218
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +195 -195
- package/.docs/organized/changelogs/create-mastra.md +13 -13
- package/.docs/organized/changelogs/mastra.md +56 -56
- package/.docs/organized/code-examples/agent-v6.md +210 -0
- package/.docs/organized/code-examples/ai-elements.md +1 -1
- package/.docs/organized/code-examples/client-side-tools.md +1 -1
- package/.docs/raw/agents/adding-voice.mdx +10 -6
- package/.docs/raw/agents/agent-approval.mdx +5 -6
- package/.docs/raw/agents/agent-memory.mdx +22 -30
- package/.docs/raw/agents/guardrails.mdx +60 -50
- package/.docs/raw/agents/networks.mdx +8 -12
- package/.docs/raw/agents/overview.mdx +39 -23
- package/.docs/raw/agents/processors.mdx +20 -19
- package/.docs/raw/agents/structured-output.mdx +11 -7
- package/.docs/raw/agents/using-tools.mdx +4 -5
- package/.docs/raw/deployment/mastra-server.mdx +3 -3
- package/.docs/raw/deployment/overview.mdx +7 -1
- package/.docs/raw/deployment/web-framework.mdx +4 -6
- package/.docs/raw/deployment/workflow-runners.mdx +14 -0
- package/.docs/raw/evals/custom-scorers.mdx +9 -6
- package/.docs/raw/evals/overview.mdx +3 -6
- package/.docs/raw/evals/running-in-ci.mdx +2 -2
- package/.docs/raw/getting-started/manual-install.mdx +20 -20
- package/.docs/raw/getting-started/mcp-docs-server.mdx +2 -2
- package/.docs/raw/getting-started/studio.mdx +1 -1
- package/.docs/raw/guides/agent-frameworks/ai-sdk.mdx +4 -4
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +30 -30
- package/.docs/raw/guides/build-your-ui/assistant-ui.mdx +8 -8
- package/.docs/raw/guides/build-your-ui/copilotkit.mdx +11 -11
- package/.docs/raw/guides/deployment/amazon-ec2.mdx +9 -9
- package/.docs/raw/guides/deployment/aws-lambda.mdx +11 -11
- package/.docs/raw/guides/deployment/azure-app-services.mdx +2 -2
- package/.docs/raw/guides/deployment/cloudflare-deployer.mdx +5 -6
- package/.docs/raw/guides/deployment/digital-ocean.mdx +10 -10
- package/.docs/raw/guides/deployment/index.mdx +1 -1
- package/.docs/raw/guides/deployment/inngest.mdx +444 -0
- package/.docs/raw/guides/deployment/netlify-deployer.mdx +4 -4
- package/.docs/raw/guides/deployment/vercel-deployer.mdx +5 -6
- package/.docs/raw/guides/getting-started/astro.mdx +292 -451
- package/.docs/raw/guides/getting-started/express.mdx +7 -7
- package/.docs/raw/guides/getting-started/hono.mdx +18 -18
- package/.docs/raw/guides/getting-started/next-js.mdx +19 -20
- package/.docs/raw/guides/getting-started/quickstart.mdx +4 -4
- package/.docs/raw/guides/getting-started/sveltekit.mdx +238 -409
- package/.docs/raw/guides/getting-started/vite-react.mdx +21 -21
- package/.docs/raw/guides/guide/ai-recruiter.mdx +10 -10
- package/.docs/raw/guides/guide/chef-michel.mdx +9 -11
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +15 -15
- package/.docs/raw/guides/guide/research-assistant.mdx +13 -13
- package/.docs/raw/guides/guide/stock-agent.mdx +5 -5
- package/.docs/raw/guides/guide/web-search.mdx +8 -8
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +7 -7
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +2 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +1 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +11 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/processors.mdx +11 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +41 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +0 -2
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +21 -23
- package/.docs/raw/index.mdx +2 -2
- package/.docs/raw/mastra-cloud/deployment.mdx +39 -0
- package/.docs/raw/mastra-cloud/observability.mdx +9 -15
- package/.docs/raw/mastra-cloud/overview.mdx +14 -44
- package/.docs/raw/mastra-cloud/setup.mdx +64 -0
- package/.docs/raw/mastra-cloud/studio.mdx +35 -0
- package/.docs/raw/mcp/overview.mdx +31 -13
- package/.docs/raw/mcp/publishing-mcp-server.mdx +2 -2
- package/.docs/raw/memory/memory-processors.mdx +9 -9
- package/.docs/raw/memory/message-history.mdx +69 -0
- package/.docs/raw/memory/overview.mdx +34 -76
- package/.docs/raw/memory/semantic-recall.mdx +58 -49
- package/.docs/raw/memory/storage.mdx +188 -0
- package/.docs/raw/memory/working-memory.mdx +7 -7
- package/.docs/raw/observability/logging.mdx +9 -10
- package/.docs/raw/observability/overview.mdx +0 -1
- package/.docs/raw/observability/tracing/bridges/otel.mdx +2 -2
- package/.docs/raw/observability/tracing/exporters/default.mdx +3 -3
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +1 -2
- package/.docs/raw/observability/tracing/overview.mdx +23 -25
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +3 -3
- package/.docs/raw/rag/chunking-and-embedding.mdx +6 -6
- package/.docs/raw/rag/graph-rag.mdx +7 -7
- package/.docs/raw/rag/overview.mdx +1 -1
- package/.docs/raw/rag/retrieval.mdx +21 -22
- package/.docs/raw/rag/vector-databases.mdx +22 -22
- package/.docs/raw/reference/agents/agent.mdx +3 -3
- package/.docs/raw/reference/agents/generate.mdx +1 -1
- package/.docs/raw/reference/agents/generateLegacy.mdx +2 -2
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +2 -2
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +2 -2
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +2 -2
- package/.docs/raw/reference/agents/getDescription.mdx +1 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +2 -2
- package/.docs/raw/reference/agents/getLLM.mdx +2 -2
- package/.docs/raw/reference/agents/getMemory.mdx +2 -2
- package/.docs/raw/reference/agents/getModel.mdx +2 -2
- package/.docs/raw/reference/agents/getTools.mdx +2 -2
- package/.docs/raw/reference/agents/getVoice.mdx +2 -2
- package/.docs/raw/reference/agents/listAgents.mdx +2 -2
- package/.docs/raw/reference/agents/listScorers.mdx +2 -2
- package/.docs/raw/reference/agents/listTools.mdx +2 -2
- package/.docs/raw/reference/agents/listWorkflows.mdx +2 -2
- package/.docs/raw/reference/agents/network.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/chat-route.mdx +2 -2
- package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/network-route.mdx +2 -2
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-stream.mdx +6 -6
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v4-messages.mdx +3 -3
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v5-messages.mdx +3 -3
- package/.docs/raw/reference/ai-sdk/with-mastra.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/workflow-route.mdx +2 -2
- package/.docs/raw/reference/auth/auth0.mdx +1 -2
- package/.docs/raw/reference/auth/clerk.mdx +1 -2
- package/.docs/raw/reference/auth/firebase.mdx +2 -4
- package/.docs/raw/reference/auth/jwt.mdx +1 -2
- package/.docs/raw/reference/auth/supabase.mdx +1 -2
- package/.docs/raw/reference/auth/workos.mdx +1 -2
- package/.docs/raw/reference/cli/create-mastra.mdx +10 -10
- package/.docs/raw/reference/cli/mastra.mdx +9 -9
- package/.docs/raw/reference/client-js/agents.mdx +1 -2
- package/.docs/raw/reference/client-js/mastra-client.mdx +1 -1
- package/.docs/raw/reference/core/getAgent.mdx +1 -1
- package/.docs/raw/reference/core/getAgentById.mdx +1 -1
- package/.docs/raw/reference/core/getDeployer.mdx +1 -1
- package/.docs/raw/reference/core/getLogger.mdx +1 -1
- package/.docs/raw/reference/core/getMCPServer.mdx +1 -1
- package/.docs/raw/reference/core/getMCPServerById.mdx +1 -1
- package/.docs/raw/reference/core/getMemory.mdx +2 -2
- package/.docs/raw/reference/core/getServer.mdx +1 -1
- package/.docs/raw/reference/core/getStorage.mdx +2 -2
- package/.docs/raw/reference/core/getStoredAgentById.mdx +3 -3
- package/.docs/raw/reference/core/getTelemetry.mdx +1 -1
- package/.docs/raw/reference/core/getVector.mdx +1 -1
- package/.docs/raw/reference/core/getWorkflow.mdx +1 -1
- package/.docs/raw/reference/core/listAgents.mdx +1 -1
- package/.docs/raw/reference/core/listLogs.mdx +1 -1
- package/.docs/raw/reference/core/listLogsByRunId.mdx +1 -1
- package/.docs/raw/reference/core/listMCPServers.mdx +1 -1
- package/.docs/raw/reference/core/listMemory.mdx +2 -2
- package/.docs/raw/reference/core/listStoredAgents.mdx +4 -4
- package/.docs/raw/reference/core/listVectors.mdx +1 -1
- package/.docs/raw/reference/core/listWorkflows.mdx +1 -1
- package/.docs/raw/reference/core/setLogger.mdx +1 -1
- package/.docs/raw/reference/core/setStorage.mdx +2 -2
- package/.docs/raw/reference/core/setTelemetry.mdx +1 -1
- package/.docs/raw/reference/deployer/cloudflare.mdx +1 -2
- package/.docs/raw/reference/deployer/deployer.mdx +0 -1
- package/.docs/raw/reference/deployer/netlify.mdx +1 -1
- package/.docs/raw/reference/deployer/vercel.mdx +2 -4
- package/.docs/raw/reference/evals/answer-relevancy.mdx +1 -1
- package/.docs/raw/reference/evals/answer-similarity.mdx +1 -1
- package/.docs/raw/reference/evals/bias.mdx +1 -1
- package/.docs/raw/reference/evals/completeness.mdx +1 -1
- package/.docs/raw/reference/evals/content-similarity.mdx +1 -1
- package/.docs/raw/reference/evals/context-precision.mdx +1 -1
- package/.docs/raw/reference/evals/faithfulness.mdx +1 -1
- package/.docs/raw/reference/evals/hallucination.mdx +1 -1
- package/.docs/raw/reference/evals/keyword-coverage.mdx +1 -1
- package/.docs/raw/reference/evals/prompt-alignment.mdx +7 -7
- package/.docs/raw/reference/evals/textual-difference.mdx +1 -1
- package/.docs/raw/reference/evals/tone-consistency.mdx +1 -1
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +10 -10
- package/.docs/raw/reference/evals/toxicity.mdx +1 -1
- package/.docs/raw/reference/logging/pino-logger.mdx +7 -8
- package/.docs/raw/reference/memory/createThread.mdx +2 -2
- package/.docs/raw/reference/memory/deleteMessages.mdx +2 -2
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +2 -2
- package/.docs/raw/reference/memory/memory-class.mdx +3 -3
- package/.docs/raw/reference/memory/query.mdx +2 -2
- package/.docs/raw/reference/memory/recall.mdx +2 -2
- package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +1 -1
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +2 -2
- package/.docs/raw/reference/processors/language-detector.mdx +2 -2
- package/.docs/raw/reference/processors/message-history-processor.mdx +2 -2
- package/.docs/raw/reference/processors/moderation-processor.mdx +3 -3
- package/.docs/raw/reference/processors/pii-detector.mdx +3 -3
- package/.docs/raw/reference/processors/processor-interface.mdx +13 -13
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +2 -2
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +2 -2
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +2 -2
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +40 -19
- package/.docs/raw/reference/processors/tool-call-filter.mdx +3 -3
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +2 -2
- package/.docs/raw/reference/processors/working-memory-processor.mdx +3 -3
- package/.docs/raw/reference/rag/chunk.mdx +1 -1
- package/.docs/raw/reference/rag/extract-params.mdx +2 -2
- package/.docs/raw/reference/rag/metadata-filters.mdx +7 -7
- package/.docs/raw/reference/server/create-route.mdx +13 -13
- package/.docs/raw/reference/server/express-adapter.mdx +6 -7
- package/.docs/raw/reference/server/hono-adapter.mdx +6 -7
- package/.docs/raw/reference/server/mastra-server.mdx +20 -20
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +7 -5
- package/.docs/raw/reference/storage/cloudflare.mdx +2 -2
- package/.docs/raw/reference/storage/convex.mdx +6 -6
- package/.docs/raw/reference/storage/dynamodb.mdx +4 -4
- package/.docs/raw/reference/storage/lance.mdx +6 -5
- package/.docs/raw/reference/storage/libsql.mdx +72 -54
- package/.docs/raw/reference/storage/mongodb.mdx +84 -9
- package/.docs/raw/reference/storage/mssql.mdx +8 -6
- package/.docs/raw/{memory → reference}/storage/overview.mdx +12 -110
- package/.docs/raw/reference/storage/postgresql.mdx +82 -9
- package/.docs/raw/reference/storage/upstash.mdx +74 -2
- package/.docs/raw/reference/streaming/agents/stream.mdx +5 -5
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +2 -2
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +1 -1
- package/.docs/raw/reference/streaming/workflows/resumeStream.mdx +1 -1
- package/.docs/raw/reference/streaming/workflows/stream.mdx +2 -2
- package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +4 -4
- package/.docs/raw/reference/templates/overview.mdx +1 -2
- package/.docs/raw/reference/tools/create-tool.mdx +1 -4
- package/.docs/raw/reference/tools/vector-query-tool.mdx +1 -1
- package/.docs/raw/reference/vectors/astra.mdx +3 -3
- package/.docs/raw/reference/vectors/chroma.mdx +3 -3
- package/.docs/raw/reference/vectors/convex.mdx +12 -12
- package/.docs/raw/reference/vectors/couchbase.mdx +5 -5
- package/.docs/raw/reference/vectors/duckdb.mdx +10 -10
- package/.docs/raw/reference/vectors/elasticsearch.mdx +4 -4
- package/.docs/raw/reference/vectors/lance.mdx +4 -4
- package/.docs/raw/reference/vectors/libsql.mdx +61 -11
- package/.docs/raw/reference/vectors/mongodb.mdx +58 -5
- package/.docs/raw/reference/vectors/pg.mdx +53 -6
- package/.docs/raw/reference/vectors/pinecone.mdx +3 -3
- package/.docs/raw/reference/vectors/qdrant.mdx +3 -3
- package/.docs/raw/reference/vectors/s3vectors.mdx +6 -6
- package/.docs/raw/reference/vectors/turbopuffer.mdx +4 -4
- package/.docs/raw/reference/vectors/upstash.mdx +55 -6
- package/.docs/raw/reference/vectors/vectorize.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +1 -3
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/start.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/startAsync.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +5 -5
- package/.docs/raw/reference/workflows/run.mdx +1 -1
- package/.docs/raw/reference/workflows/step.mdx +3 -3
- package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +3 -3
- package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +6 -6
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +7 -7
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow.mdx +3 -3
- package/.docs/raw/server/auth/auth0.mdx +20 -14
- package/.docs/raw/server/auth/clerk.mdx +16 -9
- package/.docs/raw/server/auth/firebase.mdx +21 -15
- package/.docs/raw/server/auth/jwt.mdx +14 -7
- package/.docs/raw/server/auth/supabase.mdx +16 -9
- package/.docs/raw/server/auth/workos.mdx +19 -13
- package/.docs/raw/server/custom-adapters.mdx +10 -10
- package/.docs/raw/server/custom-api-routes.mdx +2 -4
- package/.docs/raw/server/mastra-client.mdx +24 -13
- package/.docs/raw/server/mastra-server.mdx +3 -3
- package/.docs/raw/server/middleware.mdx +7 -7
- package/.docs/raw/server/request-context.mdx +31 -30
- package/.docs/raw/server/server-adapters.mdx +6 -6
- package/.docs/raw/streaming/events.mdx +14 -7
- package/.docs/raw/streaming/overview.mdx +21 -10
- package/.docs/raw/streaming/tool-streaming.mdx +6 -6
- package/.docs/raw/streaming/workflow-streaming.mdx +6 -8
- package/.docs/raw/tools-mcp/advanced-usage.mdx +2 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +31 -12
- package/.docs/raw/tools-mcp/overview.mdx +9 -10
- package/.docs/raw/voice/overview.mdx +2 -2
- package/.docs/raw/workflows/agents-and-tools.mdx +28 -19
- package/.docs/raw/workflows/control-flow.mdx +27 -40
- package/.docs/raw/workflows/error-handling.mdx +15 -22
- package/.docs/raw/workflows/human-in-the-loop.mdx +6 -7
- package/.docs/raw/workflows/input-data-mapping.mdx +7 -7
- package/.docs/raw/workflows/overview.mdx +34 -23
- package/.docs/raw/workflows/snapshots.mdx +16 -45
- package/.docs/raw/workflows/suspend-and-resume.mdx +7 -7
- package/.docs/raw/workflows/time-travel.mdx +16 -16
- package/.docs/raw/workflows/workflow-state.mdx +5 -8
- package/CHANGELOG.md +16 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/stdio.js +53 -0
- package/package.json +3 -3
- package/.docs/raw/mastra-cloud/dashboard.mdx +0 -96
- package/.docs/raw/mastra-cloud/setting-up.mdx +0 -102
- package/.docs/raw/memory/conversation-history.mdx +0 -24
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +0 -140
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +0 -150
- package/.docs/raw/memory/storage/memory-with-pg.mdx +0 -138
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +0 -146
- package/.docs/raw/memory/threads-and-resources.mdx +0 -95
- package/.docs/raw/workflows/inngest-workflow.mdx +0 -363
|
@@ -27,25 +27,25 @@ Run the following command to [create a new React + Vite app](https://vite.dev/gu
|
|
|
27
27
|
|
|
28
28
|
<Tabs groupId="pm">
|
|
29
29
|
<TabItem value="npm" label="npm">
|
|
30
|
-
```bash
|
|
30
|
+
```bash
|
|
31
31
|
npm create vite@latest mastra-react -- --template react-ts
|
|
32
32
|
cd mastra-react
|
|
33
33
|
```
|
|
34
34
|
</TabItem>
|
|
35
35
|
<TabItem value="pnpm" label="pnpm">
|
|
36
|
-
```bash
|
|
36
|
+
```bash
|
|
37
37
|
pnpm create vite mastra-react --template react-ts
|
|
38
38
|
cd mastra-react
|
|
39
39
|
```
|
|
40
40
|
</TabItem>
|
|
41
41
|
<TabItem value="yarn" label="yarn">
|
|
42
|
-
```bash
|
|
42
|
+
```bash
|
|
43
43
|
yarn create vite mastra-react --template react-ts
|
|
44
44
|
cd mastra-react
|
|
45
45
|
```
|
|
46
46
|
</TabItem>
|
|
47
47
|
<TabItem value="bun" label="bun">
|
|
48
|
-
```bash
|
|
48
|
+
```bash
|
|
49
49
|
bun create vite mastra-react --template react-ts
|
|
50
50
|
cd mastra-react
|
|
51
51
|
```
|
|
@@ -60,22 +60,22 @@ Next, install Tailwind:
|
|
|
60
60
|
|
|
61
61
|
<Tabs groupId="pm">
|
|
62
62
|
<TabItem value="npm" label="npm">
|
|
63
|
-
```bash
|
|
63
|
+
```bash
|
|
64
64
|
npm install tailwindcss @tailwindcss/vite
|
|
65
65
|
```
|
|
66
66
|
</TabItem>
|
|
67
67
|
<TabItem value="pnpm" label="pnpm">
|
|
68
|
-
```bash
|
|
68
|
+
```bash
|
|
69
69
|
pnpm add tailwindcss @tailwindcss/vite
|
|
70
70
|
```
|
|
71
71
|
</TabItem>
|
|
72
72
|
<TabItem value="yarn" label="yarn">
|
|
73
|
-
```bash
|
|
73
|
+
```bash
|
|
74
74
|
yarn add tailwindcss @tailwindcss/vite
|
|
75
75
|
```
|
|
76
76
|
</TabItem>
|
|
77
77
|
<TabItem value="bun" label="bun">
|
|
78
|
-
```bash
|
|
78
|
+
```bash
|
|
79
79
|
bun add tailwindcss @tailwindcss/vite
|
|
80
80
|
```
|
|
81
81
|
</TabItem>
|
|
@@ -138,12 +138,12 @@ Edit `tsconfig.app.json` to resolve paths:
|
|
|
138
138
|
|
|
139
139
|
## Initialize Mastra
|
|
140
140
|
|
|
141
|
-
Run [`mastra init`](/reference/v1/cli/
|
|
141
|
+
Run [`mastra init`](/reference/v1/cli/mastra#mastra-init). When prompted, choose a provider (e.g. OpenAI) and enter your key:
|
|
142
142
|
|
|
143
143
|
<Tabs groupId="pm">
|
|
144
144
|
<TabItem value="npm" label="npm">
|
|
145
145
|
|
|
146
|
-
```bash
|
|
146
|
+
```bash
|
|
147
147
|
cd mastra-react
|
|
148
148
|
npx mastra@beta init
|
|
149
149
|
```
|
|
@@ -151,7 +151,7 @@ npx mastra@beta init
|
|
|
151
151
|
</TabItem>
|
|
152
152
|
<TabItem value="pnpm" label="pnpm">
|
|
153
153
|
|
|
154
|
-
```bash
|
|
154
|
+
```bash
|
|
155
155
|
cd mastra-react
|
|
156
156
|
pnpm dlx mastra@beta init
|
|
157
157
|
```
|
|
@@ -159,7 +159,7 @@ pnpm dlx mastra@beta init
|
|
|
159
159
|
</TabItem>
|
|
160
160
|
<TabItem value="yarn" label="yarn">
|
|
161
161
|
|
|
162
|
-
```bash
|
|
162
|
+
```bash
|
|
163
163
|
cd mastra-react
|
|
164
164
|
yarn dlx mastra@beta init
|
|
165
165
|
```
|
|
@@ -167,7 +167,7 @@ yarn dlx mastra@beta init
|
|
|
167
167
|
</TabItem>
|
|
168
168
|
<TabItem value="bun" label="bun">
|
|
169
169
|
|
|
170
|
-
```bash
|
|
170
|
+
```bash
|
|
171
171
|
cd mastra-react
|
|
172
172
|
bunx mastra@beta init
|
|
173
173
|
```
|
|
@@ -190,28 +190,28 @@ Install AI SDK UI along with the Mastra adapter:
|
|
|
190
190
|
<Tabs groupId="pm">
|
|
191
191
|
<TabItem value="npm" label="npm">
|
|
192
192
|
|
|
193
|
-
```bash
|
|
193
|
+
```bash
|
|
194
194
|
npm install @mastra/ai-sdk@beta @ai-sdk/react ai
|
|
195
195
|
```
|
|
196
196
|
|
|
197
197
|
</TabItem>
|
|
198
198
|
<TabItem value="pnpm" label="pnpm">
|
|
199
199
|
|
|
200
|
-
```bash
|
|
200
|
+
```bash
|
|
201
201
|
pnpm add @mastra/ai-sdk@beta @ai-sdk/react ai
|
|
202
202
|
```
|
|
203
203
|
|
|
204
204
|
</TabItem>
|
|
205
205
|
<TabItem value="yarn" label="yarn">
|
|
206
206
|
|
|
207
|
-
```bash
|
|
207
|
+
```bash
|
|
208
208
|
yarn add @mastra/ai-sdk@beta @ai-sdk/react ai
|
|
209
209
|
```
|
|
210
210
|
|
|
211
211
|
</TabItem>
|
|
212
212
|
<TabItem value="bun" label="bun">
|
|
213
213
|
|
|
214
|
-
```bash
|
|
214
|
+
```bash
|
|
215
215
|
bun add @mastra/ai-sdk@beta @ai-sdk/react ai
|
|
216
216
|
```
|
|
217
217
|
|
|
@@ -223,28 +223,28 @@ Next, initialize AI Elements. When prompted, choose the default options:
|
|
|
223
223
|
<Tabs groupId="pm">
|
|
224
224
|
<TabItem value="npm" label="npm">
|
|
225
225
|
|
|
226
|
-
```bash
|
|
226
|
+
```bash
|
|
227
227
|
npx ai-elements@latest
|
|
228
228
|
```
|
|
229
229
|
|
|
230
230
|
</TabItem>
|
|
231
231
|
<TabItem value="pnpm" label="pnpm">
|
|
232
232
|
|
|
233
|
-
```bash
|
|
233
|
+
```bash
|
|
234
234
|
pnpm dlx ai-elements@latest
|
|
235
235
|
```
|
|
236
236
|
|
|
237
237
|
</TabItem>
|
|
238
238
|
<TabItem value="yarn" label="yarn">
|
|
239
239
|
|
|
240
|
-
```bash
|
|
240
|
+
```bash
|
|
241
241
|
yarn dlx ai-elements@latest
|
|
242
242
|
```
|
|
243
243
|
|
|
244
244
|
</TabItem>
|
|
245
245
|
<TabItem value="bun" label="bun">
|
|
246
246
|
|
|
247
|
-
```bash
|
|
247
|
+
```bash
|
|
248
248
|
bunx ai-elements@latest
|
|
249
249
|
```
|
|
250
250
|
|
|
@@ -28,7 +28,7 @@ Set up the Workflow, define steps to extract and classify candidate data, and th
|
|
|
28
28
|
|
|
29
29
|
Create a new file `src/mastra/workflows/candidate-workflow.ts` and define your workflow:
|
|
30
30
|
|
|
31
|
-
```ts
|
|
31
|
+
```ts title="src/mastra/workflows/candidate-workflow.ts"
|
|
32
32
|
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
33
33
|
import { z } from "zod";
|
|
34
34
|
|
|
@@ -56,7 +56,7 @@ You want to extract candidate details from the resume text and classify the pers
|
|
|
56
56
|
|
|
57
57
|
To the existing `src/mastra/workflows/candidate-workflow.ts` file add the following:
|
|
58
58
|
|
|
59
|
-
```ts
|
|
59
|
+
```ts title="src/mastra/workflows/candidate-workflow.ts"
|
|
60
60
|
import { Agent } from "@mastra/core/agent";
|
|
61
61
|
|
|
62
62
|
const recruiter = new Agent({
|
|
@@ -109,7 +109,7 @@ This step prompts a candidate who is identified as "technical" for more informat
|
|
|
109
109
|
|
|
110
110
|
To the existing `src/mastra/workflows/candidate-workflow.ts` file add the following:
|
|
111
111
|
|
|
112
|
-
```ts
|
|
112
|
+
```ts title="src/mastra/workflows/candidate-workflow.ts"
|
|
113
113
|
const askAboutSpecialty = createStep({
|
|
114
114
|
id: "askAboutSpecialty",
|
|
115
115
|
inputSchema: z.object({
|
|
@@ -140,7 +140,7 @@ If the candidate is "non-technical", you want a different follow-up question. Th
|
|
|
140
140
|
|
|
141
141
|
To the existing `src/mastra/workflows/candidate-workflow.ts` file add the following:
|
|
142
142
|
|
|
143
|
-
```ts title="src/mastra/workflows/candidate-workflow.ts"
|
|
143
|
+
```ts title="src/mastra/workflows/candidate-workflow.ts"
|
|
144
144
|
const askAboutRole = createStep({
|
|
145
145
|
id: "askAboutRole",
|
|
146
146
|
inputSchema: z.object({
|
|
@@ -170,7 +170,7 @@ You now combine the steps to implement branching logic based on the candidate's
|
|
|
170
170
|
|
|
171
171
|
To the existing `src/mastra/workflows/candidate-workflow.ts` file change the `candidateWorkflow` like so:
|
|
172
172
|
|
|
173
|
-
```ts title="src/mastra/workflows/candidate-workflow.ts"
|
|
173
|
+
```ts title="src/mastra/workflows/candidate-workflow.ts" {10-14}
|
|
174
174
|
export const candidateWorkflow = createWorkflow({
|
|
175
175
|
id: "candidate-workflow",
|
|
176
176
|
inputSchema: z.object({
|
|
@@ -199,7 +199,7 @@ export const candidateWorkflow = createWorkflow({
|
|
|
199
199
|
|
|
200
200
|
In your `src/mastra/index.ts` file, register the workflow:
|
|
201
201
|
|
|
202
|
-
```ts
|
|
202
|
+
```ts title="src/mastra/index.ts" {2, 5}
|
|
203
203
|
import { Mastra } from "@mastra/core";
|
|
204
204
|
import { candidateWorkflow } from "./workflows/candidate-workflow";
|
|
205
205
|
|
|
@@ -216,13 +216,13 @@ export const mastra = new Mastra({
|
|
|
216
216
|
|
|
217
217
|
You can test your workflow inside [Studio](/docs/v1/getting-started/studio) by starting the development server:
|
|
218
218
|
|
|
219
|
-
```bash
|
|
219
|
+
```bash
|
|
220
220
|
mastra dev
|
|
221
221
|
```
|
|
222
222
|
|
|
223
223
|
In the sidebar, navigate to **Workflows** and select **candidate-workflow**. In the middle you'll see a graph view of your workflow and on the right sidebar the **Run** tab is selected by default. Inside this tab you can enter a resume text, for example:
|
|
224
224
|
|
|
225
|
-
```text
|
|
225
|
+
```text
|
|
226
226
|
Knowledgeable Software Engineer with more than 10 years of experience in software development. Proven expertise in the design and development of software databases and optimization of user interfaces.
|
|
227
227
|
```
|
|
228
228
|
|
|
@@ -230,7 +230,7 @@ After entering the resume text, press the **Run** button. You should now see two
|
|
|
230
230
|
|
|
231
231
|
You can also test the workflow programmatically by calling [`.createRun()`](/reference/v1/workflows/workflow-methods/create-run) and [`.start()`](/reference/v1/workflows/run-methods/start). Create a new file `src/test-workflow.ts` and add the following:
|
|
232
232
|
|
|
233
|
-
```ts
|
|
233
|
+
```ts title="src/test-workflow.ts"
|
|
234
234
|
import { mastra } from "./mastra";
|
|
235
235
|
|
|
236
236
|
const run = await mastra.getWorkflow("candidateWorkflow").createRun();
|
|
@@ -256,7 +256,7 @@ if (res.status === "success") {
|
|
|
256
256
|
|
|
257
257
|
Now, run the workflow and get output in your terminal:
|
|
258
258
|
|
|
259
|
-
```bash
|
|
259
|
+
```bash
|
|
260
260
|
npx tsx src/test-workflow.ts
|
|
261
261
|
```
|
|
262
262
|
|
|
@@ -31,7 +31,7 @@ To create an agent in Mastra use the `Agent` class to define it and then registe
|
|
|
31
31
|
|
|
32
32
|
Create a new file `src/mastra/agents/chefAgent.ts` and define your agent:
|
|
33
33
|
|
|
34
|
-
```ts
|
|
34
|
+
```ts title="src/mastra/agents/chefAgent.ts"
|
|
35
35
|
import { Agent } from "@mastra/core/agent";
|
|
36
36
|
|
|
37
37
|
export const chefAgent = new Agent({
|
|
@@ -50,7 +50,7 @@ export const chefAgent = new Agent({
|
|
|
50
50
|
|
|
51
51
|
In your `src/mastra/index.ts` file, register the agent:
|
|
52
52
|
|
|
53
|
-
```ts
|
|
53
|
+
```ts title="src/mastra/index.ts" {2, 5}
|
|
54
54
|
import { Mastra } from "@mastra/core";
|
|
55
55
|
import { chefAgent } from "./agents/chefAgent";
|
|
56
56
|
|
|
@@ -73,7 +73,7 @@ Depending on your requirements you can interact and get responses from the agent
|
|
|
73
73
|
|
|
74
74
|
Create a new file `src/index.ts` and add a `main()` function to it. Inside, craft a query to ask the agent and log its response.
|
|
75
75
|
|
|
76
|
-
```ts
|
|
76
|
+
```ts title="src/index.ts"
|
|
77
77
|
import { chefAgent } from "./mastra/agents/chefAgent";
|
|
78
78
|
|
|
79
79
|
async function main() {
|
|
@@ -90,7 +90,7 @@ main();
|
|
|
90
90
|
|
|
91
91
|
Afterwards, run the script:
|
|
92
92
|
|
|
93
|
-
```bash
|
|
93
|
+
```bash
|
|
94
94
|
npx bun src/index.ts
|
|
95
95
|
```
|
|
96
96
|
|
|
@@ -108,7 +108,7 @@ Query: In my kitchen I have: pasta, canned tomatoes, garlic, olive oil, and some
|
|
|
108
108
|
|
|
109
109
|
In the previous example you might have waited a bit for the response without any sign of progress. To show the agent's output as it creates it you should instead stream its response to the terminal.
|
|
110
110
|
|
|
111
|
-
```ts
|
|
111
|
+
```ts title="src/index.ts"
|
|
112
112
|
import { chefAgent } from "./mastra/agents/chefAgent";
|
|
113
113
|
|
|
114
114
|
async function main() {
|
|
@@ -132,7 +132,7 @@ main();
|
|
|
132
132
|
|
|
133
133
|
Afterwards, run the script again:
|
|
134
134
|
|
|
135
|
-
```bash
|
|
135
|
+
```bash
|
|
136
136
|
npx bun src/index.ts
|
|
137
137
|
```
|
|
138
138
|
|
|
@@ -155,7 +155,7 @@ Instead of showing the agent's response to a human you might want to pass it alo
|
|
|
155
155
|
|
|
156
156
|
Change your `src/index.ts` to the following:
|
|
157
157
|
|
|
158
|
-
```ts
|
|
158
|
+
```ts title="src/index.ts"
|
|
159
159
|
import { chefAgent } from "./mastra/agents/chefAgent";
|
|
160
160
|
import { z } from "zod";
|
|
161
161
|
|
|
@@ -198,12 +198,10 @@ Query: I want to make lasagna, can you generate a lasagna recipe for me?
|
|
|
198
198
|
ingredients: [
|
|
199
199
|
{ name: "Lasagna noodles", amount: "12 sheets" },
|
|
200
200
|
{ name: "Ground beef", amount: "1 pound" },
|
|
201
|
-
// ...
|
|
202
201
|
],
|
|
203
202
|
steps: [
|
|
204
203
|
"Preheat oven to 375°F (190°C).",
|
|
205
204
|
"Cook the lasagna noodles according to package instructions.",
|
|
206
|
-
// ...
|
|
207
205
|
]
|
|
208
206
|
}
|
|
209
207
|
```
|
|
@@ -222,7 +220,7 @@ Learn how to interact with your agent through Mastra's API.
|
|
|
222
220
|
|
|
223
221
|
You can run your agent as a service using the `mastra dev` command:
|
|
224
222
|
|
|
225
|
-
```bash
|
|
223
|
+
```bash
|
|
226
224
|
mastra dev
|
|
227
225
|
```
|
|
228
226
|
|
|
@@ -244,7 +242,7 @@ POST http://localhost:4111/api/agents/chefAgent/generate
|
|
|
244
242
|
|
|
245
243
|
You can interact with the agent using `curl` from the command line:
|
|
246
244
|
|
|
247
|
-
```bash
|
|
245
|
+
```bash
|
|
248
246
|
curl -X POST http://localhost:4111/api/agents/chefAgent/generate \
|
|
249
247
|
-H "Content-Type: application/json" \
|
|
250
248
|
-d '{
|
|
@@ -30,7 +30,7 @@ Before you can create an MCP server you first need to install additional depende
|
|
|
30
30
|
|
|
31
31
|
Add `@mastra/mcp` to your project:
|
|
32
32
|
|
|
33
|
-
```bash
|
|
33
|
+
```bash
|
|
34
34
|
npm install @mastra/mcp@beta
|
|
35
35
|
```
|
|
36
36
|
|
|
@@ -40,13 +40,13 @@ npm install @mastra/mcp@beta
|
|
|
40
40
|
|
|
41
41
|
After following the default [installation guide](/guides/v1/getting-started/quickstart) your project will include files that are not relevant for this guide. You can safely remove them:
|
|
42
42
|
|
|
43
|
-
```bash
|
|
43
|
+
```bash
|
|
44
44
|
rm -rf src/mastra/agents src/mastra/workflows src/mastra/tools/weather-tool.ts
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
You should also change the `src/mastra/index.ts` file like so:
|
|
48
48
|
|
|
49
|
-
```ts
|
|
49
|
+
```ts title="src/mastra/index.ts"
|
|
50
50
|
import { Mastra } from "@mastra/core";
|
|
51
51
|
import { PinoLogger } from "@mastra/loggers";
|
|
52
52
|
import { LibSQLStore } from "@mastra/libsql";
|
|
@@ -70,13 +70,13 @@ export const mastra = new Mastra({
|
|
|
70
70
|
|
|
71
71
|
Create a dedicated directory for your MCP server's logic and a `notes` directory for your notes:
|
|
72
72
|
|
|
73
|
-
```bash
|
|
73
|
+
```bash
|
|
74
74
|
mkdir notes src/mastra/mcp
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
Create the following files:
|
|
78
78
|
|
|
79
|
-
```bash
|
|
79
|
+
```bash
|
|
80
80
|
touch src/mastra/mcp/{server,resources,prompts}.ts
|
|
81
81
|
```
|
|
82
82
|
|
|
@@ -113,7 +113,7 @@ Let's add the MCP server!
|
|
|
113
113
|
|
|
114
114
|
In `src/mastra/mcp/server.ts`, define the MCP server instance:
|
|
115
115
|
|
|
116
|
-
```typescript
|
|
116
|
+
```typescript title="src/mastra/mcp/server.ts"
|
|
117
117
|
import { MCPServer } from "@mastra/mcp";
|
|
118
118
|
|
|
119
119
|
export const notes = new MCPServer({
|
|
@@ -126,7 +126,7 @@ export const notes = new MCPServer({
|
|
|
126
126
|
|
|
127
127
|
Register this MCP server in your Mastra instance at `src/mastra/index.ts`. The key `notes` is the public identifier for your MCP server:
|
|
128
128
|
|
|
129
|
-
```typescript
|
|
129
|
+
```typescript title="src/mastra/index.ts" {4, 15-17}
|
|
130
130
|
import { Mastra } from "@mastra/core";
|
|
131
131
|
import { PinoLogger } from "@mastra/loggers";
|
|
132
132
|
import { LibSQLStore } from "@mastra/libsql";
|
|
@@ -154,7 +154,7 @@ export const mastra = new Mastra({
|
|
|
154
154
|
|
|
155
155
|
Resource handlers allow clients to discover and read the content your server manages. Implement handlers to work with markdown files in the `notes` directory. Add to the `src/mastra/mcp/resources.ts` file:
|
|
156
156
|
|
|
157
|
-
```typescript
|
|
157
|
+
```typescript title="src/mastra/mcp/resources.ts"
|
|
158
158
|
import fs from "fs/promises";
|
|
159
159
|
import path from "path";
|
|
160
160
|
import { fileURLToPath } from "url";
|
|
@@ -210,7 +210,7 @@ export const resourceHandlers: MCPServerResources = {
|
|
|
210
210
|
|
|
211
211
|
Register these resource handlers in `src/mastra/mcp/server.ts`:
|
|
212
212
|
|
|
213
|
-
```typescript
|
|
213
|
+
```typescript title="src/mastra/mcp/server.ts" {2, 8}
|
|
214
214
|
import { MCPServer } from "@mastra/mcp";
|
|
215
215
|
import { resourceHandlers } from "./resources";
|
|
216
216
|
|
|
@@ -230,7 +230,7 @@ export const notes = new MCPServer({
|
|
|
230
230
|
Tools are the actions your server can perform. Let's create a `write` tool.
|
|
231
231
|
First, define the tool in `src/mastra/tools/write-note.ts`:
|
|
232
232
|
|
|
233
|
-
```typescript
|
|
233
|
+
```typescript title="src/mastra/tools/write-note.ts"
|
|
234
234
|
import { createTool } from "@mastra/core/tools";
|
|
235
235
|
import { z } from "zod";
|
|
236
236
|
import { fileURLToPath } from "url";
|
|
@@ -271,7 +271,7 @@ export const writeNoteTool = createTool({
|
|
|
271
271
|
|
|
272
272
|
Register this tool in `src/mastra/mcp/server.ts`:
|
|
273
273
|
|
|
274
|
-
```typescript
|
|
274
|
+
```typescript title="src/mastra/mcp/server.ts"
|
|
275
275
|
import { MCPServer } from "@mastra/mcp";
|
|
276
276
|
import { resourceHandlers } from "./resources";
|
|
277
277
|
import { writeNoteTool } from "../tools/write-note";
|
|
@@ -299,13 +299,13 @@ Prompt handlers provide ready-to-use prompts for clients. You'll add these three
|
|
|
299
299
|
|
|
300
300
|
This requires a few markdown-parsing libraries you need to install:
|
|
301
301
|
|
|
302
|
-
```bash
|
|
302
|
+
```bash
|
|
303
303
|
npm install unified remark-parse gray-matter @types/unist
|
|
304
304
|
```
|
|
305
305
|
|
|
306
306
|
Implement the prompts in `src/mastra/mcp/prompts.ts`:
|
|
307
307
|
|
|
308
|
-
```typescript
|
|
308
|
+
```typescript title="src/mastra/mcp/prompts.ts"
|
|
309
309
|
import type { MCPServerPrompts } from "@mastra/mcp";
|
|
310
310
|
import { unified } from "unified";
|
|
311
311
|
import remarkParse from "remark-parse";
|
|
@@ -413,7 +413,7 @@ export const promptHandlers: MCPServerPrompts = {
|
|
|
413
413
|
|
|
414
414
|
Register these prompt handlers in `src/mastra/mcp/server.ts`:
|
|
415
415
|
|
|
416
|
-
```typescript
|
|
416
|
+
```typescript title="src/mastra/mcp/server.ts"
|
|
417
417
|
import { MCPServer } from "@mastra/mcp";
|
|
418
418
|
import { resourceHandlers } from "./resources";
|
|
419
419
|
import { writeNoteTool } from "../tools/write-note";
|
|
@@ -439,7 +439,7 @@ export const notes = new MCPServer({
|
|
|
439
439
|
|
|
440
440
|
Great, you've authored your first MCP server! Now you can try it out by starting the Mastra dev server and opening [Studio](/docs/v1/getting-started/studio):
|
|
441
441
|
|
|
442
|
-
```bash
|
|
442
|
+
```bash
|
|
443
443
|
npm run dev
|
|
444
444
|
```
|
|
445
445
|
|
|
@@ -10,7 +10,7 @@ import StepItem from "@site/src/components/StepItem";
|
|
|
10
10
|
|
|
11
11
|
In this guide, you'll create an AI research assistant that can analyze academic papers and answer specific questions about their content using Retrieval Augmented Generation (RAG).
|
|
12
12
|
|
|
13
|
-
You'll use the foundational Transformer paper ["Attention Is All You Need"](https://arxiv.org/html/1706.03762) as your example. As a database you'll use a local
|
|
13
|
+
You'll use the foundational Transformer paper ["Attention Is All You Need"](https://arxiv.org/html/1706.03762) as your example. As a database you'll use a local libSQL database.
|
|
14
14
|
|
|
15
15
|
## Prerequisites
|
|
16
16
|
|
|
@@ -59,7 +59,7 @@ Install additional dependencies
|
|
|
59
59
|
|
|
60
60
|
After running the [installation guide](/guides/v1/getting-started/quickstart) you'll need to install additional dependencies:
|
|
61
61
|
|
|
62
|
-
```bash
|
|
62
|
+
```bash
|
|
63
63
|
npm install @mastra/rag@beta ai@^4.0.0
|
|
64
64
|
```
|
|
65
65
|
</StepItem>
|
|
@@ -74,7 +74,7 @@ Now you'll create your RAG-enabled research assistant. The agent uses:
|
|
|
74
74
|
|
|
75
75
|
Create a new file `src/mastra/agents/researchAgent.ts` and define your agent:
|
|
76
76
|
|
|
77
|
-
```ts
|
|
77
|
+
```ts title="src/mastra/agents/researchAgent.ts"
|
|
78
78
|
import { Agent } from "@mastra/core/agent";
|
|
79
79
|
import { ModelRouterEmbeddingModel } from "@mastra/core/llm";
|
|
80
80
|
import { createVectorQueryTool } from "@mastra/rag";
|
|
@@ -114,7 +114,7 @@ In the root of your project, grab the absolute path with the `pwd` command. The
|
|
|
114
114
|
|
|
115
115
|
In your `src/mastra/index.ts` file, add the following to your existing file and configuration:
|
|
116
116
|
|
|
117
|
-
```ts
|
|
117
|
+
```ts title="src/mastra/index.ts" {2, 4-6, 9}
|
|
118
118
|
import { Mastra } from "@mastra/core";
|
|
119
119
|
import { LibSQLVector } from "@mastra/libsql";
|
|
120
120
|
|
|
@@ -133,7 +133,7 @@ For the `connectionUrl` use the absolute path you got from the `pwd` command. Th
|
|
|
133
133
|
:::note
|
|
134
134
|
|
|
135
135
|
For the purpose of this guide you are using a hardcoded absolute path to your
|
|
136
|
-
local
|
|
136
|
+
local libSQL file, however for production usage this won't work. You should
|
|
137
137
|
use a remote persistent database then.
|
|
138
138
|
|
|
139
139
|
:::
|
|
@@ -144,7 +144,7 @@ use a remote persistent database then.
|
|
|
144
144
|
|
|
145
145
|
In the `src/mastra/index.ts` file, add the agent to Mastra:
|
|
146
146
|
|
|
147
|
-
```ts
|
|
147
|
+
```ts title="src/mastra/index.ts" {3, 10}
|
|
148
148
|
import { Mastra } from "@mastra/core";
|
|
149
149
|
import { LibSQLVector } from "@mastra/libsql";
|
|
150
150
|
import { researchAgent } from "./agents/researchAgent";
|
|
@@ -176,7 +176,7 @@ In this step the research paper is retrieved by providing an URL, then converted
|
|
|
176
176
|
|
|
177
177
|
Create a new file `src/store.ts` and add the following:
|
|
178
178
|
|
|
179
|
-
```ts
|
|
179
|
+
```ts title="src/store.ts"
|
|
180
180
|
import { MDocument } from "@mastra/rag";
|
|
181
181
|
|
|
182
182
|
// Load the paper
|
|
@@ -198,7 +198,7 @@ console.log("Number of chunks:", chunks.length);
|
|
|
198
198
|
|
|
199
199
|
Run the file in your terminal:
|
|
200
200
|
|
|
201
|
-
```bash
|
|
201
|
+
```bash
|
|
202
202
|
npx bun src/store.ts
|
|
203
203
|
```
|
|
204
204
|
|
|
@@ -229,7 +229,7 @@ This allows the agent to efficiently search and retrieve relevant information.
|
|
|
229
229
|
|
|
230
230
|
Open the `src/store.ts` file and add the following:
|
|
231
231
|
|
|
232
|
-
```ts
|
|
232
|
+
```ts title="src/store.ts"
|
|
233
233
|
import { MDocument } from "@mastra/rag";
|
|
234
234
|
import { embedMany } from "ai";
|
|
235
235
|
import { mastra } from "./mastra";
|
|
@@ -276,7 +276,7 @@ await vectorStore.upsert({
|
|
|
276
276
|
|
|
277
277
|
Lastly, you'll now need to store the embeddings by running the script again:
|
|
278
278
|
|
|
279
|
-
```bash
|
|
279
|
+
```bash
|
|
280
280
|
npx bun src/store.ts
|
|
281
281
|
```
|
|
282
282
|
|
|
@@ -292,7 +292,7 @@ Now that the vector database has all embeddings, you can test the research assis
|
|
|
292
292
|
|
|
293
293
|
Create a new file `src/ask-agent.ts` and add different types of queries:
|
|
294
294
|
|
|
295
|
-
```ts title="src/ask-agent.ts"
|
|
295
|
+
```ts title="src/ask-agent.ts"
|
|
296
296
|
import { mastra } from "./mastra";
|
|
297
297
|
const agent = mastra.getAgent("researchAgent");
|
|
298
298
|
|
|
@@ -306,7 +306,7 @@ console.log("Response:", response1.text);
|
|
|
306
306
|
|
|
307
307
|
Run the script:
|
|
308
308
|
|
|
309
|
-
```bash
|
|
309
|
+
```bash
|
|
310
310
|
npx bun src/ask-agent.ts
|
|
311
311
|
```
|
|
312
312
|
|
|
@@ -323,7 +323,7 @@ Response: Sequence modeling with neural networks faces several key challenges:
|
|
|
323
323
|
|
|
324
324
|
Try another question:
|
|
325
325
|
|
|
326
|
-
```ts title="src/ask-agent.ts"
|
|
326
|
+
```ts title="src/ask-agent.ts"
|
|
327
327
|
import { mastra } from "./mastra";
|
|
328
328
|
const agent = mastra.getAgent("researchAgent");
|
|
329
329
|
|
|
@@ -29,7 +29,7 @@ To create an agent in Mastra use the `Agent` class to define it and then registe
|
|
|
29
29
|
|
|
30
30
|
Create a new file `src/mastra/agents/stockAgent.ts` and define your agent:
|
|
31
31
|
|
|
32
|
-
```ts
|
|
32
|
+
```ts title="src/mastra/agents/stockAgent.ts"
|
|
33
33
|
import { Agent } from "@mastra/core/agent";
|
|
34
34
|
|
|
35
35
|
export const stockAgent = new Agent({
|
|
@@ -47,7 +47,7 @@ export const stockAgent = new Agent({
|
|
|
47
47
|
|
|
48
48
|
In your `src/mastra/index.ts` file, register the agent:
|
|
49
49
|
|
|
50
|
-
```ts
|
|
50
|
+
```ts title="src/mastra/index.ts" {2, 5}
|
|
51
51
|
import { Mastra } from "@mastra/core";
|
|
52
52
|
import { stockAgent } from "./agents/stockAgent";
|
|
53
53
|
|
|
@@ -103,7 +103,7 @@ export const stockPrices = createTool({
|
|
|
103
103
|
|
|
104
104
|
Inside `src/mastra/agents/stockAgent.ts` import your newly created `stockPrices` tool and add it to the agent.
|
|
105
105
|
|
|
106
|
-
```ts
|
|
106
|
+
```ts title="src/mastra/agents/stockAgent.ts" {9-11}
|
|
107
107
|
import { Agent } from "@mastra/core/agent";
|
|
108
108
|
import { stockPrices } from "../tools/stockPrices";
|
|
109
109
|
|
|
@@ -133,7 +133,7 @@ Learn how to interact with your agent through Mastra's API.
|
|
|
133
133
|
|
|
134
134
|
You can run your agent as a service using the `mastra dev` command:
|
|
135
135
|
|
|
136
|
-
```bash
|
|
136
|
+
```bash
|
|
137
137
|
mastra dev
|
|
138
138
|
```
|
|
139
139
|
|
|
@@ -155,7 +155,7 @@ POST http://localhost:4111/api/agents/stockAgent/generate
|
|
|
155
155
|
|
|
156
156
|
You can interact with the agent using `curl` from the command line:
|
|
157
157
|
|
|
158
|
-
```bash
|
|
158
|
+
```bash
|
|
159
159
|
curl -X POST http://localhost:4111/api/agents/stockAgent/generate \
|
|
160
160
|
-H "Content-Type: application/json" \
|
|
161
161
|
-d '{
|