@mastra/mcp-docs-server 0.13.39 → 1.0.0-beta.1
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%2Fai-sdk-v4.md +1 -0
- package/.docs/organized/changelogs/%40internal%2Fchangeset-cli.md +0 -10
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +0 -10
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +36 -36
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +0 -10
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +70 -70
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +40 -40
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fauth.md +4 -14
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +220 -220
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +190 -190
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +7 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +210 -210
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +69 -69
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +67 -67
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +70 -70
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +67 -67
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +209 -209
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +191 -191
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +5 -13
- package/.docs/organized/changelogs/%40mastra%2Flance.md +182 -182
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +65 -65
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +228 -228
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +206 -206
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +197 -197
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +216 -216
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Frag.md +61 -61
- package/.docs/organized/changelogs/%40mastra%2Freact.md +66 -66
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -17
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -30
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +203 -203
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +190 -190
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +20 -20
- package/.docs/organized/changelogs/create-mastra.md +29 -29
- package/.docs/organized/changelogs/mastra.md +93 -93
- package/.docs/organized/code-examples/a2a.md +4 -2
- package/.docs/organized/code-examples/agui.md +12 -9
- package/.docs/organized/code-examples/ai-sdk-useChat.md +12 -18
- package/.docs/organized/code-examples/ai-sdk-v5.md +4 -2
- package/.docs/organized/code-examples/bird-checker-with-express.md +5 -4
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +4 -3
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +4 -3
- package/.docs/organized/code-examples/client-side-tools.md +1 -0
- package/.docs/organized/code-examples/crypto-chatbot.md +1 -1
- package/.docs/organized/code-examples/experimental-auth-weather-agent.md +8 -177
- package/.docs/organized/code-examples/fireworks-r1.md +2 -2
- package/.docs/organized/code-examples/heads-up-game.md +10 -7
- package/.docs/organized/code-examples/mcp-configuration.md +5 -3
- package/.docs/organized/code-examples/mcp-registry-registry.md +3 -2
- package/.docs/organized/code-examples/memory-per-resource-example.md +4 -2
- package/.docs/organized/code-examples/memory-todo-agent.md +1 -0
- package/.docs/organized/code-examples/memory-with-context.md +2 -1
- package/.docs/organized/code-examples/memory-with-libsql.md +4 -2
- package/.docs/organized/code-examples/memory-with-mongodb.md +4 -2
- package/.docs/organized/code-examples/memory-with-pg.md +4 -2
- package/.docs/organized/code-examples/memory-with-processors.md +13 -8
- package/.docs/organized/code-examples/memory-with-upstash.md +5 -3
- package/.docs/organized/code-examples/openapi-spec-writer.md +32 -41
- package/.docs/organized/code-examples/quick-start.md +5 -32
- package/.docs/organized/code-examples/stock-price-tool.md +6 -5
- package/.docs/organized/code-examples/weather-agent.md +21 -16
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +3 -2
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +9 -12
- package/.docs/organized/code-examples/workflow-with-memory.md +16 -15
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +2 -2
- package/.docs/organized/code-examples/workflow-with-suspend-resume.md +3 -2
- package/.docs/raw/agents/adding-voice.mdx +27 -22
- package/.docs/raw/agents/agent-memory.mdx +24 -16
- package/.docs/raw/agents/guardrails.mdx +33 -12
- package/.docs/raw/agents/networks.mdx +8 -4
- package/.docs/raw/agents/overview.mdx +23 -17
- package/.docs/raw/agents/using-tools.mdx +11 -8
- package/.docs/raw/auth/auth0.mdx +9 -9
- package/.docs/raw/auth/clerk.mdx +7 -7
- package/.docs/raw/auth/firebase.mdx +9 -9
- package/.docs/raw/auth/index.mdx +6 -6
- package/.docs/raw/auth/jwt.mdx +7 -7
- package/.docs/raw/auth/supabase.mdx +8 -8
- package/.docs/raw/auth/workos.mdx +9 -9
- package/.docs/raw/community/contributing-templates.mdx +3 -3
- package/.docs/raw/community/discord.mdx +1 -1
- package/.docs/raw/course/01-first-agent/03-verifying-installation.md +1 -1
- package/.docs/raw/course/01-first-agent/08-exporting-your-agent.md +2 -1
- package/.docs/raw/course/01-first-agent/16-adding-memory-to-agent.md +2 -1
- package/.docs/raw/course/02-agent-tools-mcp/02-installing-mcp.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/31-enhancing-memory-configuration.md +2 -0
- package/.docs/raw/course/03-agent-memory/03-installing-memory.md +1 -1
- package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -0
- package/.docs/raw/course/03-agent-memory/10-storage-configuration.md +2 -3
- package/.docs/raw/course/03-agent-memory/13-vector-store-configuration.md +2 -0
- package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +2 -0
- package/.docs/raw/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +1 -0
- package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +2 -0
- package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +1 -0
- package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +1 -0
- package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +1 -0
- package/.docs/raw/course/04-workflows/08-running-workflows-programmatically.md +2 -2
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +6 -6
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +8 -6
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +5 -5
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +5 -5
- package/.docs/raw/deployment/cloud-providers/index.mdx +11 -8
- package/.docs/raw/deployment/monorepo.mdx +2 -2
- package/.docs/raw/deployment/overview.mdx +2 -2
- package/.docs/raw/deployment/server-deployment.mdx +2 -10
- package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +5 -5
- package/.docs/raw/deployment/serverless-platforms/index.mdx +10 -7
- package/.docs/raw/deployment/serverless-platforms/netlify-deployer.mdx +5 -5
- package/.docs/raw/deployment/serverless-platforms/vercel-deployer.mdx +5 -5
- package/.docs/raw/deployment/web-framework.mdx +8 -8
- package/.docs/raw/{scorers → evals}/custom-scorers.mdx +6 -6
- package/.docs/raw/evals/off-the-shelf-scorers.mdx +50 -0
- package/.docs/raw/{scorers → evals}/overview.mdx +9 -9
- package/.docs/raw/evals/running-in-ci.mdx +113 -0
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +26 -25
- package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +1 -1
- package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +17 -17
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +4 -1
- package/.docs/raw/frameworks/servers/express.mdx +11 -10
- package/.docs/raw/frameworks/web-frameworks/astro.mdx +18 -18
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +7 -7
- package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +16 -16
- package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +7 -7
- package/.docs/raw/getting-started/installation.mdx +26 -25
- package/.docs/raw/getting-started/mcp-docs-server.mdx +1 -1
- package/.docs/raw/getting-started/project-structure.mdx +4 -4
- package/.docs/raw/getting-started/studio.mdx +8 -8
- package/.docs/raw/getting-started/templates.mdx +6 -6
- package/.docs/raw/guides/guide/ai-recruiter.mdx +264 -0
- package/.docs/raw/guides/guide/chef-michel.mdx +271 -0
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +450 -0
- package/.docs/raw/guides/guide/research-assistant.mdx +380 -0
- package/.docs/raw/guides/guide/stock-agent.mdx +185 -0
- package/.docs/raw/guides/guide/web-search.mdx +291 -0
- package/.docs/raw/guides/index.mdx +43 -0
- package/.docs/raw/guides/migrations/agentnetwork.mdx +114 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/_template.mdx +50 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +265 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/cli.mdx +48 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +153 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/evals.mdx +230 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/mastra.mdx +171 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/mcp.mdx +114 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +241 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +83 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/processors.mdx +62 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +270 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +115 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tracing.mdx +280 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/vectors.mdx +23 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/voice.mdx +39 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +178 -0
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +367 -0
- package/.docs/raw/guides/quickstarts/nextjs.mdx +275 -0
- package/.docs/raw/index.mdx +9 -9
- package/.docs/raw/{observability/logging.mdx → logging.mdx} +4 -4
- package/.docs/raw/mastra-cloud/dashboard.mdx +2 -2
- package/.docs/raw/mastra-cloud/observability.mdx +6 -6
- package/.docs/raw/mastra-cloud/overview.mdx +2 -2
- package/.docs/raw/mastra-cloud/setting-up.mdx +4 -4
- package/.docs/raw/memory/conversation-history.mdx +1 -0
- package/.docs/raw/memory/memory-processors.mdx +4 -3
- package/.docs/raw/memory/overview.mdx +10 -6
- package/.docs/raw/memory/semantic-recall.mdx +13 -8
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +12 -7
- package/.docs/raw/memory/storage/memory-with-pg.mdx +11 -6
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +11 -6
- package/.docs/raw/memory/threads-and-resources.mdx +11 -13
- package/.docs/raw/memory/working-memory.mdx +30 -14
- package/.docs/raw/observability/overview.mdx +13 -30
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/arize.mdx +11 -19
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/braintrust.mdx +8 -17
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/cloud.mdx +11 -17
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/default.mdx +16 -20
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/langfuse.mdx +8 -17
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/langsmith.mdx +8 -17
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/otel.mdx +12 -21
- package/.docs/raw/observability/{ai-tracing → tracing}/overview.mdx +107 -142
- package/.docs/raw/observability/{ai-tracing → tracing}/processors/sensitive-data-filter.mdx +14 -13
- package/.docs/raw/rag/chunking-and-embedding.mdx +5 -5
- package/.docs/raw/rag/overview.mdx +3 -13
- package/.docs/raw/rag/retrieval.mdx +24 -12
- package/.docs/raw/rag/vector-databases.mdx +7 -1
- package/.docs/raw/reference/agents/agent.mdx +35 -30
- package/.docs/raw/reference/agents/generate.mdx +10 -10
- package/.docs/raw/reference/agents/generateLegacy.mdx +8 -8
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +21 -15
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +69 -0
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +22 -16
- package/.docs/raw/reference/agents/getDescription.mdx +1 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +8 -8
- package/.docs/raw/reference/agents/getLLM.mdx +9 -9
- package/.docs/raw/reference/agents/getMemory.mdx +9 -9
- package/.docs/raw/reference/agents/getModel.mdx +10 -10
- package/.docs/raw/reference/agents/getVoice.mdx +8 -8
- package/.docs/raw/reference/agents/listAgents.mdx +9 -9
- package/.docs/raw/reference/agents/listScorers.mdx +7 -7
- package/.docs/raw/reference/agents/listTools.mdx +7 -7
- package/.docs/raw/reference/agents/listWorkflows.mdx +7 -7
- package/.docs/raw/reference/agents/network.mdx +11 -10
- package/.docs/raw/reference/auth/auth0.mdx +4 -4
- package/.docs/raw/reference/auth/clerk.mdx +4 -4
- package/.docs/raw/reference/auth/firebase.mdx +6 -6
- package/.docs/raw/reference/auth/jwt.mdx +4 -4
- package/.docs/raw/reference/auth/supabase.mdx +4 -4
- package/.docs/raw/reference/auth/workos.mdx +4 -4
- package/.docs/raw/reference/cli/create-mastra.mdx +10 -10
- package/.docs/raw/reference/cli/mastra.mdx +7 -7
- package/.docs/raw/reference/client-js/agents.mdx +6 -2
- package/.docs/raw/reference/client-js/mastra-client.mdx +7 -7
- package/.docs/raw/reference/client-js/memory.mdx +24 -16
- package/.docs/raw/reference/client-js/observability.mdx +11 -11
- package/.docs/raw/reference/client-js/workflows.mdx +6 -34
- 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 +2 -2
- package/.docs/raw/reference/core/getLogger.mdx +2 -2
- package/.docs/raw/reference/core/getMCPServer.mdx +31 -15
- package/.docs/raw/reference/core/getMCPServerById.mdx +81 -0
- package/.docs/raw/reference/core/getScorer.mdx +3 -3
- package/.docs/raw/reference/core/getScorerById.mdx +79 -0
- package/.docs/raw/reference/core/getServer.mdx +2 -2
- package/.docs/raw/reference/core/getStorage.mdx +2 -2
- package/.docs/raw/reference/core/getTelemetry.mdx +2 -2
- package/.docs/raw/reference/core/getVector.mdx +2 -2
- 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 +2 -2
- package/.docs/raw/reference/core/listLogsByRunId.mdx +2 -2
- package/.docs/raw/reference/core/listMCPServers.mdx +65 -0
- package/.docs/raw/reference/core/listScorers.mdx +3 -3
- package/.docs/raw/reference/core/listVectors.mdx +36 -0
- package/.docs/raw/reference/core/listWorkflows.mdx +6 -6
- package/.docs/raw/reference/core/mastra-class.mdx +3 -2
- package/.docs/raw/reference/core/setLogger.mdx +2 -2
- package/.docs/raw/reference/core/setStorage.mdx +3 -2
- package/.docs/raw/reference/core/setTelemetry.mdx +2 -2
- package/.docs/raw/reference/deployer/cloudflare.mdx +2 -2
- package/.docs/raw/reference/deployer/deployer.mdx +0 -6
- package/.docs/raw/reference/deployer/netlify.mdx +2 -2
- package/.docs/raw/reference/deployer/vercel.mdx +3 -3
- package/.docs/raw/reference/evals/answer-relevancy.mdx +164 -126
- package/.docs/raw/reference/{scorers → evals}/answer-similarity.mdx +27 -27
- package/.docs/raw/reference/evals/bias.mdx +149 -115
- package/.docs/raw/reference/evals/completeness.mdx +148 -117
- package/.docs/raw/reference/evals/content-similarity.mdx +126 -113
- package/.docs/raw/reference/evals/context-precision.mdx +290 -133
- package/.docs/raw/reference/{scorers → evals}/context-relevance.mdx +6 -6
- package/.docs/raw/reference/{scorers → evals}/create-scorer.mdx +69 -60
- package/.docs/raw/reference/evals/faithfulness.mdx +163 -121
- package/.docs/raw/reference/evals/hallucination.mdx +159 -132
- package/.docs/raw/reference/evals/keyword-coverage.mdx +169 -125
- package/.docs/raw/reference/{scorers → evals}/mastra-scorer.mdx +7 -5
- package/.docs/raw/reference/{scorers → evals}/noise-sensitivity.mdx +9 -9
- package/.docs/raw/reference/evals/prompt-alignment.mdx +604 -182
- package/.docs/raw/reference/{scorers/run-experiment.mdx → evals/run-evals.mdx} +17 -18
- package/.docs/raw/reference/evals/textual-difference.mdx +149 -117
- package/.docs/raw/reference/evals/tone-consistency.mdx +149 -125
- package/.docs/raw/reference/{scorers → evals}/tool-call-accuracy.mdx +8 -6
- package/.docs/raw/reference/evals/toxicity.mdx +152 -96
- package/.docs/raw/reference/{observability/logging → logging}/pino-logger.mdx +2 -2
- package/.docs/raw/reference/memory/createThread.mdx +5 -5
- package/.docs/raw/reference/memory/deleteMessages.mdx +7 -7
- package/.docs/raw/reference/memory/getThreadById.mdx +4 -4
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +110 -0
- package/.docs/raw/reference/memory/memory-class.mdx +13 -9
- package/.docs/raw/reference/memory/query.mdx +58 -57
- package/.docs/raw/reference/memory/recall.mdx +185 -0
- package/.docs/raw/reference/observability/tracing/configuration.mdx +245 -0
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/arize.mdx +13 -13
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/braintrust.mdx +11 -8
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/cloud-exporter.mdx +21 -19
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/console-exporter.mdx +49 -17
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/default-exporter.mdx +42 -41
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/langfuse.mdx +10 -7
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/langsmith.mdx +10 -7
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/otel.mdx +5 -5
- package/.docs/raw/reference/observability/tracing/instances.mdx +168 -0
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/interfaces.mdx +115 -89
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/processors/sensitive-data-filter.mdx +3 -3
- package/.docs/raw/reference/observability/{ai-tracing/span.mdx → tracing/spans.mdx} +59 -41
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +9 -3
- package/.docs/raw/reference/processors/language-detector.mdx +9 -3
- package/.docs/raw/reference/processors/moderation-processor.mdx +9 -3
- package/.docs/raw/reference/processors/pii-detector.mdx +9 -3
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +9 -3
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +9 -3
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +9 -3
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +9 -3
- package/.docs/raw/reference/rag/chunk.mdx +1 -8
- package/.docs/raw/reference/rag/database-config.mdx +7 -7
- package/.docs/raw/reference/rag/metadata-filters.mdx +14 -11
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +1 -1
- package/.docs/raw/reference/storage/cloudflare.mdx +1 -1
- package/.docs/raw/reference/storage/dynamodb.mdx +3 -3
- package/.docs/raw/reference/storage/lance.mdx +1 -1
- package/.docs/raw/reference/storage/libsql.mdx +3 -1
- package/.docs/raw/reference/storage/mongodb.mdx +1 -1
- package/.docs/raw/reference/storage/mssql.mdx +6 -1
- package/.docs/raw/reference/storage/postgresql.mdx +7 -1
- package/.docs/raw/reference/storage/upstash.mdx +2 -1
- package/.docs/raw/reference/streaming/agents/stream.mdx +12 -12
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +8 -8
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +3 -3
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +3 -3
- package/.docs/raw/reference/streaming/workflows/resumeStreamVNext.mdx +6 -6
- package/.docs/raw/reference/streaming/workflows/stream.mdx +10 -10
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +11 -11
- package/.docs/raw/reference/templates/overview.mdx +3 -3
- package/.docs/raw/reference/tools/create-tool.mdx +52 -35
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +15 -15
- package/.docs/raw/reference/tools/mcp-client.mdx +1 -1
- package/.docs/raw/reference/tools/mcp-server.mdx +119 -35
- package/.docs/raw/reference/tools/vector-query-tool.mdx +27 -26
- package/.docs/raw/reference/vectors/couchbase.mdx +8 -2
- package/.docs/raw/reference/vectors/libsql.mdx +2 -1
- package/.docs/raw/reference/vectors/mongodb.mdx +7 -1
- package/.docs/raw/reference/vectors/pg.mdx +3 -0
- package/.docs/raw/reference/vectors/s3vectors.mdx +1 -1
- package/.docs/raw/reference/vectors/upstash.mdx +1 -0
- package/.docs/raw/reference/voice/google-gemini-live.mdx +1 -1
- package/.docs/raw/reference/voice/voice.addTools.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +4 -4
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +14 -14
- package/.docs/raw/reference/workflows/run-methods/start.mdx +17 -17
- package/.docs/raw/reference/workflows/run.mdx +1 -8
- package/.docs/raw/reference/workflows/step.mdx +5 -5
- package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +7 -13
- 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 +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +5 -0
- 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 +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow.mdx +1 -1
- package/.docs/raw/server-db/custom-api-routes.mdx +2 -2
- package/.docs/raw/server-db/mastra-client.mdx +23 -22
- package/.docs/raw/server-db/middleware.mdx +7 -7
- package/.docs/raw/server-db/production-server.mdx +4 -4
- package/.docs/raw/server-db/{runtime-context.mdx → request-context.mdx} +46 -45
- package/.docs/raw/server-db/storage.mdx +29 -21
- package/.docs/raw/streaming/events.mdx +3 -3
- package/.docs/raw/streaming/overview.mdx +5 -5
- package/.docs/raw/streaming/tool-streaming.mdx +18 -17
- package/.docs/raw/streaming/workflow-streaming.mdx +1 -1
- package/.docs/raw/tools-mcp/advanced-usage.mdx +5 -4
- package/.docs/raw/tools-mcp/mcp-overview.mdx +33 -20
- package/.docs/raw/tools-mcp/overview.mdx +11 -11
- package/.docs/raw/voice/overview.mdx +63 -43
- package/.docs/raw/voice/speech-to-speech.mdx +5 -3
- package/.docs/raw/voice/speech-to-text.mdx +10 -9
- package/.docs/raw/voice/text-to-speech.mdx +13 -12
- package/.docs/raw/workflows/agents-and-tools.mdx +9 -5
- package/.docs/raw/workflows/control-flow.mdx +3 -3
- package/.docs/raw/workflows/error-handling.mdx +2 -21
- package/.docs/raw/workflows/human-in-the-loop.mdx +7 -4
- package/.docs/raw/workflows/inngest-workflow.mdx +3 -3
- package/.docs/raw/workflows/input-data-mapping.mdx +107 -0
- package/.docs/raw/workflows/overview.mdx +17 -16
- package/.docs/raw/workflows/snapshots.mdx +13 -11
- package/.docs/raw/workflows/suspend-and-resume.mdx +23 -15
- package/CHANGELOG.md +55 -53
- package/README.md +11 -2
- package/dist/{chunk-TUAHUTTB.js → chunk-5NJC7NRO.js} +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
- package/dist/prepare-docs/prepare.js +1 -1
- package/dist/prompts/migration.d.ts +6 -0
- package/dist/prompts/migration.d.ts.map +1 -0
- package/dist/stdio.js +402 -30
- package/dist/tools/migration.d.ts +40 -0
- package/dist/tools/migration.d.ts.map +1 -0
- package/package.json +8 -12
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +0 -302
- package/.docs/raw/observability/nextjs-tracing.mdx +0 -109
- package/.docs/raw/observability/otel-tracing.mdx +0 -189
- package/.docs/raw/reference/agents/getScorers.mdx +0 -69
- package/.docs/raw/reference/agents/getTools.mdx +0 -69
- package/.docs/raw/reference/agents/getWorkflows.mdx +0 -69
- package/.docs/raw/reference/client-js/workflows-legacy.mdx +0 -143
- package/.docs/raw/reference/core/getAgents.mdx +0 -35
- package/.docs/raw/reference/core/getLogs.mdx +0 -96
- package/.docs/raw/reference/core/getLogsByRunId.mdx +0 -87
- package/.docs/raw/reference/core/getMCPServers.mdx +0 -36
- package/.docs/raw/reference/core/getMemory.mdx +0 -36
- package/.docs/raw/reference/core/getScorerByName.mdx +0 -78
- package/.docs/raw/reference/core/getScorers.mdx +0 -43
- package/.docs/raw/reference/core/getVectors.mdx +0 -36
- package/.docs/raw/reference/core/getWorkflows.mdx +0 -45
- package/.docs/raw/reference/evals/context-position.mdx +0 -197
- package/.docs/raw/reference/evals/context-relevancy.mdx +0 -196
- package/.docs/raw/reference/evals/contextual-recall.mdx +0 -196
- package/.docs/raw/reference/evals/summarization.mdx +0 -212
- package/.docs/raw/reference/legacyWorkflows/after.mdx +0 -89
- package/.docs/raw/reference/legacyWorkflows/afterEvent.mdx +0 -79
- package/.docs/raw/reference/legacyWorkflows/commit.mdx +0 -33
- package/.docs/raw/reference/legacyWorkflows/createRun.mdx +0 -76
- package/.docs/raw/reference/legacyWorkflows/else.mdx +0 -68
- package/.docs/raw/reference/legacyWorkflows/events.mdx +0 -305
- package/.docs/raw/reference/legacyWorkflows/execute.mdx +0 -110
- package/.docs/raw/reference/legacyWorkflows/if.mdx +0 -108
- package/.docs/raw/reference/legacyWorkflows/resume.mdx +0 -158
- package/.docs/raw/reference/legacyWorkflows/resumeWithEvent.mdx +0 -133
- package/.docs/raw/reference/legacyWorkflows/snapshots.mdx +0 -207
- package/.docs/raw/reference/legacyWorkflows/start.mdx +0 -87
- package/.docs/raw/reference/legacyWorkflows/step-class.mdx +0 -100
- package/.docs/raw/reference/legacyWorkflows/step-condition.mdx +0 -137
- package/.docs/raw/reference/legacyWorkflows/step-function.mdx +0 -93
- package/.docs/raw/reference/legacyWorkflows/step-options.mdx +0 -69
- package/.docs/raw/reference/legacyWorkflows/step-retries.mdx +0 -196
- package/.docs/raw/reference/legacyWorkflows/suspend.mdx +0 -70
- package/.docs/raw/reference/legacyWorkflows/then.mdx +0 -72
- package/.docs/raw/reference/legacyWorkflows/until.mdx +0 -168
- package/.docs/raw/reference/legacyWorkflows/watch.mdx +0 -124
- package/.docs/raw/reference/legacyWorkflows/while.mdx +0 -168
- package/.docs/raw/reference/legacyWorkflows/workflow.mdx +0 -234
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +0 -79
- package/.docs/raw/reference/memory/getThreadsByResourceIdPaginated.mdx +0 -110
- package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +0 -185
- package/.docs/raw/reference/observability/ai-tracing/configuration.mdx +0 -238
- package/.docs/raw/reference/observability/otel-tracing/otel-config.mdx +0 -117
- package/.docs/raw/reference/observability/otel-tracing/providers/arize-ax.mdx +0 -81
- package/.docs/raw/reference/observability/otel-tracing/providers/arize-phoenix.mdx +0 -121
- package/.docs/raw/reference/observability/otel-tracing/providers/braintrust.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/dash0.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/index.mdx +0 -20
- package/.docs/raw/reference/observability/otel-tracing/providers/keywordsai.mdx +0 -73
- package/.docs/raw/reference/observability/otel-tracing/providers/laminar.mdx +0 -41
- package/.docs/raw/reference/observability/otel-tracing/providers/langfuse.mdx +0 -84
- package/.docs/raw/reference/observability/otel-tracing/providers/langsmith.mdx +0 -48
- package/.docs/raw/reference/observability/otel-tracing/providers/langwatch.mdx +0 -43
- package/.docs/raw/reference/observability/otel-tracing/providers/new-relic.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/signoz.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/traceloop.mdx +0 -40
- package/.docs/raw/reference/scorers/answer-relevancy.mdx +0 -227
- package/.docs/raw/reference/scorers/bias.mdx +0 -228
- package/.docs/raw/reference/scorers/completeness.mdx +0 -214
- package/.docs/raw/reference/scorers/content-similarity.mdx +0 -197
- package/.docs/raw/reference/scorers/context-precision.mdx +0 -352
- package/.docs/raw/reference/scorers/faithfulness.mdx +0 -241
- package/.docs/raw/reference/scorers/hallucination.mdx +0 -252
- package/.docs/raw/reference/scorers/keyword-coverage.mdx +0 -229
- package/.docs/raw/reference/scorers/prompt-alignment.mdx +0 -668
- package/.docs/raw/reference/scorers/textual-difference.mdx +0 -203
- package/.docs/raw/reference/scorers/tone-consistency.mdx +0 -211
- package/.docs/raw/reference/scorers/toxicity.mdx +0 -228
- package/.docs/raw/reference/workflows/run-methods/watch.mdx +0 -73
- package/.docs/raw/scorers/evals-old-api/custom-eval.mdx +0 -24
- package/.docs/raw/scorers/evals-old-api/overview.mdx +0 -106
- package/.docs/raw/scorers/evals-old-api/running-in-ci.mdx +0 -85
- package/.docs/raw/scorers/evals-old-api/textual-evals.mdx +0 -58
- package/.docs/raw/scorers/off-the-shelf-scorers.mdx +0 -50
- package/.docs/raw/workflows-legacy/control-flow.mdx +0 -774
- package/.docs/raw/workflows-legacy/dynamic-workflows.mdx +0 -239
- package/.docs/raw/workflows-legacy/error-handling.mdx +0 -187
- package/.docs/raw/workflows-legacy/nested-workflows.mdx +0 -360
- package/.docs/raw/workflows-legacy/overview.mdx +0 -182
- package/.docs/raw/workflows-legacy/runtime-variables.mdx +0 -156
- package/.docs/raw/workflows-legacy/steps.mdx +0 -115
- package/.docs/raw/workflows-legacy/suspend-and-resume.mdx +0 -406
- package/.docs/raw/workflows-legacy/variables.mdx +0 -318
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Guide: Building an AI Chef Assistant | Mastra Agent Guides"
|
|
3
|
+
description: Guide on creating a Chef Assistant agent in Mastra to help users cook meals with available ingredients.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import Steps from "@site/src/components/Steps";
|
|
7
|
+
import StepItem from "@site/src/components/StepItem";
|
|
8
|
+
import YouTube from "@site/src/components/YouTube-player";
|
|
9
|
+
|
|
10
|
+
# Building an AI Chef Assistant
|
|
11
|
+
|
|
12
|
+
In this guide, you'll create a "Chef Assistant" agent that helps users cook meals with available ingredients.
|
|
13
|
+
|
|
14
|
+
You'll learn how to create the agent and register it with Mastra. Next, you'll interact with the agent through your terminal and get to know different response formats. Lastly, you'll access the agent through Mastra's local API endpoints.
|
|
15
|
+
|
|
16
|
+
<YouTube id="_tZhOqHCrF0" />
|
|
17
|
+
|
|
18
|
+
## Prerequisites
|
|
19
|
+
|
|
20
|
+
- Node.js `v22.13.0` or later installed
|
|
21
|
+
- An API key from a supported [Model Provider](/models/v1)
|
|
22
|
+
- An existing Mastra project (Follow the [installation guide](/docs/v1/getting-started/installation) to set up a new project)
|
|
23
|
+
|
|
24
|
+
## Creating the Agent
|
|
25
|
+
|
|
26
|
+
To create an agent in Mastra use the `Agent` class to define it and then register it with Mastra.
|
|
27
|
+
|
|
28
|
+
<Steps>
|
|
29
|
+
|
|
30
|
+
<StepItem>
|
|
31
|
+
|
|
32
|
+
Create a new file `src/mastra/agents/chefAgent.ts` and define your agent:
|
|
33
|
+
|
|
34
|
+
```ts copy title="src/mastra/agents/chefAgent.ts"
|
|
35
|
+
import { openai } from "@ai-sdk/openai";
|
|
36
|
+
import { Agent } from "@mastra/core/agent";
|
|
37
|
+
|
|
38
|
+
export const chefAgent = new Agent({
|
|
39
|
+
id: "chef-agent",
|
|
40
|
+
name: "chef-agent",
|
|
41
|
+
instructions:
|
|
42
|
+
"You are Michel, a practical and experienced home chef" +
|
|
43
|
+
"You help people cook with whatever ingredients they have available.",
|
|
44
|
+
model: openai("gpt-4o-mini"),
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
</StepItem>
|
|
49
|
+
|
|
50
|
+
<StepItem>
|
|
51
|
+
|
|
52
|
+
In your `src/mastra/index.ts` file, register the agent:
|
|
53
|
+
|
|
54
|
+
```ts copy title="src/mastra/index.ts" {2, 5}
|
|
55
|
+
import { Mastra } from "@mastra/core";
|
|
56
|
+
import { chefAgent } from "./agents/chefAgent";
|
|
57
|
+
|
|
58
|
+
export const mastra = new Mastra({
|
|
59
|
+
agents: { chefAgent },
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
</StepItem>
|
|
64
|
+
|
|
65
|
+
</Steps >
|
|
66
|
+
|
|
67
|
+
## Interacting with the Agent
|
|
68
|
+
|
|
69
|
+
Depending on your requirements you can interact and get responses from the agent in different formats. In the following steps you'll learn how to generate, stream, and get structured output.
|
|
70
|
+
|
|
71
|
+
<Steps>
|
|
72
|
+
|
|
73
|
+
<StepItem>
|
|
74
|
+
|
|
75
|
+
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.
|
|
76
|
+
|
|
77
|
+
```ts copy title="src/index.ts"
|
|
78
|
+
import { chefAgent } from "./mastra/agents/chefAgent";
|
|
79
|
+
|
|
80
|
+
async function main() {
|
|
81
|
+
const query =
|
|
82
|
+
"In my kitchen I have: pasta, canned tomatoes, garlic, olive oil, and some dried herbs (basil and oregano). What can I make?";
|
|
83
|
+
console.log(`Query: ${query}`);
|
|
84
|
+
|
|
85
|
+
const response = await chefAgent.generate([{ role: "user", content: query }]);
|
|
86
|
+
console.log("\n👨🍳 Chef Michel:", response.text);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
main();
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Afterwards, run the script:
|
|
93
|
+
|
|
94
|
+
```bash copy
|
|
95
|
+
npx bun src/index.ts
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
You should get an output similar to this:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
Query: In my kitchen I have: pasta, canned tomatoes, garlic, olive oil, and some dried herbs (basil and oregano). What can I make?
|
|
102
|
+
|
|
103
|
+
👨🍳 Chef Michel: You can make a delicious pasta al pomodoro! Here's how...
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
</StepItem>
|
|
107
|
+
|
|
108
|
+
<StepItem>
|
|
109
|
+
|
|
110
|
+
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.
|
|
111
|
+
|
|
112
|
+
```ts copy title="src/index.ts"
|
|
113
|
+
import { chefAgent } from "./mastra/agents/chefAgent";
|
|
114
|
+
|
|
115
|
+
async function main() {
|
|
116
|
+
const query =
|
|
117
|
+
"Now I'm over at my friend's house, and they have: chicken thighs, coconut milk, sweet potatoes, and some curry powder.";
|
|
118
|
+
console.log(`Query: ${query}`);
|
|
119
|
+
|
|
120
|
+
const stream = await chefAgent.stream([{ role: "user", content: query }]);
|
|
121
|
+
|
|
122
|
+
console.log("\n Chef Michel: ");
|
|
123
|
+
|
|
124
|
+
for await (const chunk of stream.textStream) {
|
|
125
|
+
process.stdout.write(chunk);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
console.log("\n\n✅ Recipe complete!");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
main();
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Afterwards, run the script again:
|
|
135
|
+
|
|
136
|
+
```bash copy
|
|
137
|
+
npx bun src/index.ts
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
You should get an output similar to the one below. This time though you can read it line by line instead of one large block.
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
Query: Now I'm over at my friend's house, and they have: chicken thighs, coconut milk, sweet potatoes, and some curry powder.
|
|
144
|
+
|
|
145
|
+
👨🍳 Chef Michel:
|
|
146
|
+
Great! You can make a comforting chicken curry...
|
|
147
|
+
|
|
148
|
+
✅ Recipe complete!
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
</StepItem>
|
|
152
|
+
|
|
153
|
+
<StepItem>
|
|
154
|
+
|
|
155
|
+
Instead of showing the agent's response to a human you might want to pass it along to another part of your code. For these instances your agent should return [structured output](/docs/v1/agents/overview#structured-output).
|
|
156
|
+
|
|
157
|
+
Change your `src/index.ts` to the following:
|
|
158
|
+
|
|
159
|
+
```ts copy title="src/index.ts"
|
|
160
|
+
import { chefAgent } from "./mastra/agents/chefAgent";
|
|
161
|
+
import { z } from "zod";
|
|
162
|
+
|
|
163
|
+
async function main() {
|
|
164
|
+
const query =
|
|
165
|
+
"I want to make lasagna, can you generate a lasagna recipe for me?";
|
|
166
|
+
console.log(`Query: ${query}`);
|
|
167
|
+
|
|
168
|
+
// Define the Zod schema
|
|
169
|
+
const schema = z.object({
|
|
170
|
+
ingredients: z.array(
|
|
171
|
+
z.object({
|
|
172
|
+
name: z.string(),
|
|
173
|
+
amount: z.string(),
|
|
174
|
+
}),
|
|
175
|
+
),
|
|
176
|
+
steps: z.array(z.string()),
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
const response = await chefAgent.generate(
|
|
180
|
+
[{ role: "user", content: query }],
|
|
181
|
+
{
|
|
182
|
+
structuredOutput: {
|
|
183
|
+
schema,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
);
|
|
187
|
+
console.log("\n👨🍳 Chef Michel:", response.object);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
main();
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
After running the script again you should get an output similar to this:
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
Query: I want to make lasagna, can you generate a lasagna recipe for me?
|
|
197
|
+
|
|
198
|
+
👨🍳 Chef Michel: {
|
|
199
|
+
ingredients: [
|
|
200
|
+
{ name: "Lasagna noodles", amount: "12 sheets" },
|
|
201
|
+
{ name: "Ground beef", amount: "1 pound" },
|
|
202
|
+
// ...
|
|
203
|
+
],
|
|
204
|
+
steps: [
|
|
205
|
+
"Preheat oven to 375°F (190°C).",
|
|
206
|
+
"Cook the lasagna noodles according to package instructions.",
|
|
207
|
+
// ...
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
</StepItem>
|
|
213
|
+
|
|
214
|
+
</Steps >
|
|
215
|
+
|
|
216
|
+
## Running the Agent Server
|
|
217
|
+
|
|
218
|
+
Learn how to interact with your agent through Mastra's API.
|
|
219
|
+
|
|
220
|
+
<Steps>
|
|
221
|
+
|
|
222
|
+
<StepItem>
|
|
223
|
+
|
|
224
|
+
You can run your agent as a service using the `mastra dev` command:
|
|
225
|
+
|
|
226
|
+
```bash copy
|
|
227
|
+
mastra dev
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
This will start a server exposing endpoints to interact with your registered agents. Within [Studio](/docs/v1/getting-started/studio) you can test your agent through a UI.
|
|
231
|
+
|
|
232
|
+
</StepItem>
|
|
233
|
+
|
|
234
|
+
<StepItem>
|
|
235
|
+
|
|
236
|
+
By default, `mastra dev` runs on `http://localhost:4111`. Your Chef Assistant agent will be available at:
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
POST http://localhost:4111/api/agents/chefAgent/generate
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
</StepItem>
|
|
243
|
+
|
|
244
|
+
<StepItem>
|
|
245
|
+
|
|
246
|
+
You can interact with the agent using `curl` from the command line:
|
|
247
|
+
|
|
248
|
+
```bash copy
|
|
249
|
+
curl -X POST http://localhost:4111/api/agents/chefAgent/generate \
|
|
250
|
+
-H "Content-Type: application/json" \
|
|
251
|
+
-d '{
|
|
252
|
+
"messages": [
|
|
253
|
+
{
|
|
254
|
+
"role": "user",
|
|
255
|
+
"content": "I have eggs, flour, and milk. What can I make?"
|
|
256
|
+
}
|
|
257
|
+
]
|
|
258
|
+
}'
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
**Sample Response:**
|
|
262
|
+
|
|
263
|
+
```json
|
|
264
|
+
{
|
|
265
|
+
"text": "You can make delicious pancakes! Here's a simple recipe..."
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
</StepItem>
|
|
270
|
+
|
|
271
|
+
</Steps>
|
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Guide: Building a Notes MCP Server | Mastra Guide"
|
|
3
|
+
description: "A step-by-step guide to creating a fully-featured MCP (Model Context Protocol) server for managing notes using the Mastra framework."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import Steps from "@site/src/components/Steps";
|
|
7
|
+
import StepItem from "@site/src/components/StepItem";
|
|
8
|
+
|
|
9
|
+
# Building a Notes MCP Server
|
|
10
|
+
|
|
11
|
+
In this guide, you'll learn how to build a complete MCP (Model Context Protocol) server from scratch. This server will manage a collection of markdown notes and has these features:
|
|
12
|
+
|
|
13
|
+
1. **List and Read Notes**: Allow clients to browse and view markdown files stored on the server
|
|
14
|
+
2. **Write Notes**: Provide a tool for creating or updating notes
|
|
15
|
+
3. **Offer Smart Prompts**: Generate contextual prompts, like creating a daily note template or summarizing existing content
|
|
16
|
+
|
|
17
|
+
## Prerequisites
|
|
18
|
+
|
|
19
|
+
- Node.js `v22.13.0` or later installed
|
|
20
|
+
- An API key from a supported [Model Provider](/models/v1)
|
|
21
|
+
- An existing Mastra project (Follow the [installation guide](/docs/v1/getting-started/installation) to set up a new project)
|
|
22
|
+
|
|
23
|
+
## Adding necessary dependencies & files
|
|
24
|
+
|
|
25
|
+
Before you can create an MCP server you first need to install additional dependencies and set up a boilerplate folder structure.
|
|
26
|
+
|
|
27
|
+
<Steps>
|
|
28
|
+
|
|
29
|
+
<StepItem>
|
|
30
|
+
|
|
31
|
+
Add `@mastra/mcp` to your project:
|
|
32
|
+
|
|
33
|
+
```bash copy
|
|
34
|
+
npm install @mastra/mcp@beta
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
</StepItem>
|
|
38
|
+
|
|
39
|
+
<StepItem>
|
|
40
|
+
|
|
41
|
+
After following the default [installation guide](/docs/v1/getting-started/installation) your project will include files that are not relevant for this guide. You can safely remove them:
|
|
42
|
+
|
|
43
|
+
```bash copy
|
|
44
|
+
rm -rf src/mastra/agents src/mastra/workflows src/mastra/tools/weather-tool.ts
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
You should also change the `src/mastra/index.ts` file like so:
|
|
48
|
+
|
|
49
|
+
```ts copy title="src/mastra/index.ts"
|
|
50
|
+
import { Mastra } from "@mastra/core";
|
|
51
|
+
import { PinoLogger } from "@mastra/loggers";
|
|
52
|
+
import { LibSQLStore } from "@mastra/libsql";
|
|
53
|
+
|
|
54
|
+
export const mastra = new Mastra({
|
|
55
|
+
storage: new LibSQLStore({
|
|
56
|
+
id: 'mastra-storage',
|
|
57
|
+
// stores telemetry, evals, ... into memory storage, if it needs to persist, change to file:../mastra.db
|
|
58
|
+
url: ":memory:",
|
|
59
|
+
}),
|
|
60
|
+
logger: new PinoLogger({
|
|
61
|
+
name: "Mastra",
|
|
62
|
+
level: "info",
|
|
63
|
+
}),
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
</StepItem>
|
|
68
|
+
|
|
69
|
+
<StepItem>
|
|
70
|
+
|
|
71
|
+
Create a dedicated directory for your MCP server's logic and a `notes` directory for your notes:
|
|
72
|
+
|
|
73
|
+
```bash copy
|
|
74
|
+
mkdir notes src/mastra/mcp
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Create the following files:
|
|
78
|
+
|
|
79
|
+
```bash copy
|
|
80
|
+
touch src/mastra/mcp/{server,resources,prompts}.ts
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
- `server.ts`: Will contain the main MCP server configuration
|
|
84
|
+
- `resources.ts`: Will handle listing and reading note files
|
|
85
|
+
- `prompts.ts`: Will contain the logic for the smart prompts
|
|
86
|
+
|
|
87
|
+
The resulting directory structure should look like this:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
<your-project-name>/
|
|
91
|
+
├── notes/
|
|
92
|
+
└── src/
|
|
93
|
+
└── mastra/
|
|
94
|
+
├── index.ts
|
|
95
|
+
├── mcp/
|
|
96
|
+
│ ├── server.ts
|
|
97
|
+
│ ├── resources.ts
|
|
98
|
+
│ └── prompts.ts
|
|
99
|
+
└── tools/
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
</StepItem>
|
|
103
|
+
|
|
104
|
+
</Steps>
|
|
105
|
+
|
|
106
|
+
## Creating the MCP Server
|
|
107
|
+
|
|
108
|
+
Let's add the MCP server!
|
|
109
|
+
|
|
110
|
+
<Steps>
|
|
111
|
+
|
|
112
|
+
<StepItem>
|
|
113
|
+
|
|
114
|
+
In `src/mastra/mcp/server.ts`, define the MCP server instance:
|
|
115
|
+
|
|
116
|
+
```typescript copy title="src/mastra/mcp/server.ts"
|
|
117
|
+
import { MCPServer } from "@mastra/mcp";
|
|
118
|
+
|
|
119
|
+
export const notes = new MCPServer({
|
|
120
|
+
id: "notes",
|
|
121
|
+
name: "Notes Server",
|
|
122
|
+
version: "0.1.0",
|
|
123
|
+
tools: {},
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
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
|
+
|
|
129
|
+
```typescript copy title="src/mastra/index.ts" {4, 15-17}
|
|
130
|
+
import { Mastra } from "@mastra/core";
|
|
131
|
+
import { PinoLogger } from "@mastra/loggers";
|
|
132
|
+
import { LibSQLStore } from "@mastra/libsql";
|
|
133
|
+
import { notes } from "./mcp/server";
|
|
134
|
+
|
|
135
|
+
export const mastra = new Mastra({
|
|
136
|
+
storage: new LibSQLStore({
|
|
137
|
+
id: 'mastra-storage',
|
|
138
|
+
// stores telemetry, evals, ... into memory storage, if it needs to persist, change to file:../mastra.db
|
|
139
|
+
url: ":memory:",
|
|
140
|
+
}),
|
|
141
|
+
logger: new PinoLogger({
|
|
142
|
+
name: "Mastra",
|
|
143
|
+
level: "info",
|
|
144
|
+
}),
|
|
145
|
+
mcpServers: {
|
|
146
|
+
notes,
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
</StepItem>
|
|
152
|
+
|
|
153
|
+
<StepItem>
|
|
154
|
+
|
|
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
|
+
|
|
157
|
+
```typescript copy title="src/mastra/mcp/resources.ts"
|
|
158
|
+
import fs from "fs/promises";
|
|
159
|
+
import path from "path";
|
|
160
|
+
import { fileURLToPath } from "url";
|
|
161
|
+
import type { MCPServerResources, Resource } from "@mastra/mcp";
|
|
162
|
+
|
|
163
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
164
|
+
const __dirname = path.dirname(__filename);
|
|
165
|
+
const NOTES_DIR = path.resolve(__dirname, "../../notes"); // relative to the default output directory
|
|
166
|
+
|
|
167
|
+
const listNoteFiles = async (): Promise<Resource[]> => {
|
|
168
|
+
try {
|
|
169
|
+
await fs.mkdir(NOTES_DIR, { recursive: true });
|
|
170
|
+
const files = await fs.readdir(NOTES_DIR);
|
|
171
|
+
return files
|
|
172
|
+
.filter((file) => file.endsWith(".md"))
|
|
173
|
+
.map((file) => {
|
|
174
|
+
const title = file.replace(".md", "");
|
|
175
|
+
return {
|
|
176
|
+
uri: `notes://${title}`,
|
|
177
|
+
name: title,
|
|
178
|
+
description: `A note about ${title}`,
|
|
179
|
+
mime_type: "text/markdown",
|
|
180
|
+
};
|
|
181
|
+
});
|
|
182
|
+
} catch (error) {
|
|
183
|
+
console.error("Error listing note resources:", error);
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const readNoteFile = async (uri: string): Promise<string | null> => {
|
|
189
|
+
const title = uri.replace("notes://", "");
|
|
190
|
+
const notePath = path.join(NOTES_DIR, `${title}.md`);
|
|
191
|
+
try {
|
|
192
|
+
return await fs.readFile(notePath, "utf-8");
|
|
193
|
+
} catch (error) {
|
|
194
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") {
|
|
195
|
+
console.error(`Error reading resource ${uri}:`, error);
|
|
196
|
+
}
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export const resourceHandlers: MCPServerResources = {
|
|
202
|
+
listResources: listNoteFiles,
|
|
203
|
+
getResourceContent: async ({ uri }: { uri: string }) => {
|
|
204
|
+
const content = await readNoteFile(uri);
|
|
205
|
+
if (content === null) return { text: "" };
|
|
206
|
+
return { text: content };
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Register these resource handlers in `src/mastra/mcp/server.ts`:
|
|
212
|
+
|
|
213
|
+
```typescript copy title="src/mastra/mcp/server.ts" {2, 8}
|
|
214
|
+
import { MCPServer } from "@mastra/mcp";
|
|
215
|
+
import { resourceHandlers } from "./resources";
|
|
216
|
+
|
|
217
|
+
export const notes = new MCPServer({
|
|
218
|
+
id: "notes",
|
|
219
|
+
name: "Notes Server",
|
|
220
|
+
version: "0.1.0",
|
|
221
|
+
tools: {},
|
|
222
|
+
resources: resourceHandlers,
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
</StepItem>
|
|
227
|
+
|
|
228
|
+
<StepItem title="Implement and Register a Tool">
|
|
229
|
+
|
|
230
|
+
Tools are the actions your server can perform. Let's create a `write` tool.
|
|
231
|
+
First, define the tool in `src/mastra/tools/write-note.ts`:
|
|
232
|
+
|
|
233
|
+
```typescript copy title="src/mastra/tools/write-note.ts"
|
|
234
|
+
import { createTool } from "@mastra/core/tools";
|
|
235
|
+
import { z } from "zod";
|
|
236
|
+
import { fileURLToPath } from "url";
|
|
237
|
+
import path from "node:path";
|
|
238
|
+
import fs from "fs/promises";
|
|
239
|
+
|
|
240
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
241
|
+
const __dirname = path.dirname(__filename);
|
|
242
|
+
const NOTES_DIR = path.resolve(__dirname, "../../../notes");
|
|
243
|
+
|
|
244
|
+
export const writeNoteTool = createTool({
|
|
245
|
+
id: "write",
|
|
246
|
+
description: "Write a new note or overwrite an existing one.",
|
|
247
|
+
inputSchema: z.object({
|
|
248
|
+
title: z
|
|
249
|
+
.string()
|
|
250
|
+
.nonempty()
|
|
251
|
+
.describe("The title of the note. This will be the filename."),
|
|
252
|
+
content: z
|
|
253
|
+
.string()
|
|
254
|
+
.nonempty()
|
|
255
|
+
.describe("The markdown content of the note."),
|
|
256
|
+
}),
|
|
257
|
+
outputSchema: z.string().nonempty(),
|
|
258
|
+
execute: async (inputData) => {
|
|
259
|
+
try {
|
|
260
|
+
const { title, content } = inputData;
|
|
261
|
+
const filePath = path.join(NOTES_DIR, `${title}.md`);
|
|
262
|
+
await fs.mkdir(NOTES_DIR, { recursive: true });
|
|
263
|
+
await fs.writeFile(filePath, content, "utf-8");
|
|
264
|
+
return `Successfully wrote to note \"${title}\".`;
|
|
265
|
+
} catch (error: any) {
|
|
266
|
+
return `Error writing note: ${error.message}`;
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Register this tool in `src/mastra/mcp/server.ts`:
|
|
273
|
+
|
|
274
|
+
```typescript copy title="src/mastra/mcp/server.ts"
|
|
275
|
+
import { MCPServer } from "@mastra/mcp";
|
|
276
|
+
import { resourceHandlers } from "./resources";
|
|
277
|
+
import { writeNoteTool } from "../tools/write-note";
|
|
278
|
+
|
|
279
|
+
export const notes = new MCPServer({
|
|
280
|
+
id: "notes",
|
|
281
|
+
name: "Notes Server",
|
|
282
|
+
version: "0.1.0",
|
|
283
|
+
resources: resourceHandlers,
|
|
284
|
+
tools: {
|
|
285
|
+
write: writeNoteTool,
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
</StepItem>
|
|
291
|
+
|
|
292
|
+
<StepItem title="Implement and Register Prompts">
|
|
293
|
+
|
|
294
|
+
Prompt handlers provide ready-to-use prompts for clients. You'll add these three:
|
|
295
|
+
|
|
296
|
+
- Daily note
|
|
297
|
+
- Summarize a note
|
|
298
|
+
- Brainstorm ideas
|
|
299
|
+
|
|
300
|
+
This requires a few markdown-parsing libraries you need to install:
|
|
301
|
+
|
|
302
|
+
```bash copy
|
|
303
|
+
npm install unified remark-parse gray-matter @types/unist
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Implement the prompts in `src/mastra/mcp/prompts.ts`:
|
|
307
|
+
|
|
308
|
+
```typescript copy title="src/mastra/mcp/prompts.ts"
|
|
309
|
+
import type { MCPServerPrompts } from "@mastra/mcp";
|
|
310
|
+
import { unified } from "unified";
|
|
311
|
+
import remarkParse from "remark-parse";
|
|
312
|
+
import matter from "gray-matter";
|
|
313
|
+
import type { Node } from "unist";
|
|
314
|
+
|
|
315
|
+
const prompts = [
|
|
316
|
+
{
|
|
317
|
+
name: "new_daily_note",
|
|
318
|
+
description: "Create a new daily note.",
|
|
319
|
+
version: "1.0.0",
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
name: "summarize_note",
|
|
323
|
+
description: "Give me a TL;DR of the note.",
|
|
324
|
+
version: "1.0.0",
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
name: "brainstorm_ideas",
|
|
328
|
+
description: "Brainstorm new ideas based on a note.",
|
|
329
|
+
version: "1.0.0",
|
|
330
|
+
},
|
|
331
|
+
];
|
|
332
|
+
|
|
333
|
+
function stringifyNode(node: Node): string {
|
|
334
|
+
if ("value" in node && typeof node.value === "string") return node.value;
|
|
335
|
+
if ("children" in node && Array.isArray(node.children))
|
|
336
|
+
return node.children.map(stringifyNode).join("");
|
|
337
|
+
return "";
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export async function analyzeMarkdown(md: string) {
|
|
341
|
+
const { content } = matter(md);
|
|
342
|
+
const tree = unified().use(remarkParse).parse(content);
|
|
343
|
+
const headings: string[] = [];
|
|
344
|
+
const wordCounts: Record<string, number> = {};
|
|
345
|
+
let currentHeading = "untitled";
|
|
346
|
+
wordCounts[currentHeading] = 0;
|
|
347
|
+
tree.children.forEach((node) => {
|
|
348
|
+
if (node.type === "heading" && node.depth === 2) {
|
|
349
|
+
currentHeading = stringifyNode(node);
|
|
350
|
+
headings.push(currentHeading);
|
|
351
|
+
wordCounts[currentHeading] = 0;
|
|
352
|
+
} else {
|
|
353
|
+
const textContent = stringifyNode(node);
|
|
354
|
+
if (textContent.trim()) {
|
|
355
|
+
wordCounts[currentHeading] =
|
|
356
|
+
(wordCounts[currentHeading] || 0) + textContent.split(/\\s+/).length;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
return { headings, wordCounts };
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const getPromptMessages: MCPServerPrompts["getPromptMessages"] = async ({
|
|
364
|
+
name,
|
|
365
|
+
args,
|
|
366
|
+
}) => {
|
|
367
|
+
switch (name) {
|
|
368
|
+
case "new_daily_note":
|
|
369
|
+
const today = new Date().toISOString().split("T")[0];
|
|
370
|
+
return [
|
|
371
|
+
{
|
|
372
|
+
role: "user",
|
|
373
|
+
content: {
|
|
374
|
+
type: "text",
|
|
375
|
+
text: `Create a new note titled \"${today}\" with sections: \"## Tasks\", \"## Meetings\", \"## Notes\".`,
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
];
|
|
379
|
+
case "summarize_note":
|
|
380
|
+
if (!args?.noteContent) throw new Error("No content provided");
|
|
381
|
+
const metaSum = await analyzeMarkdown(args.noteContent as string);
|
|
382
|
+
return [
|
|
383
|
+
{
|
|
384
|
+
role: "user",
|
|
385
|
+
content: {
|
|
386
|
+
type: "text",
|
|
387
|
+
text: `Summarize each section in ≤ 3 bullets.\\n\\n### Outline\\n${metaSum.headings.map((h) => `- ${h} (${metaSum.wordCounts[h] || 0} words)`).join("\\n")}`.trim(),
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
];
|
|
391
|
+
case "brainstorm_ideas":
|
|
392
|
+
if (!args?.noteContent) throw new Error("No content provided");
|
|
393
|
+
const metaBrain = await analyzeMarkdown(args.noteContent as string);
|
|
394
|
+
return [
|
|
395
|
+
{
|
|
396
|
+
role: "user",
|
|
397
|
+
content: {
|
|
398
|
+
type: "text",
|
|
399
|
+
text: `Brainstorm 3 ideas for underdeveloped sections below ${args?.topic ? `on ${args.topic}` : "."}\\n\\nUnderdeveloped sections:\\n${metaBrain.headings.length ? metaBrain.headings.map((h) => `- ${h}`).join("\\n") : "- (none, pick any)"}`,
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
];
|
|
403
|
+
default:
|
|
404
|
+
throw new Error(`Prompt \"${name}\" not found`);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
export const promptHandlers: MCPServerPrompts = {
|
|
409
|
+
listPrompts: async () => prompts,
|
|
410
|
+
getPromptMessages,
|
|
411
|
+
};
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
Register these prompt handlers in `src/mastra/mcp/server.ts`:
|
|
415
|
+
|
|
416
|
+
```typescript copy title="src/mastra/mcp/server.ts"
|
|
417
|
+
import { MCPServer } from "@mastra/mcp";
|
|
418
|
+
import { resourceHandlers } from "./resources";
|
|
419
|
+
import { writeNoteTool } from "../tools/write-note";
|
|
420
|
+
import { promptHandlers } from "./prompts";
|
|
421
|
+
|
|
422
|
+
export const notes = new MCPServer({
|
|
423
|
+
id: "notes",
|
|
424
|
+
name: "Notes Server",
|
|
425
|
+
version: "0.1.0",
|
|
426
|
+
resources: resourceHandlers,
|
|
427
|
+
prompts: promptHandlers,
|
|
428
|
+
tools: {
|
|
429
|
+
write: writeNoteTool,
|
|
430
|
+
},
|
|
431
|
+
});
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
</StepItem>
|
|
435
|
+
|
|
436
|
+
</Steps>
|
|
437
|
+
|
|
438
|
+
## Run the Server
|
|
439
|
+
|
|
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
|
+
|
|
442
|
+
```bash copy
|
|
443
|
+
npm run dev
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
Open [`http://localhost:4111`](http://localhost:4111) in your browser. In the left sidebar, select **MCP Servers**. Select the **notes** MCP server.
|
|
447
|
+
|
|
448
|
+
You'll now be presented with instructions on how to add the MCP server to your IDE. You're able to use this MCP server with any MCP Client. On the right side under **Available Tools** you can also select the **write** tool.
|
|
449
|
+
|
|
450
|
+
Inside the **write** tool, try it out by providing `test` as a name and `this is a test` for the markdown content. After clicking on **Submit** you'll have a new `test.md` file inside `notes`.
|