@mastra/mcp-docs-server 1.0.0-beta.9 → 1.0.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%2Fchangeset-cli.md +3 -1
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +3 -1
- package/.docs/organized/changelogs/%40internal%2Fplayground.md +60 -0
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +15 -15
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +3 -1
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +287 -287
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +302 -302
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +53 -53
- package/.docs/organized/changelogs/%40mastra%2Fauth.md +38 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +66 -66
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +522 -212
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +239 -239
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +439 -234
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +450 -211
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +202 -0
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +448 -22
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +348 -348
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +60 -60
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +287 -287
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +106 -106
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +90 -90
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +86 -86
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +221 -221
- package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +70 -0
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +403 -225
- package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +72 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +145 -145
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +54 -0
- package/.docs/organized/changelogs/%40mastra%2Flance.md +456 -226
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +625 -229
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +71 -71
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +245 -245
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +28 -28
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +281 -281
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +354 -156
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +545 -212
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +481 -202
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +194 -194
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +781 -235
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +198 -198
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +282 -282
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +163 -163
- package/.docs/organized/changelogs/%40mastra%2Frag.md +310 -310
- package/.docs/organized/changelogs/%40mastra%2Freact.md +328 -237
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +64 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +160 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +230 -230
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +479 -232
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +53 -53
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +47 -47
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +110 -110
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +15 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +98 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +54 -54
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +46 -46
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +93 -93
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +47 -47
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +45 -45
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +45 -45
- package/.docs/organized/changelogs/create-mastra.md +219 -219
- package/.docs/organized/changelogs/mastra.md +276 -276
- package/.docs/organized/code-examples/a2a.md +2 -2
- package/.docs/organized/code-examples/agent-v6.md +221 -0
- package/.docs/organized/code-examples/agui.md +4 -4
- package/.docs/organized/code-examples/ai-elements.md +3 -3
- package/.docs/organized/code-examples/ai-sdk-useChat.md +2 -2
- package/.docs/organized/code-examples/ai-sdk-v5.md +3 -3
- package/.docs/organized/code-examples/assistant-ui.md +5 -5
- package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +2 -2
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +3 -3
- package/.docs/organized/code-examples/client-side-tools.md +4 -4
- package/.docs/organized/code-examples/crypto-chatbot.md +5 -5
- package/.docs/organized/code-examples/experimental-auth-weather-agent.md +1 -1
- package/.docs/organized/code-examples/fireworks-r1.md +2 -2
- package/.docs/organized/code-examples/heads-up-game.md +7 -7
- package/.docs/organized/code-examples/inngest.md +1075 -0
- package/.docs/organized/code-examples/mcp-configuration.md +1 -1
- package/.docs/organized/code-examples/mcp-server-adapters.md +2 -2
- package/.docs/organized/code-examples/memory-per-resource-example.md +3 -3
- package/.docs/organized/code-examples/memory-todo-agent.md +1 -1
- package/.docs/organized/code-examples/memory-with-context.md +1 -1
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/openapi-spec-writer.md +3 -3
- package/.docs/organized/code-examples/quick-start.md +1 -5
- package/.docs/organized/code-examples/server-app-access.md +2 -2
- package/.docs/organized/code-examples/server-express-adapter.md +1 -1
- package/.docs/organized/code-examples/server-fastify-adapter.md +83 -0
- package/.docs/organized/code-examples/server-hono-adapter.md +2 -2
- package/.docs/organized/code-examples/server-koa-adapter.md +94 -0
- package/.docs/organized/code-examples/stock-price-tool.md +21 -2
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-suspend-resume.md +1 -1
- package/.docs/raw/agents/adding-voice.mdx +24 -6
- package/.docs/raw/agents/agent-approval.mdx +209 -12
- package/.docs/raw/agents/agent-memory.mdx +36 -32
- package/.docs/raw/agents/guardrails.mdx +105 -56
- package/.docs/raw/agents/network-approval.mdx +281 -0
- package/.docs/raw/agents/networks.mdx +69 -13
- package/.docs/raw/agents/overview.mdx +43 -25
- package/.docs/raw/agents/processors.mdx +234 -17
- package/.docs/raw/agents/structured-output.mdx +78 -8
- package/.docs/raw/agents/using-tools.mdx +67 -6
- package/.docs/raw/course/01-first-agent/07-creating-your-agent.md +1 -2
- package/.docs/raw/course/01-first-agent/12-connecting-tool-to-agent.md +1 -1
- package/.docs/raw/course/01-first-agent/16-adding-memory-to-agent.md +1 -2
- package/.docs/raw/course/02-agent-tools-mcp/05-updating-your-agent.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/10-updating-agent-instructions-zapier.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/16-updating-agent-instructions-github.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/21-updating-agent-instructions-hackernews.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/27-updating-agent-instructions-filesystem.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/31-enhancing-memory-configuration.md +3 -3
- package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -2
- package/.docs/raw/course/03-agent-memory/07-understanding-memory-threads.md +35 -0
- package/.docs/raw/course/03-agent-memory/08-configuring-conversation-history.md +1 -2
- package/.docs/raw/course/03-agent-memory/13-vector-store-configuration.md +1 -1
- package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +4 -5
- package/.docs/raw/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +1 -1
- package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +3 -4
- package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +3 -4
- package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +3 -4
- package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +3 -4
- package/.docs/raw/course/04-workflows/11-creating-an-ai-agent.md +2 -3
- package/.docs/raw/deployment/cloud-providers.mdx +22 -0
- package/.docs/raw/deployment/mastra-server.mdx +140 -0
- package/.docs/raw/deployment/monorepo.mdx +106 -42
- package/.docs/raw/deployment/overview.mdx +35 -48
- package/.docs/raw/deployment/web-framework.mdx +17 -19
- package/.docs/raw/deployment/workflow-runners.mdx +16 -0
- package/.docs/raw/evals/built-in-scorers.mdx +2 -0
- package/.docs/raw/evals/custom-scorers.mdx +60 -12
- package/.docs/raw/evals/overview.mdx +6 -6
- package/.docs/raw/evals/running-in-ci.mdx +4 -2
- package/.docs/raw/getting-started/manual-install.mdx +20 -20
- package/.docs/raw/getting-started/mcp-docs-server.mdx +59 -2
- package/.docs/raw/getting-started/project-structure.mdx +2 -2
- package/.docs/raw/getting-started/start.mdx +17 -1
- package/.docs/raw/getting-started/studio.mdx +6 -35
- package/.docs/raw/guides/agent-frameworks/ai-sdk.mdx +23 -33
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +1034 -80
- package/.docs/raw/guides/build-your-ui/assistant-ui.mdx +8 -8
- package/.docs/raw/guides/build-your-ui/copilotkit.mdx +32 -11
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/amazon-ec2.mdx +9 -9
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/aws-lambda.mdx +13 -16
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/azure-app-services.mdx +5 -7
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/cloudflare-deployer.mdx +8 -5
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/digital-ocean.mdx +18 -23
- package/.docs/raw/guides/deployment/index.mdx +32 -0
- package/.docs/raw/guides/deployment/inngest.mdx +673 -0
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/netlify-deployer.mdx +7 -3
- package/.docs/raw/{deployment/cloud-providers → guides/deployment}/vercel-deployer.mdx +8 -5
- package/.docs/raw/guides/getting-started/astro.mdx +292 -451
- package/.docs/raw/guides/getting-started/express.mdx +72 -153
- package/.docs/raw/guides/getting-started/hono.mdx +227 -0
- package/.docs/raw/guides/getting-started/next-js.mdx +173 -61
- package/.docs/raw/guides/getting-started/nuxt.mdx +505 -0
- package/.docs/raw/guides/getting-started/quickstart.mdx +5 -5
- package/.docs/raw/guides/getting-started/sveltekit.mdx +238 -409
- package/.docs/raw/guides/getting-started/vite-react.mdx +317 -147
- 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 +20 -20
- package/.docs/raw/guides/guide/stock-agent.mdx +5 -5
- package/.docs/raw/guides/guide/web-search.mdx +38 -38
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +7 -7
- package/.docs/raw/guides/index.mdx +0 -1
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +2 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +105 -4
- package/.docs/raw/guides/migrations/upgrade-to-v1/cli.mdx +15 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +170 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/deployment.mdx +42 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/mastra.mdx +0 -35
- package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +40 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +17 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/processors.mdx +11 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/rag.mdx +47 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +271 -25
- package/.docs/raw/guides/migrations/upgrade-to-v1/tracing.mdx +72 -17
- package/.docs/raw/guides/migrations/upgrade-to-v1/vectors.mdx +46 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +50 -7
- 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 +86 -0
- package/.docs/raw/mastra-cloud/observability.mdx +43 -0
- package/.docs/raw/mastra-cloud/overview.mdx +31 -0
- package/.docs/raw/mastra-cloud/setup.mdx +64 -0
- package/.docs/raw/mastra-cloud/studio.mdx +35 -0
- package/.docs/raw/mcp/overview.mdx +60 -25
- package/.docs/raw/mcp/publishing-mcp-server.mdx +7 -4
- package/.docs/raw/memory/memory-processors.mdx +17 -12
- package/.docs/raw/memory/message-history.mdx +72 -0
- package/.docs/raw/memory/overview.mdx +38 -76
- package/.docs/raw/memory/semantic-recall.mdx +65 -52
- package/.docs/raw/memory/storage.mdx +248 -0
- package/.docs/raw/memory/working-memory.mdx +24 -13
- package/.docs/raw/observability/logging.mdx +16 -15
- package/.docs/raw/observability/overview.mdx +27 -7
- package/.docs/raw/observability/tracing/bridges/otel.mdx +7 -4
- package/.docs/raw/observability/tracing/exporters/arize.mdx +61 -24
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +32 -22
- package/.docs/raw/observability/tracing/exporters/cloud.mdx +24 -5
- package/.docs/raw/observability/tracing/exporters/datadog.mdx +175 -0
- package/.docs/raw/observability/tracing/exporters/default.mdx +28 -7
- package/.docs/raw/observability/tracing/exporters/laminar.mdx +89 -0
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +31 -22
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +33 -3
- package/.docs/raw/observability/tracing/exporters/otel.mdx +194 -22
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +32 -22
- package/.docs/raw/observability/tracing/exporters/sentry.mdx +198 -0
- package/.docs/raw/observability/tracing/overview.mdx +388 -108
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +27 -7
- package/.docs/raw/rag/chunking-and-embedding.mdx +22 -33
- package/.docs/raw/rag/graph-rag.mdx +223 -0
- package/.docs/raw/rag/overview.mdx +6 -3
- package/.docs/raw/rag/retrieval.mdx +53 -57
- package/.docs/raw/rag/vector-databases.mdx +55 -31
- package/.docs/raw/reference/agents/agent.mdx +17 -14
- package/.docs/raw/reference/agents/generate.mdx +172 -44
- package/.docs/raw/reference/agents/generateLegacy.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +5 -3
- package/.docs/raw/reference/agents/getDescription.mdx +3 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +5 -3
- package/.docs/raw/reference/agents/getLLM.mdx +5 -3
- package/.docs/raw/reference/agents/getMemory.mdx +5 -3
- package/.docs/raw/reference/agents/getModel.mdx +5 -3
- package/.docs/raw/reference/agents/getTools.mdx +4 -2
- package/.docs/raw/reference/agents/getVoice.mdx +4 -2
- package/.docs/raw/reference/agents/listAgents.mdx +4 -2
- package/.docs/raw/reference/agents/listScorers.mdx +5 -3
- package/.docs/raw/reference/agents/listTools.mdx +4 -2
- package/.docs/raw/reference/agents/listWorkflows.mdx +4 -2
- package/.docs/raw/reference/agents/network.mdx +113 -1
- package/.docs/raw/reference/ai-sdk/chat-route.mdx +6 -3
- package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +4 -2
- package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +4 -2
- package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +5 -3
- package/.docs/raw/reference/ai-sdk/network-route.mdx +6 -3
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-stream.mdx +10 -6
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v4-messages.mdx +130 -0
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v5-messages.mdx +110 -0
- package/.docs/raw/reference/ai-sdk/with-mastra.mdx +122 -0
- package/.docs/raw/reference/ai-sdk/workflow-route.mdx +7 -4
- package/.docs/raw/reference/auth/auth0.mdx +5 -3
- package/.docs/raw/reference/auth/clerk.mdx +5 -3
- package/.docs/raw/reference/auth/firebase.mdx +6 -5
- package/.docs/raw/reference/auth/jwt.mdx +5 -3
- package/.docs/raw/reference/auth/supabase.mdx +5 -3
- package/.docs/raw/reference/auth/workos.mdx +5 -3
- package/.docs/raw/reference/cli/create-mastra.mdx +12 -10
- package/.docs/raw/reference/cli/mastra.mdx +63 -15
- package/.docs/raw/reference/client-js/agents.mdx +77 -35
- package/.docs/raw/reference/client-js/error-handling.mdx +3 -3
- package/.docs/raw/reference/client-js/logs.mdx +2 -0
- package/.docs/raw/reference/client-js/mastra-client.mdx +4 -2
- package/.docs/raw/reference/client-js/memory.mdx +43 -1
- package/.docs/raw/reference/client-js/observability.mdx +2 -0
- package/.docs/raw/reference/client-js/telemetry.mdx +2 -0
- package/.docs/raw/reference/client-js/tools.mdx +2 -0
- package/.docs/raw/reference/client-js/vectors.mdx +2 -0
- package/.docs/raw/reference/client-js/workflows.mdx +47 -3
- package/.docs/raw/reference/configuration.mdx +761 -0
- package/.docs/raw/reference/core/addGateway.mdx +2 -0
- package/.docs/raw/reference/core/getAgent.mdx +3 -1
- package/.docs/raw/reference/core/getAgentById.mdx +3 -1
- package/.docs/raw/reference/core/getDeployer.mdx +3 -1
- package/.docs/raw/reference/core/getGateway.mdx +2 -0
- package/.docs/raw/reference/core/getGatewayById.mdx +2 -0
- package/.docs/raw/reference/core/getLogger.mdx +3 -1
- package/.docs/raw/reference/core/getMCPServer.mdx +3 -1
- package/.docs/raw/reference/core/getMCPServerById.mdx +3 -1
- package/.docs/raw/reference/core/getMemory.mdx +7 -3
- package/.docs/raw/reference/core/getScorer.mdx +2 -0
- package/.docs/raw/reference/core/getScorerById.mdx +2 -0
- package/.docs/raw/reference/core/getServer.mdx +6 -4
- package/.docs/raw/reference/core/getStorage.mdx +5 -3
- package/.docs/raw/reference/core/getStoredAgentById.mdx +6 -4
- package/.docs/raw/reference/core/getTelemetry.mdx +3 -1
- package/.docs/raw/reference/core/getVector.mdx +3 -1
- package/.docs/raw/reference/core/getWorkflow.mdx +3 -1
- package/.docs/raw/reference/core/listAgents.mdx +3 -1
- package/.docs/raw/reference/core/listGateways.mdx +2 -0
- package/.docs/raw/reference/core/listLogs.mdx +3 -1
- package/.docs/raw/reference/core/listLogsByRunId.mdx +3 -1
- package/.docs/raw/reference/core/listMCPServers.mdx +3 -1
- package/.docs/raw/reference/core/listMemory.mdx +8 -4
- package/.docs/raw/reference/core/listScorers.mdx +2 -0
- package/.docs/raw/reference/core/listStoredAgents.mdx +7 -5
- package/.docs/raw/reference/core/listVectors.mdx +3 -1
- package/.docs/raw/reference/core/listWorkflows.mdx +3 -1
- package/.docs/raw/reference/core/mastra-class.mdx +27 -20
- package/.docs/raw/reference/core/mastra-model-gateway.mdx +2 -0
- package/.docs/raw/reference/core/setLogger.mdx +3 -1
- package/.docs/raw/reference/core/setStorage.mdx +6 -4
- package/.docs/raw/reference/deployer/cloudflare.mdx +22 -53
- package/.docs/raw/reference/deployer/deployer.mdx +2 -1
- package/.docs/raw/reference/deployer/netlify.mdx +4 -1
- package/.docs/raw/reference/deployer/vercel.mdx +5 -4
- package/.docs/raw/reference/evals/answer-relevancy.mdx +4 -1
- package/.docs/raw/reference/evals/answer-similarity.mdx +4 -1
- package/.docs/raw/reference/evals/bias.mdx +4 -1
- package/.docs/raw/reference/evals/completeness.mdx +4 -1
- package/.docs/raw/reference/evals/content-similarity.mdx +4 -1
- package/.docs/raw/reference/evals/context-precision.mdx +4 -1
- package/.docs/raw/reference/evals/context-relevance.mdx +2 -0
- package/.docs/raw/reference/evals/create-scorer.mdx +11 -3
- package/.docs/raw/reference/evals/faithfulness.mdx +4 -1
- package/.docs/raw/reference/evals/hallucination.mdx +4 -1
- package/.docs/raw/reference/evals/keyword-coverage.mdx +4 -1
- package/.docs/raw/reference/evals/mastra-scorer.mdx +2 -0
- package/.docs/raw/reference/evals/noise-sensitivity.mdx +2 -0
- package/.docs/raw/reference/evals/prompt-alignment.mdx +9 -7
- package/.docs/raw/reference/evals/run-evals.mdx +3 -1
- package/.docs/raw/reference/evals/scorer-utils.mdx +3 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +4 -1
- package/.docs/raw/reference/evals/tone-consistency.mdx +4 -1
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +25 -23
- package/.docs/raw/reference/evals/toxicity.mdx +4 -1
- package/.docs/raw/reference/index.mdx +2 -1
- package/.docs/raw/reference/logging/pino-logger.mdx +10 -8
- package/.docs/raw/reference/memory/clone-utilities.mdx +345 -0
- package/.docs/raw/reference/memory/cloneThread.mdx +237 -0
- package/.docs/raw/reference/memory/createThread.mdx +6 -4
- package/.docs/raw/reference/memory/deleteMessages.mdx +4 -2
- package/.docs/raw/reference/memory/getThreadById.mdx +3 -1
- package/.docs/raw/reference/memory/listThreads.mdx +187 -0
- package/.docs/raw/reference/memory/memory-class.mdx +27 -20
- package/.docs/raw/reference/memory/recall.mdx +6 -4
- package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +6 -2
- package/.docs/raw/reference/observability/tracing/configuration.mdx +51 -0
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +25 -6
- package/.docs/raw/reference/observability/tracing/exporters/braintrust.mdx +23 -2
- package/.docs/raw/reference/observability/tracing/exporters/cloud-exporter.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/console-exporter.mdx +3 -0
- package/.docs/raw/reference/observability/tracing/exporters/datadog.mdx +172 -0
- package/.docs/raw/reference/observability/tracing/exporters/default-exporter.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/laminar.mdx +139 -0
- package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +26 -4
- package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +10 -0
- package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +51 -34
- package/.docs/raw/reference/observability/tracing/exporters/posthog.mdx +25 -4
- package/.docs/raw/reference/observability/tracing/exporters/sentry.mdx +224 -0
- package/.docs/raw/reference/observability/tracing/instances.mdx +2 -0
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +20 -0
- package/.docs/raw/reference/observability/tracing/processors/sensitive-data-filter.mdx +2 -0
- package/.docs/raw/reference/observability/tracing/spans.mdx +2 -0
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +4 -2
- package/.docs/raw/reference/processors/language-detector.mdx +6 -3
- package/.docs/raw/reference/processors/message-history-processor.mdx +5 -2
- package/.docs/raw/reference/processors/moderation-processor.mdx +6 -4
- package/.docs/raw/reference/processors/pii-detector.mdx +6 -4
- package/.docs/raw/reference/processors/processor-interface.mdx +326 -23
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +5 -3
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +7 -2
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +5 -3
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +62 -19
- package/.docs/raw/reference/processors/tool-call-filter.mdx +5 -3
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +6 -3
- package/.docs/raw/reference/processors/working-memory-processor.mdx +6 -3
- package/.docs/raw/reference/rag/chunk.mdx +7 -6
- package/.docs/raw/reference/rag/database-config.mdx +8 -6
- package/.docs/raw/reference/rag/document.mdx +2 -0
- package/.docs/raw/reference/rag/embeddings.mdx +2 -0
- package/.docs/raw/reference/rag/extract-params.mdx +57 -3
- package/.docs/raw/reference/rag/graph-rag.mdx +2 -0
- package/.docs/raw/reference/rag/metadata-filters.mdx +27 -7
- package/.docs/raw/reference/rag/rerank.mdx +2 -0
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +2 -0
- package/.docs/raw/reference/server/create-route.mdx +34 -18
- package/.docs/raw/reference/server/express-adapter.mdx +27 -51
- package/.docs/raw/reference/server/fastify-adapter.mdx +130 -0
- package/.docs/raw/reference/server/hono-adapter.mdx +27 -51
- package/.docs/raw/reference/server/koa-adapter.mdx +129 -0
- package/.docs/raw/reference/server/mastra-server.mdx +52 -34
- package/.docs/raw/reference/server/routes.mdx +73 -10
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +10 -5
- package/.docs/raw/reference/storage/cloudflare.mdx +12 -2
- package/.docs/raw/reference/storage/composite.mdx +245 -0
- package/.docs/raw/reference/storage/convex.mdx +8 -6
- package/.docs/raw/reference/storage/dynamodb.mdx +134 -8
- package/.docs/raw/reference/storage/lance.mdx +9 -5
- package/.docs/raw/reference/storage/libsql.mdx +76 -54
- package/.docs/raw/reference/storage/mongodb.mdx +115 -16
- package/.docs/raw/reference/storage/mssql.mdx +11 -6
- package/.docs/raw/{server-db/storage.mdx → reference/storage/overview.mdx} +15 -111
- package/.docs/raw/reference/storage/postgresql.mdx +228 -83
- package/.docs/raw/reference/storage/upstash.mdx +78 -2
- package/.docs/raw/reference/streaming/ChunkType.mdx +31 -3
- package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +67 -6
- package/.docs/raw/reference/streaming/agents/stream.mdx +48 -51
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +5 -3
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +3 -1
- package/.docs/raw/reference/streaming/workflows/resumeStream.mdx +3 -1
- package/.docs/raw/reference/streaming/workflows/stream.mdx +37 -22
- package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +6 -4
- package/.docs/raw/reference/templates/overview.mdx +3 -2
- package/.docs/raw/reference/tools/client.mdx +3 -0
- package/.docs/raw/reference/tools/create-tool.mdx +127 -5
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +2 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +40 -3
- package/.docs/raw/reference/tools/mcp-client.mdx +110 -1
- package/.docs/raw/reference/tools/mcp-server.mdx +278 -24
- package/.docs/raw/reference/tools/vector-query-tool.mdx +68 -4
- package/.docs/raw/reference/vectors/astra.mdx +5 -3
- package/.docs/raw/reference/vectors/chroma.mdx +5 -3
- package/.docs/raw/reference/vectors/convex.mdx +14 -12
- package/.docs/raw/reference/vectors/couchbase.mdx +7 -5
- package/.docs/raw/reference/vectors/duckdb.mdx +12 -10
- package/.docs/raw/reference/vectors/elasticsearch.mdx +12 -4
- package/.docs/raw/reference/vectors/lance.mdx +6 -4
- package/.docs/raw/reference/vectors/libsql.mdx +66 -13
- package/.docs/raw/reference/vectors/mongodb.mdx +90 -10
- package/.docs/raw/reference/vectors/opensearch.mdx +30 -3
- package/.docs/raw/reference/vectors/pg.mdx +58 -6
- package/.docs/raw/reference/vectors/pinecone.mdx +23 -8
- package/.docs/raw/reference/vectors/qdrant.mdx +148 -4
- package/.docs/raw/reference/vectors/s3vectors.mdx +8 -6
- package/.docs/raw/reference/vectors/turbopuffer.mdx +6 -4
- package/.docs/raw/reference/vectors/upstash.mdx +60 -6
- package/.docs/raw/reference/vectors/vectorize.mdx +5 -3
- package/.docs/raw/reference/voice/azure.mdx +2 -0
- package/.docs/raw/reference/voice/cloudflare.mdx +2 -0
- package/.docs/raw/reference/voice/composite-voice.mdx +4 -0
- package/.docs/raw/reference/voice/deepgram.mdx +2 -0
- package/.docs/raw/reference/voice/elevenlabs.mdx +2 -0
- package/.docs/raw/reference/voice/google-gemini-live.mdx +3 -0
- package/.docs/raw/reference/voice/google.mdx +2 -0
- package/.docs/raw/reference/voice/mastra-voice.mdx +2 -0
- package/.docs/raw/reference/voice/murf.mdx +2 -0
- package/.docs/raw/reference/voice/openai-realtime.mdx +3 -0
- package/.docs/raw/reference/voice/openai.mdx +2 -0
- package/.docs/raw/reference/voice/playai.mdx +2 -0
- package/.docs/raw/reference/voice/sarvam.mdx +2 -0
- package/.docs/raw/reference/voice/speechify.mdx +2 -0
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +3 -0
- package/.docs/raw/reference/voice/voice.addTools.mdx +3 -0
- package/.docs/raw/reference/voice/voice.answer.mdx +4 -0
- package/.docs/raw/reference/voice/voice.close.mdx +3 -0
- package/.docs/raw/reference/voice/voice.connect.mdx +5 -1
- package/.docs/raw/reference/voice/voice.events.mdx +2 -0
- package/.docs/raw/reference/voice/voice.getSpeakers.mdx +3 -0
- package/.docs/raw/reference/voice/voice.listen.mdx +6 -0
- package/.docs/raw/reference/voice/voice.off.mdx +2 -0
- package/.docs/raw/reference/voice/voice.on.mdx +5 -1
- package/.docs/raw/reference/voice/voice.send.mdx +4 -0
- package/.docs/raw/reference/voice/voice.speak.mdx +6 -0
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +2 -0
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +55 -5
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +6 -4
- package/.docs/raw/reference/workflows/run-methods/start.mdx +7 -5
- package/.docs/raw/reference/workflows/run-methods/startAsync.mdx +145 -0
- package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +10 -8
- package/.docs/raw/reference/workflows/run.mdx +11 -3
- package/.docs/raw/reference/workflows/step.mdx +56 -3
- package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +39 -2
- package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +71 -4
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +9 -7
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +4 -6
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +4 -6
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +3 -1
- package/.docs/raw/reference/workflows/workflow.mdx +193 -2
- package/.docs/raw/{auth → server/auth}/auth0.mdx +40 -21
- package/.docs/raw/{auth → server/auth}/clerk.mdx +37 -16
- package/.docs/raw/{auth → server/auth}/firebase.mdx +47 -25
- package/.docs/raw/{auth → server/auth}/index.mdx +8 -6
- package/.docs/raw/{auth → server/auth}/jwt.mdx +22 -10
- package/.docs/raw/{auth → server/auth}/supabase.mdx +45 -25
- package/.docs/raw/{auth → server/auth}/workos.mdx +39 -20
- package/.docs/raw/{server-db → server}/custom-adapters.mdx +40 -24
- package/.docs/raw/{server-db → server}/custom-api-routes.mdx +6 -6
- package/.docs/raw/{server-db → server}/mastra-client.mdx +35 -38
- package/.docs/raw/server/mastra-server.mdx +86 -0
- package/.docs/raw/{server-db → server}/middleware.mdx +11 -9
- package/.docs/raw/{server-db → server}/request-context.mdx +85 -43
- package/.docs/raw/{server-db → server}/server-adapters.mdx +154 -33
- package/.docs/raw/streaming/events.mdx +16 -7
- package/.docs/raw/streaming/overview.mdx +30 -17
- package/.docs/raw/streaming/tool-streaming.mdx +8 -6
- package/.docs/raw/streaming/workflow-streaming.mdx +8 -8
- package/.docs/raw/tools-mcp/advanced-usage.mdx +4 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +46 -12
- package/.docs/raw/tools-mcp/overview.mdx +14 -13
- package/.docs/raw/voice/overview.mdx +17 -2
- package/.docs/raw/voice/speech-to-speech.mdx +5 -0
- package/.docs/raw/voice/speech-to-text.mdx +4 -0
- package/.docs/raw/voice/text-to-speech.mdx +3 -0
- package/.docs/raw/workflows/agents-and-tools.mdx +70 -21
- package/.docs/raw/workflows/control-flow.mdx +369 -34
- package/.docs/raw/workflows/error-handling.mdx +192 -18
- package/.docs/raw/workflows/human-in-the-loop.mdx +8 -7
- package/.docs/raw/workflows/input-data-mapping.mdx +9 -7
- package/.docs/raw/workflows/overview.mdx +80 -34
- package/.docs/raw/workflows/snapshots.mdx +19 -45
- package/.docs/raw/workflows/suspend-and-resume.mdx +14 -14
- package/.docs/raw/workflows/time-travel.mdx +25 -21
- package/.docs/raw/workflows/workflow-state.mdx +7 -8
- package/CHANGELOG.md +260 -0
- package/README.md +36 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/stdio.js +746 -49
- package/dist/tools/course.d.ts.map +1 -1
- package/dist/tools/embedded-docs.d.ts +276 -0
- package/dist/tools/embedded-docs.d.ts.map +1 -0
- package/package.json +9 -8
- package/.docs/organized/changelogs/%40internal%2Fai-sdk-v4.md +0 -1
- package/.docs/raw/deployment/building-mastra.mdx +0 -73
- package/.docs/raw/deployment/cloud-providers/index.mdx +0 -55
- package/.docs/raw/deployment/mastra-cloud/dashboard.mdx +0 -100
- package/.docs/raw/deployment/mastra-cloud/observability.mdx +0 -53
- package/.docs/raw/deployment/mastra-cloud/overview.mdx +0 -65
- package/.docs/raw/deployment/mastra-cloud/setting-up.mdx +0 -105
- 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/reference/core/setTelemetry.mdx +0 -36
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +0 -110
- package/.docs/raw/reference/memory/query.mdx +0 -189
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +0 -70
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +0 -66
- package/.docs/raw/server-db/mastra-server.mdx +0 -97
- package/.docs/raw/workflows/inngest-workflow.mdx +0 -363
package/dist/stdio.js
CHANGED
|
@@ -4,12 +4,47 @@ import * as fs from 'fs';
|
|
|
4
4
|
import { existsSync, mkdirSync } from 'fs';
|
|
5
5
|
import * as os2 from 'os';
|
|
6
6
|
import os2__default from 'os';
|
|
7
|
-
import * as
|
|
8
|
-
import
|
|
7
|
+
import * as path5 from 'path';
|
|
8
|
+
import path5__default from 'path';
|
|
9
9
|
import fs3 from 'fs/promises';
|
|
10
10
|
import { MCPServer } from '@mastra/mcp';
|
|
11
11
|
import { z } from 'zod';
|
|
12
|
+
import { getPackageInfo } from 'local-pkg';
|
|
12
13
|
|
|
14
|
+
var LOG_LEVEL_PRIORITY = {
|
|
15
|
+
debug: 0,
|
|
16
|
+
info: 1,
|
|
17
|
+
warn: 2,
|
|
18
|
+
error: 3,
|
|
19
|
+
none: 4
|
|
20
|
+
// none = disable all logs
|
|
21
|
+
};
|
|
22
|
+
function mapToLogLevel(level) {
|
|
23
|
+
switch (level) {
|
|
24
|
+
case "debug":
|
|
25
|
+
return "debug";
|
|
26
|
+
case "info":
|
|
27
|
+
case "notice":
|
|
28
|
+
return "info";
|
|
29
|
+
case "warning":
|
|
30
|
+
return "warn";
|
|
31
|
+
case "error":
|
|
32
|
+
case "critical":
|
|
33
|
+
case "alert":
|
|
34
|
+
case "emergency":
|
|
35
|
+
return "error";
|
|
36
|
+
default:
|
|
37
|
+
return "info";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
var currentLogLevel = "debug";
|
|
41
|
+
function setLogLevel(level) {
|
|
42
|
+
currentLogLevel = level;
|
|
43
|
+
}
|
|
44
|
+
function shouldLog(level) {
|
|
45
|
+
const mappedLevel = mapToLogLevel(level);
|
|
46
|
+
return LOG_LEVEL_PRIORITY[mappedLevel] >= LOG_LEVEL_PRIORITY[currentLogLevel];
|
|
47
|
+
}
|
|
13
48
|
var writeErrorLog = (message, data) => {
|
|
14
49
|
const now = /* @__PURE__ */ new Date();
|
|
15
50
|
const timestamp = now.toISOString();
|
|
@@ -20,9 +55,9 @@ var writeErrorLog = (message, data) => {
|
|
|
20
55
|
...data ? typeof data === "object" ? data : { data } : {}
|
|
21
56
|
};
|
|
22
57
|
try {
|
|
23
|
-
const cacheDir =
|
|
58
|
+
const cacheDir = path5.join(os2.homedir(), ".cache", "mastra", "mcp-docs-server-logs");
|
|
24
59
|
fs.mkdirSync(cacheDir, { recursive: true });
|
|
25
|
-
const logFile =
|
|
60
|
+
const logFile = path5.join(cacheDir, `${hourTimestamp}.log`);
|
|
26
61
|
fs.appendFileSync(logFile, JSON.stringify(logMessage) + "\n", "utf8");
|
|
27
62
|
} catch (err) {
|
|
28
63
|
console.error("Failed to write to log file:", err);
|
|
@@ -31,6 +66,7 @@ var writeErrorLog = (message, data) => {
|
|
|
31
66
|
function createLogger(server2) {
|
|
32
67
|
const sendLog = async (level, message, data) => {
|
|
33
68
|
if (!server2) return;
|
|
69
|
+
if (!shouldLog(level)) return;
|
|
34
70
|
try {
|
|
35
71
|
const sdkServer = server2.getServer();
|
|
36
72
|
if (!sdkServer) return;
|
|
@@ -155,7 +191,7 @@ function getUpgradeToV1Messages(area) {
|
|
|
155
191
|
- If "${area}" doesn't end with 's', try adding 's' (e.g., "agent" \u2192 "agents")
|
|
156
192
|
4. If the guide exists, walk me through the changes step by step
|
|
157
193
|
5. If neither form exists, list available migration guides in "upgrade-to-v1/" and suggest which ones might be relevant to "${area}"
|
|
158
|
-
6. After you find the guide, collect all the codemod calls to run to codemods. These callouts are marked with ":::tip[Codemod]" in the docs. Run the codemods with "npx @mastra/codemod@
|
|
194
|
+
6. After you find the guide, collect all the codemod calls to run to codemods. These callouts are marked with ":::tip[Codemod]" in the docs. Run the codemods with "npx @mastra/codemod@latest <codemod-name> <path>" to automate all those changes. Afterwards, help me with any remaining manual changes needed.`
|
|
159
195
|
}
|
|
160
196
|
}
|
|
161
197
|
];
|
|
@@ -171,7 +207,7 @@ function getUpgradeToV1Messages(area) {
|
|
|
171
207
|
2. First, list all available migration guides with path: "upgrade-to-v1/"
|
|
172
208
|
2. Give me a high-level overview of what changed in each area
|
|
173
209
|
3. Find relevant migration areas to focus on based on my project's codebase and confirm the list with me
|
|
174
|
-
4. After the areas are confirmed, check the migration guides for callouts to codemods. These callouts are marked with ":::tip[Codemod]" in the docs. Run the codemods with "npx @mastra/codemod@
|
|
210
|
+
4. After the areas are confirmed, check the migration guides for callouts to codemods. These callouts are marked with ":::tip[Codemod]" in the docs. Run the codemods with "npx @mastra/codemod@latest v1" to automate all those changes. Afterwards, help me with any remaining manual changes needed.
|
|
175
211
|
|
|
176
212
|
After the areas are confirmed, we'll go through each one systematically.`
|
|
177
213
|
}
|
|
@@ -277,7 +313,7 @@ var blogInputSchema = z.object({
|
|
|
277
313
|
});
|
|
278
314
|
var blogTool = {
|
|
279
315
|
name: "mastraBlog",
|
|
280
|
-
description: "Get Mastra.ai blog content. Without a URL, returns a list of all blog posts. With a URL, returns the specific blog post content in markdown format. The blog contains changelog posts as well as announcements and posts about Mastra features and AI news",
|
|
316
|
+
description: "[\u{1F310} REMOTE] Get Mastra.ai blog content. Without a URL, returns a list of all blog posts. With a URL, returns the specific blog post content in markdown format. The blog contains changelog posts as well as announcements and posts about Mastra features and AI news",
|
|
281
317
|
parameters: blogInputSchema,
|
|
282
318
|
execute: async (args) => {
|
|
283
319
|
void logger.debug("Executing mastraBlog tool", { url: args.url });
|
|
@@ -316,7 +352,7 @@ async function listPackageChangelogs() {
|
|
|
316
352
|
}
|
|
317
353
|
async function readPackageChangelog(filename) {
|
|
318
354
|
const encodedName = encodePackageName(filename.replace(".md", ""));
|
|
319
|
-
const filePath =
|
|
355
|
+
const filePath = path5__default.join(changelogsDir, `${encodedName}.md`);
|
|
320
356
|
void logger.debug(`Reading changelog: ${filename}`);
|
|
321
357
|
try {
|
|
322
358
|
return await fs3.readFile(filePath, "utf-8");
|
|
@@ -336,7 +372,7 @@ var changesInputSchema = z.object({
|
|
|
336
372
|
});
|
|
337
373
|
var changesTool = {
|
|
338
374
|
name: "mastraChanges",
|
|
339
|
-
description: `Get changelog information for Mastra.ai packages. ${packagesListing}`,
|
|
375
|
+
description: `[\u{1F310} REMOTE] Get changelog information for Mastra.ai packages. ${packagesListing}`,
|
|
340
376
|
parameters: changesInputSchema,
|
|
341
377
|
execute: async (args) => {
|
|
342
378
|
void logger.debug("Executing mastraChanges tool", { package: args.package });
|
|
@@ -407,11 +443,11 @@ Here is the content for this step: <StepContent>${content}</StepContent>`;
|
|
|
407
443
|
When you're ready to continue, use the \`nextMastraCourseStep\` tool to move to the next step.`;
|
|
408
444
|
}
|
|
409
445
|
async function getDeviceIdPath() {
|
|
410
|
-
const cacheDir =
|
|
446
|
+
const cacheDir = path5__default.join(os2__default.homedir(), ".cache", "mastra");
|
|
411
447
|
if (!existsSync(cacheDir)) {
|
|
412
448
|
mkdirSync(cacheDir, { recursive: true });
|
|
413
449
|
}
|
|
414
|
-
return
|
|
450
|
+
return path5__default.join(cacheDir, ".device_id");
|
|
415
451
|
}
|
|
416
452
|
async function getDeviceCredentials() {
|
|
417
453
|
try {
|
|
@@ -461,13 +497,13 @@ async function readCourseStep(lessonName, stepName, _isFirstStep = false) {
|
|
|
461
497
|
if (!lessonDir) {
|
|
462
498
|
throw new Error(`Lesson "${lessonName}" not found.`);
|
|
463
499
|
}
|
|
464
|
-
const lessonPath =
|
|
500
|
+
const lessonPath = path5__default.join(courseDir, lessonDir);
|
|
465
501
|
const files = await fs3.readdir(lessonPath);
|
|
466
502
|
const stepFile = files.find((f) => f.endsWith(".md") && f.replace(/^\d+-/, "").replace(".md", "") === stepName);
|
|
467
503
|
if (!stepFile) {
|
|
468
504
|
throw new Error(`Step "${stepName}" not found in lesson "${lessonName}".`);
|
|
469
505
|
}
|
|
470
|
-
const filePath =
|
|
506
|
+
const filePath = path5__default.join(courseDir, lessonDir, stepFile);
|
|
471
507
|
try {
|
|
472
508
|
const content = await fs3.readFile(filePath, "utf-8");
|
|
473
509
|
return wrapContentInPrompt(content);
|
|
@@ -513,11 +549,11 @@ async function saveCourseState(state, deviceId) {
|
|
|
513
549
|
}
|
|
514
550
|
}
|
|
515
551
|
async function getCourseStatePath() {
|
|
516
|
-
const stateDirPath =
|
|
552
|
+
const stateDirPath = path5__default.join(os2__default.homedir(), ".cache", "mastra", "course");
|
|
517
553
|
if (!existsSync(stateDirPath)) {
|
|
518
554
|
mkdirSync(stateDirPath, { recursive: true });
|
|
519
555
|
}
|
|
520
|
-
return
|
|
556
|
+
return path5__default.join(stateDirPath, "state.json");
|
|
521
557
|
}
|
|
522
558
|
async function loadCourseState() {
|
|
523
559
|
const statePath = await getCourseStatePath();
|
|
@@ -535,7 +571,7 @@ async function scanCourseContent() {
|
|
|
535
571
|
const lessonDirs = await fs3.readdir(courseDir);
|
|
536
572
|
const lessons = await Promise.all(
|
|
537
573
|
lessonDirs.filter((dir) => !dir.startsWith(".")).sort((a, b) => a.localeCompare(b)).map(async (lessonDir) => {
|
|
538
|
-
const lessonPath =
|
|
574
|
+
const lessonPath = path5__default.join(courseDir, lessonDir);
|
|
539
575
|
const lessonStats = await fs3.stat(lessonPath);
|
|
540
576
|
if (!lessonStats.isDirectory()) return null;
|
|
541
577
|
const lessonName = lessonDir.replace(/^\d+-/, "");
|
|
@@ -605,7 +641,7 @@ async function mergeCourseStates(currentState, newState) {
|
|
|
605
641
|
}
|
|
606
642
|
var startMastraCourse = {
|
|
607
643
|
name: "startMastraCourse",
|
|
608
|
-
description: "Starts the Mastra Course. If the user is not registered, they will be prompted to register first. Otherwise, it will start at the first lesson or pick up where they last left off. ALWAYS ask the user for their email address if they are not registered. DO NOT assume their email address, they must confirm their email and that they want to register.",
|
|
644
|
+
description: "[\u{1F393} COURSE] Starts the Mastra Course. If the user is not registered, they will be prompted to register first. Otherwise, it will start at the first lesson or pick up where they last left off. ALWAYS ask the user for their email address if they are not registered. DO NOT assume their email address, they must confirm their email and that they want to register.",
|
|
609
645
|
parameters: z.object({
|
|
610
646
|
email: z.string().email().optional().describe("Email address for registration if not already registered. ")
|
|
611
647
|
}),
|
|
@@ -702,7 +738,7 @@ When you've completed this step, use the \`nextMastraCourseStep\` tool to contin
|
|
|
702
738
|
};
|
|
703
739
|
var getMastraCourseStatus = {
|
|
704
740
|
name: "getMastraCourseStatus",
|
|
705
|
-
description: "Gets the current status of the Mastra Course, including which lessons and steps have been completed",
|
|
741
|
+
description: "[\u{1F393} COURSE] Gets the current status of the Mastra Course, including which lessons and steps have been completed",
|
|
706
742
|
parameters: z.object({}),
|
|
707
743
|
execute: async (_args) => {
|
|
708
744
|
try {
|
|
@@ -779,7 +815,7 @@ Course status url: https://mastra.ai/course/${deviceId}`;
|
|
|
779
815
|
};
|
|
780
816
|
var startMastraCourseLesson = {
|
|
781
817
|
name: "startMastraCourseLesson",
|
|
782
|
-
description: "Starts a specific lesson in the Mastra Course. If the lesson has been started before, it will resume from the first incomplete step",
|
|
818
|
+
description: "[\u{1F393} COURSE] Starts a specific lesson in the Mastra Course. If the lesson has been started before, it will resume from the first incomplete step",
|
|
783
819
|
parameters: _courseLessonSchema,
|
|
784
820
|
execute: async (args) => {
|
|
785
821
|
try {
|
|
@@ -822,7 +858,7 @@ When you've completed this step, use the \`nextMastraCourseStep\` tool to contin
|
|
|
822
858
|
};
|
|
823
859
|
var nextMastraCourseStep = {
|
|
824
860
|
name: "nextMastraCourseStep",
|
|
825
|
-
description: "Advances to the next step in the current Mastra Course lesson. If all steps in the current lesson are completed, it will move to the next lesson",
|
|
861
|
+
description: "[\u{1F393} COURSE] Advances to the next step in the current Mastra Course lesson. If all steps in the current lesson are completed, it will move to the next lesson",
|
|
826
862
|
parameters: z.object({}),
|
|
827
863
|
execute: async (_args) => {
|
|
828
864
|
try {
|
|
@@ -893,7 +929,7 @@ If you'd like to review any lesson, use the \`startMastraCourseLesson\` tool wit
|
|
|
893
929
|
};
|
|
894
930
|
var clearMastraCourseHistory = {
|
|
895
931
|
name: "clearMastraCourseHistory",
|
|
896
|
-
description: "Clears all Mastra Course progress history and starts over from the beginning. This action cannot be undone",
|
|
932
|
+
description: "[\u{1F393} COURSE] Clears all Mastra Course progress history and starts over from the beginning. This action cannot be undone",
|
|
897
933
|
parameters: _confirmationSchema,
|
|
898
934
|
execute: async (args) => {
|
|
899
935
|
try {
|
|
@@ -939,8 +975,8 @@ async function listDirContents(dirPath) {
|
|
|
939
975
|
}
|
|
940
976
|
}
|
|
941
977
|
async function readMdxContent(docPath, queryKeywords) {
|
|
942
|
-
const fullPath =
|
|
943
|
-
if (!fullPath.startsWith(
|
|
978
|
+
const fullPath = path5__default.resolve(path5__default.join(docsBaseDir, docPath));
|
|
979
|
+
if (!fullPath.startsWith(path5__default.resolve(docsBaseDir))) {
|
|
944
980
|
void logger.error(`Path traversal attempt detected`);
|
|
945
981
|
return { found: false, isSecurityViolation: true };
|
|
946
982
|
}
|
|
@@ -965,7 +1001,7 @@ async function readMdxContent(docPath, queryKeywords) {
|
|
|
965
1001
|
].join("\n");
|
|
966
1002
|
let fileContents = "";
|
|
967
1003
|
for (const file of files) {
|
|
968
|
-
const filePath =
|
|
1004
|
+
const filePath = path5__default.join(fullPath, file);
|
|
969
1005
|
const content2 = await fs3.readFile(filePath, "utf-8");
|
|
970
1006
|
fileContents += `
|
|
971
1007
|
|
|
@@ -993,7 +1029,7 @@ async function findNearestDirectory(docPath, availablePaths2) {
|
|
|
993
1029
|
while (parts.length > 0) {
|
|
994
1030
|
const testPath = parts.join("/");
|
|
995
1031
|
try {
|
|
996
|
-
const fullPath =
|
|
1032
|
+
const fullPath = path5__default.join(docsBaseDir, testPath);
|
|
997
1033
|
const stats = await fs3.stat(fullPath);
|
|
998
1034
|
if (stats.isDirectory()) {
|
|
999
1035
|
const { dirs, files } = await listDirContents(fullPath);
|
|
@@ -1019,7 +1055,7 @@ async function getAvailablePaths() {
|
|
|
1019
1055
|
const { dirs, files } = await listDirContents(docsBaseDir);
|
|
1020
1056
|
let referenceDirs = [];
|
|
1021
1057
|
if (dirs.includes("reference/")) {
|
|
1022
|
-
const { dirs: refDirs } = await listDirContents(
|
|
1058
|
+
const { dirs: refDirs } = await listDirContents(path5__default.join(docsBaseDir, "reference"));
|
|
1023
1059
|
referenceDirs = refDirs.map((d) => `reference/${d}`);
|
|
1024
1060
|
}
|
|
1025
1061
|
return [
|
|
@@ -1046,7 +1082,7 @@ ${availablePaths}`),
|
|
|
1046
1082
|
});
|
|
1047
1083
|
var docsTool = {
|
|
1048
1084
|
name: "mastraDocs",
|
|
1049
|
-
description: `Get Mastra.ai documentation.
|
|
1085
|
+
description: `[\u{1F310} REMOTE] Get Mastra.ai documentation.
|
|
1050
1086
|
Request paths to explore the docs. References contain API docs.
|
|
1051
1087
|
Other paths contain guides. The user doesn't know about files and directories.
|
|
1052
1088
|
You can also use keywords from the user query to find relevant documentation, but prioritize paths.
|
|
@@ -1067,34 +1103,34 @@ var docsTool = {
|
|
|
1067
1103
|
try {
|
|
1068
1104
|
const queryKeywords = args.queryKeywords ?? [];
|
|
1069
1105
|
const results = await Promise.all(
|
|
1070
|
-
args.paths.map(async (
|
|
1106
|
+
args.paths.map(async (path8) => {
|
|
1071
1107
|
try {
|
|
1072
|
-
const result = await readMdxContent(
|
|
1108
|
+
const result = await readMdxContent(path8, queryKeywords);
|
|
1073
1109
|
if (result.found) {
|
|
1074
1110
|
return {
|
|
1075
|
-
path:
|
|
1111
|
+
path: path8,
|
|
1076
1112
|
content: result.content,
|
|
1077
1113
|
error: null
|
|
1078
1114
|
};
|
|
1079
1115
|
}
|
|
1080
1116
|
if (result.isSecurityViolation) {
|
|
1081
1117
|
return {
|
|
1082
|
-
path:
|
|
1118
|
+
path: path8,
|
|
1083
1119
|
content: null,
|
|
1084
1120
|
error: "Invalid path"
|
|
1085
1121
|
};
|
|
1086
1122
|
}
|
|
1087
|
-
const directorySuggestions = await findNearestDirectory(
|
|
1088
|
-
const contentBasedSuggestions = await getMatchingPaths(
|
|
1123
|
+
const directorySuggestions = await findNearestDirectory(path8, availablePaths);
|
|
1124
|
+
const contentBasedSuggestions = await getMatchingPaths(path8, queryKeywords, docsBaseDir);
|
|
1089
1125
|
return {
|
|
1090
|
-
path:
|
|
1126
|
+
path: path8,
|
|
1091
1127
|
content: null,
|
|
1092
1128
|
error: [directorySuggestions, contentBasedSuggestions].join("\n\n")
|
|
1093
1129
|
};
|
|
1094
1130
|
} catch (error) {
|
|
1095
|
-
void logger.warning(`Failed to read content for path: ${
|
|
1131
|
+
void logger.warning(`Failed to read content for path: ${path8}`, error);
|
|
1096
1132
|
return {
|
|
1097
|
-
path:
|
|
1133
|
+
path: path8,
|
|
1098
1134
|
content: null,
|
|
1099
1135
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
1100
1136
|
};
|
|
@@ -1124,6 +1160,647 @@ ${result.content}
|
|
|
1124
1160
|
}
|
|
1125
1161
|
}
|
|
1126
1162
|
};
|
|
1163
|
+
var packageCache = /* @__PURE__ */ new Map();
|
|
1164
|
+
var sourceMapCache = /* @__PURE__ */ new Map();
|
|
1165
|
+
var packageInfoCache = /* @__PURE__ */ new Map();
|
|
1166
|
+
var KNOWN_MASTRA_PACKAGES = [
|
|
1167
|
+
"@mastra/core",
|
|
1168
|
+
"@mastra/cli",
|
|
1169
|
+
"@mastra/memory",
|
|
1170
|
+
"@mastra/rag",
|
|
1171
|
+
"@mastra/evals",
|
|
1172
|
+
"@mastra/mcp",
|
|
1173
|
+
"@mastra/server",
|
|
1174
|
+
"@mastra/deployer",
|
|
1175
|
+
"@mastra/agent-builder",
|
|
1176
|
+
"@mastra/auth",
|
|
1177
|
+
"@mastra/fastembed",
|
|
1178
|
+
"@mastra/loggers",
|
|
1179
|
+
"@mastra/schema-compat",
|
|
1180
|
+
"@mastra/codemod"
|
|
1181
|
+
];
|
|
1182
|
+
async function getPackageRootPath(packageName, projectPath) {
|
|
1183
|
+
const cacheKey = `${packageName}:${projectPath}`;
|
|
1184
|
+
if (packageInfoCache.has(cacheKey)) {
|
|
1185
|
+
return packageInfoCache.get(cacheKey);
|
|
1186
|
+
}
|
|
1187
|
+
try {
|
|
1188
|
+
const info = await getPackageInfo(packageName, {
|
|
1189
|
+
paths: [path5__default.join(projectPath, "node_modules")]
|
|
1190
|
+
});
|
|
1191
|
+
if (info?.rootPath) {
|
|
1192
|
+
const result = { rootPath: info.rootPath, version: info.version || "unknown" };
|
|
1193
|
+
packageInfoCache.set(cacheKey, result);
|
|
1194
|
+
void logger.debug("Resolved package with local-pkg", { packageName, projectPath, ...result });
|
|
1195
|
+
return result;
|
|
1196
|
+
}
|
|
1197
|
+
} catch (err) {
|
|
1198
|
+
void logger.debug("Package not found or error resolving", {
|
|
1199
|
+
packageName,
|
|
1200
|
+
projectPath,
|
|
1201
|
+
error: err instanceof Error ? err.message : String(err)
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
packageInfoCache.set(cacheKey, null);
|
|
1205
|
+
return null;
|
|
1206
|
+
}
|
|
1207
|
+
async function getInstalledMastraPackages(projectPath) {
|
|
1208
|
+
const cacheKey = projectPath;
|
|
1209
|
+
if (packageCache.has(cacheKey)) {
|
|
1210
|
+
void logger.debug("Using cached package list", { count: packageCache.get(cacheKey).length });
|
|
1211
|
+
return packageCache.get(cacheKey);
|
|
1212
|
+
}
|
|
1213
|
+
void logger.debug("Scanning for @mastra packages using local-pkg", { projectPath });
|
|
1214
|
+
const packages = [];
|
|
1215
|
+
const packagesWithoutDocs = [];
|
|
1216
|
+
for (const packageName of KNOWN_MASTRA_PACKAGES) {
|
|
1217
|
+
const packageInfo = await getPackageRootPath(packageName, projectPath);
|
|
1218
|
+
if (packageInfo) {
|
|
1219
|
+
const docsPath = path5__default.join(packageInfo.rootPath, "dist", "docs");
|
|
1220
|
+
try {
|
|
1221
|
+
const stats = await fs3.stat(docsPath);
|
|
1222
|
+
if (stats.isDirectory()) {
|
|
1223
|
+
packages.push(packageName);
|
|
1224
|
+
void logger.debug("Found package with embedded docs", { package: packageName });
|
|
1225
|
+
} else {
|
|
1226
|
+
packagesWithoutDocs.push(packageName);
|
|
1227
|
+
}
|
|
1228
|
+
} catch {
|
|
1229
|
+
packagesWithoutDocs.push(packageName);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
const result = packages.sort();
|
|
1234
|
+
packageCache.set(cacheKey, result);
|
|
1235
|
+
void logger.info("Package scan complete", {
|
|
1236
|
+
packagesWithDocs: result.length,
|
|
1237
|
+
packagesWithoutDocs: packagesWithoutDocs.length,
|
|
1238
|
+
packages: result
|
|
1239
|
+
});
|
|
1240
|
+
return result;
|
|
1241
|
+
}
|
|
1242
|
+
async function readSourceMap(packageName, projectPath) {
|
|
1243
|
+
const cacheKey = `${packageName}:${projectPath}`;
|
|
1244
|
+
if (sourceMapCache.has(cacheKey)) return sourceMapCache.get(cacheKey);
|
|
1245
|
+
try {
|
|
1246
|
+
const packageInfo = await getPackageRootPath(packageName, projectPath);
|
|
1247
|
+
if (!packageInfo) {
|
|
1248
|
+
sourceMapCache.set(cacheKey, null);
|
|
1249
|
+
return null;
|
|
1250
|
+
}
|
|
1251
|
+
const sourceMapPath = path5__default.join(packageInfo.rootPath, "dist", "docs", "SOURCE_MAP.json");
|
|
1252
|
+
const content = await fs3.readFile(sourceMapPath, "utf-8");
|
|
1253
|
+
const sourceMap = JSON.parse(content);
|
|
1254
|
+
sourceMapCache.set(cacheKey, sourceMap);
|
|
1255
|
+
return sourceMap;
|
|
1256
|
+
} catch {
|
|
1257
|
+
sourceMapCache.set(cacheKey, null);
|
|
1258
|
+
return null;
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
var getMastraHelpTool = {
|
|
1262
|
+
name: "getMastraHelp",
|
|
1263
|
+
description: `\u{1F680} START HERE - Complete guide to Mastra documentation tools.
|
|
1264
|
+
|
|
1265
|
+
This MCP server provides TWO documentation sources:
|
|
1266
|
+
|
|
1267
|
+
## \u{1F4E6} LOCAL PACKAGE DOCS (Recommended for Development)
|
|
1268
|
+
SOURCE: Your installed @mastra packages in node_modules
|
|
1269
|
+
VERSION: Matches your installed code exactly
|
|
1270
|
+
|
|
1271
|
+
ADVANTAGES:
|
|
1272
|
+
- \u2705 Version-matched to your code
|
|
1273
|
+
- \u2705 Complete TypeScript type definitions
|
|
1274
|
+
- \u2705 Works offline
|
|
1275
|
+
- \u2705 SOURCE_MAP.json with exact exports
|
|
1276
|
+
|
|
1277
|
+
TOOLS: listMastraPackages, getMastraExports, getMastraExportDetails, readMastraDocs, searchMastraDocs
|
|
1278
|
+
USE WHEN: Writing code, implementing features, checking APIs, debugging
|
|
1279
|
+
|
|
1280
|
+
## \u{1F310} REMOTE WEBSITE DOCS (For Latest Info & Learning)
|
|
1281
|
+
SOURCE: mastra.ai website
|
|
1282
|
+
VERSION: Latest published documentation
|
|
1283
|
+
|
|
1284
|
+
ADVANTAGES:
|
|
1285
|
+
- \u2705 Always up-to-date
|
|
1286
|
+
- \u2705 Blog posts and announcements
|
|
1287
|
+
- \u2705 Migration guides
|
|
1288
|
+
- \u2705 Curated examples
|
|
1289
|
+
|
|
1290
|
+
TOOLS: mastraDocs, mastraBlog, mastraExamples, mastraChanges, mastraMigration
|
|
1291
|
+
USE WHEN: Learning concepts, checking latest features, migration help
|
|
1292
|
+
|
|
1293
|
+
## \u{1F393} INTERACTIVE COURSE
|
|
1294
|
+
TOOLS: startMastraCourse, getMastraCourseStatus, etc.
|
|
1295
|
+
USE WHEN: User wants guided learning experience
|
|
1296
|
+
|
|
1297
|
+
---
|
|
1298
|
+
|
|
1299
|
+
RECOMMENDED WORKFLOW:
|
|
1300
|
+
1. For coding: listMastraPackages \u2192 getMastraExports \u2192 getMastraExportDetails
|
|
1301
|
+
2. For learning: mastraDocs
|
|
1302
|
+
3. Version mismatch: mastraChanges \u2192 mastraMigration
|
|
1303
|
+
|
|
1304
|
+
This tool shows you which packages are installed and provides detailed guidance on using all available documentation tools.`,
|
|
1305
|
+
parameters: z.object({
|
|
1306
|
+
projectPath: z.string().describe("Absolute path to your project root (we will search upward for node_modules with Mastra packages)")
|
|
1307
|
+
}),
|
|
1308
|
+
execute: async (args) => {
|
|
1309
|
+
void logger.debug("Executing getMastraHelp tool", { projectPath: args.projectPath });
|
|
1310
|
+
const packages = await getInstalledMastraPackages(args.projectPath);
|
|
1311
|
+
if (packages.length === 0) {
|
|
1312
|
+
return `No Mastra packages with embedded documentation found in your project.
|
|
1313
|
+
|
|
1314
|
+
To use these tools, install Mastra packages like:
|
|
1315
|
+
- npm install @mastra/core
|
|
1316
|
+
- npm install @mastra/memory
|
|
1317
|
+
- npm install @mastra/rag
|
|
1318
|
+
|
|
1319
|
+
Then rebuild/reinstall to generate embedded docs.`;
|
|
1320
|
+
}
|
|
1321
|
+
return `# Mastra Documentation System - Complete Guide
|
|
1322
|
+
|
|
1323
|
+
This MCP server provides **TWO** documentation sources. Choose based on your needs:
|
|
1324
|
+
|
|
1325
|
+
---
|
|
1326
|
+
|
|
1327
|
+
## \u{1F4E6} LOCAL PACKAGE DOCS (Your Installed Packages)
|
|
1328
|
+
|
|
1329
|
+
Found ${packages.length} installed package(s) with embedded documentation:
|
|
1330
|
+
${packages.map((pkg) => `- ${pkg}`).join("\n")}
|
|
1331
|
+
|
|
1332
|
+
**SOURCE**: Your node_modules (matches installed code version)
|
|
1333
|
+
**USE WHEN**: Writing code, implementing features, debugging, checking APIs
|
|
1334
|
+
|
|
1335
|
+
### Available LOCAL Tools:
|
|
1336
|
+
|
|
1337
|
+
**1. listMastraPackages** - List installed packages
|
|
1338
|
+
Returns: Packages with embedded docs
|
|
1339
|
+
|
|
1340
|
+
**2. getMastraExports** - Explore package API surface
|
|
1341
|
+
Example: See all exports from @mastra/core (Agent, Tool, Workflow, etc.)
|
|
1342
|
+
Returns: List of exports with source file locations
|
|
1343
|
+
|
|
1344
|
+
**3. getMastraExportDetails** - Get type definitions & code
|
|
1345
|
+
Example: Get full TypeScript types for Agent class
|
|
1346
|
+
Returns: Complete type definitions and optionally implementation source
|
|
1347
|
+
|
|
1348
|
+
**4. readMastraDocs** - Read comprehensive guides
|
|
1349
|
+
Example: Read documentation about agents, tools, workflows, memory
|
|
1350
|
+
Returns: Topic-based guides and examples from your installed version
|
|
1351
|
+
|
|
1352
|
+
**5. searchMastraDocs** - Search local documentation
|
|
1353
|
+
Example: Search for "memory processors" or "semantic recall"
|
|
1354
|
+
Returns: Relevant excerpts from your installed docs
|
|
1355
|
+
|
|
1356
|
+
### Typical LOCAL Workflow:
|
|
1357
|
+
1. listMastraPackages \u2192 see what's installed
|
|
1358
|
+
2. getMastraExports \u2192 explore package API
|
|
1359
|
+
3. getMastraExportDetails \u2192 get type definitions
|
|
1360
|
+
4. readMastraDocs \u2192 learn concepts
|
|
1361
|
+
5. searchMastraDocs \u2192 find specific info
|
|
1362
|
+
|
|
1363
|
+
---
|
|
1364
|
+
|
|
1365
|
+
## \u{1F310} REMOTE WEBSITE DOCS (mastra.ai)
|
|
1366
|
+
|
|
1367
|
+
**SOURCE**: https://mastra.ai (latest published documentation)
|
|
1368
|
+
**USE WHEN**: Learning new concepts, checking latest features, migration guides
|
|
1369
|
+
|
|
1370
|
+
### Available REMOTE Tools:
|
|
1371
|
+
|
|
1372
|
+
**mastraDocs** - Browse official documentation
|
|
1373
|
+
Latest guides, references, and tutorials
|
|
1374
|
+
|
|
1375
|
+
**mastraBlog** - Read blog posts and announcements
|
|
1376
|
+
News, features, changelogs
|
|
1377
|
+
|
|
1378
|
+
**mastraExamples** - Get curated code examples
|
|
1379
|
+
Full example applications
|
|
1380
|
+
|
|
1381
|
+
**mastraChanges** - View package changelogs
|
|
1382
|
+
See what's new in each version
|
|
1383
|
+
|
|
1384
|
+
**mastraMigration** - Get migration guides
|
|
1385
|
+
Upgrade between versions
|
|
1386
|
+
|
|
1387
|
+
\u26A0\uFE0F **Version Note**: Remote docs show latest published version. For API reference matching YOUR code, use LOCAL tools above.
|
|
1388
|
+
|
|
1389
|
+
---
|
|
1390
|
+
|
|
1391
|
+
## \u{1F393} INTERACTIVE COURSE
|
|
1392
|
+
|
|
1393
|
+
**startMastraCourse**, **getMastraCourseStatus**, **startMastraCourseLesson**, **nextMastraCourseStep**, **clearMastraCourseHistory**
|
|
1394
|
+
|
|
1395
|
+
Guided learning experience with hands-on exercises.
|
|
1396
|
+
|
|
1397
|
+
---
|
|
1398
|
+
|
|
1399
|
+
## Quick Start Recommendations
|
|
1400
|
+
|
|
1401
|
+
**If you're writing code**: Use LOCAL tools
|
|
1402
|
+
\u2192 Start with listMastraPackages
|
|
1403
|
+
|
|
1404
|
+
**If you're learning**: Use REMOTE tools
|
|
1405
|
+
\u2192 Start with mastraDocs
|
|
1406
|
+
|
|
1407
|
+
**If version differs**: Check changes
|
|
1408
|
+
\u2192 mastraChanges \u2192 mastraMigration`;
|
|
1409
|
+
}
|
|
1410
|
+
};
|
|
1411
|
+
var listInstalledPackagesTool = {
|
|
1412
|
+
name: "listMastraPackages",
|
|
1413
|
+
description: `[\u{1F4E6} LOCAL PACKAGES] Discover which Mastra packages are installed and have documentation available.
|
|
1414
|
+
|
|
1415
|
+
Use this when you need to:
|
|
1416
|
+
- See what Mastra packages you can work with
|
|
1417
|
+
- Start exploring Mastra documentation
|
|
1418
|
+
- Check if a specific package is available
|
|
1419
|
+
|
|
1420
|
+
Returns: List of @mastra/* packages (core, memory, rag, etc.) with embedded docs.
|
|
1421
|
+
Next step: Use getMastraExports to explore a specific package's API.`,
|
|
1422
|
+
parameters: z.object({
|
|
1423
|
+
projectPath: z.string().describe("Absolute path to your project root (we will search upward for node_modules with Mastra packages)")
|
|
1424
|
+
}),
|
|
1425
|
+
execute: async (args) => {
|
|
1426
|
+
void logger.debug("Executing listInstalledMastraPackages tool", {
|
|
1427
|
+
projectPath: args.projectPath,
|
|
1428
|
+
cwd: process.cwd(),
|
|
1429
|
+
env: {
|
|
1430
|
+
PWD: process.env.PWD,
|
|
1431
|
+
HOME: process.env.HOME
|
|
1432
|
+
}
|
|
1433
|
+
});
|
|
1434
|
+
const packages = await getInstalledMastraPackages(args.projectPath);
|
|
1435
|
+
if (packages.length === 0) {
|
|
1436
|
+
return `No @mastra/* packages with embedded docs found in your project.
|
|
1437
|
+
|
|
1438
|
+
Install Mastra packages to get started:
|
|
1439
|
+
- npm install @mastra/core
|
|
1440
|
+
- npm install @mastra/memory
|
|
1441
|
+
- npm install @mastra/rag`;
|
|
1442
|
+
}
|
|
1443
|
+
return [
|
|
1444
|
+
`# Installed Mastra Packages`,
|
|
1445
|
+
"",
|
|
1446
|
+
`Found ${packages.length} package(s) with embedded documentation:`,
|
|
1447
|
+
"",
|
|
1448
|
+
...packages.map((pkg) => `- ${pkg}`),
|
|
1449
|
+
"",
|
|
1450
|
+
"## Next Steps",
|
|
1451
|
+
"",
|
|
1452
|
+
"1. Use **getMastraExports** with a package name to see all available APIs",
|
|
1453
|
+
"2. Use **readMastraDocs** with a package name to browse topic guides",
|
|
1454
|
+
"3. Use **searchMastraDocs** to find specific information"
|
|
1455
|
+
].join("\n");
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
var readSourceMapTool = {
|
|
1459
|
+
name: "getMastraExports",
|
|
1460
|
+
description: `[\u{1F4E6} LOCAL PACKAGES] Explore the complete API surface of a Mastra package - see all classes, functions, types, and constants.
|
|
1461
|
+
|
|
1462
|
+
Use this when you need to:
|
|
1463
|
+
- Discover what APIs a Mastra package provides (Agent, Tool, Workflow, etc.)
|
|
1464
|
+
- See all available classes and functions before implementing
|
|
1465
|
+
- Find the right export for your use case
|
|
1466
|
+
- Understand package structure and organization
|
|
1467
|
+
|
|
1468
|
+
Returns: List of all exports with their source file locations.
|
|
1469
|
+
Next step: Use getMastraExportDetails to get full type definitions and code for a specific export.`,
|
|
1470
|
+
parameters: z.object({
|
|
1471
|
+
package: z.string().describe('Package name to explore (e.g., "@mastra/core", "@mastra/memory", "@mastra/rag")'),
|
|
1472
|
+
projectPath: z.string().describe("Absolute path to your project root (we will search upward for node_modules)"),
|
|
1473
|
+
filter: z.string().optional().describe('Optional: filter exports by name (case-insensitive, e.g., "Agent", "create", "Tool")')
|
|
1474
|
+
}),
|
|
1475
|
+
execute: async (args) => {
|
|
1476
|
+
void logger.debug("Executing readMastraSourceMap tool", { args });
|
|
1477
|
+
const sourceMap = await readSourceMap(args.package, args.projectPath);
|
|
1478
|
+
if (!sourceMap) return `No SOURCE_MAP.json found for ${args.package}.`;
|
|
1479
|
+
let exports = Object.entries(sourceMap.exports);
|
|
1480
|
+
if (args.filter) {
|
|
1481
|
+
const filterLower = args.filter.toLowerCase();
|
|
1482
|
+
exports = exports.filter(([name]) => name.toLowerCase().includes(filterLower));
|
|
1483
|
+
}
|
|
1484
|
+
if (exports.length === 0) {
|
|
1485
|
+
return args.filter ? `No exports matching "${args.filter}" in ${args.package}.
|
|
1486
|
+
|
|
1487
|
+
Try running without a filter to see all available exports.` : `No exports found in ${args.package}.`;
|
|
1488
|
+
}
|
|
1489
|
+
return [
|
|
1490
|
+
`# ${sourceMap.package} v${sourceMap.version} - API Exports`,
|
|
1491
|
+
"",
|
|
1492
|
+
`Found ${exports.length} export(s)${args.filter ? ` matching "${args.filter}"` : ""}:`,
|
|
1493
|
+
"",
|
|
1494
|
+
...exports.map(([name, info]) => {
|
|
1495
|
+
const line = info.line ? `:${info.line}` : "";
|
|
1496
|
+
return `- **${name}**: \`${info.implementation}${line}\``;
|
|
1497
|
+
}),
|
|
1498
|
+
"",
|
|
1499
|
+
"## Next Steps",
|
|
1500
|
+
"",
|
|
1501
|
+
"- Use **getMastraExportDetails** with an export name to see full type definitions and code",
|
|
1502
|
+
"- Use **readMastraDocs** to read conceptual guides and examples",
|
|
1503
|
+
"- Use **searchMastraDocs** to find specific topics or patterns"
|
|
1504
|
+
].join("\n");
|
|
1505
|
+
}
|
|
1506
|
+
};
|
|
1507
|
+
var findExportTool = {
|
|
1508
|
+
name: "getMastraExportDetails",
|
|
1509
|
+
description: `[\u{1F4E6} LOCAL PACKAGES] Get complete API reference for a specific Mastra export - type definitions, interfaces, and optionally source code.
|
|
1510
|
+
|
|
1511
|
+
Use this when you need to:
|
|
1512
|
+
- Understand how to use a specific Mastra class or function (Agent, Tool, Workflow, etc.)
|
|
1513
|
+
- See TypeScript type definitions and interfaces
|
|
1514
|
+
- Look up method signatures and parameters
|
|
1515
|
+
- Read implementation code and examples
|
|
1516
|
+
- Understand constructor options and configuration
|
|
1517
|
+
|
|
1518
|
+
Returns: Full TypeScript type definitions and optionally implementation source code.
|
|
1519
|
+
Example: Get details on the Agent class to see how to create and configure agents.`,
|
|
1520
|
+
parameters: z.object({
|
|
1521
|
+
package: z.string().describe('Package name (e.g., "@mastra/core", "@mastra/memory")'),
|
|
1522
|
+
exportName: z.string().describe('Exact export name to look up (e.g., "Agent", "createTool", "Workflow")'),
|
|
1523
|
+
includeTypes: z.boolean().optional().default(true).describe("Include TypeScript type definitions (recommended: true)"),
|
|
1524
|
+
includeImplementation: z.boolean().optional().default(false).describe("Include source code implementation (useful for understanding internals)"),
|
|
1525
|
+
implementationLines: z.number().optional().default(50).describe("Number of lines of implementation code to show (default: 50)"),
|
|
1526
|
+
projectPath: z.string().describe("Absolute path to your project root (we will search upward for node_modules)")
|
|
1527
|
+
}),
|
|
1528
|
+
execute: async (args) => {
|
|
1529
|
+
void logger.debug("Executing findMastraExport tool", { args });
|
|
1530
|
+
const sourceMap = await readSourceMap(args.package, args.projectPath);
|
|
1531
|
+
if (!sourceMap) return `No SOURCE_MAP.json found for ${args.package}.`;
|
|
1532
|
+
const exportInfo = sourceMap.exports[args.exportName];
|
|
1533
|
+
if (!exportInfo) {
|
|
1534
|
+
const match = Object.entries(sourceMap.exports).find(
|
|
1535
|
+
([name]) => name.toLowerCase() === args.exportName.toLowerCase()
|
|
1536
|
+
);
|
|
1537
|
+
if (match) {
|
|
1538
|
+
return `Export "${args.exportName}" not found. Did you mean "${match[0]}"?
|
|
1539
|
+
|
|
1540
|
+
Run getMastraExports with package="${args.package}" to see all available exports.`;
|
|
1541
|
+
}
|
|
1542
|
+
return `Export "${args.exportName}" not found in ${args.package}.
|
|
1543
|
+
|
|
1544
|
+
Run getMastraExports with package="${args.package}" to see all available exports.`;
|
|
1545
|
+
}
|
|
1546
|
+
const packageInfo = await getPackageRootPath(args.package, args.projectPath);
|
|
1547
|
+
if (!packageInfo) {
|
|
1548
|
+
return `Package ${args.package} not found. Make sure it's installed.`;
|
|
1549
|
+
}
|
|
1550
|
+
const output = [`# ${args.exportName} (${args.package})`, ""];
|
|
1551
|
+
if (args.includeTypes !== false) {
|
|
1552
|
+
try {
|
|
1553
|
+
const typesPath = path5__default.join(packageInfo.rootPath, exportInfo.types);
|
|
1554
|
+
const typesContent = await fs3.readFile(typesPath, "utf-8");
|
|
1555
|
+
output.push("## Type Definition", "", `\`${exportInfo.types}\``, "", "```typescript");
|
|
1556
|
+
const lines = typesContent.split("\n");
|
|
1557
|
+
let startLine = lines.findIndex((line) => line.includes(args.exportName));
|
|
1558
|
+
if (startLine === -1) {
|
|
1559
|
+
output.push(typesContent.slice(0, 2e3));
|
|
1560
|
+
} else {
|
|
1561
|
+
startLine = Math.max(0, startLine - 2);
|
|
1562
|
+
let endLine = Math.min(lines.length, startLine + 50);
|
|
1563
|
+
output.push(lines.slice(startLine, endLine).join("\n"));
|
|
1564
|
+
}
|
|
1565
|
+
output.push("```", "");
|
|
1566
|
+
} catch {
|
|
1567
|
+
output.push("## Type Definition", "", `Could not read: ${exportInfo.types}`, "");
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
if (args.includeImplementation) {
|
|
1571
|
+
try {
|
|
1572
|
+
const implPath = path5__default.join(packageInfo.rootPath, exportInfo.implementation);
|
|
1573
|
+
const implContent = await fs3.readFile(implPath, "utf-8");
|
|
1574
|
+
const lines = implContent.split("\n");
|
|
1575
|
+
const numLines = args.implementationLines || 50;
|
|
1576
|
+
output.push("## Implementation", "");
|
|
1577
|
+
output.push(`\`${exportInfo.implementation}\`${exportInfo.line ? ` (line ${exportInfo.line})` : ""}`);
|
|
1578
|
+
output.push("", "```javascript");
|
|
1579
|
+
const startLine = exportInfo.line ? Math.max(0, exportInfo.line - 1) : 0;
|
|
1580
|
+
const endLine = Math.min(lines.length, startLine + numLines);
|
|
1581
|
+
output.push(lines.slice(startLine, endLine).join("\n"));
|
|
1582
|
+
if (endLine < lines.length) output.push(`// ... ${lines.length - endLine} more lines`);
|
|
1583
|
+
output.push("```", "");
|
|
1584
|
+
} catch {
|
|
1585
|
+
output.push("## Implementation", "", `Could not read: ${exportInfo.implementation}`, "");
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
output.push(
|
|
1589
|
+
"## Next Steps",
|
|
1590
|
+
"",
|
|
1591
|
+
"- Use **readMastraDocs** to see practical guides and examples",
|
|
1592
|
+
"- Use **searchMastraDocs** to find usage patterns and best practices",
|
|
1593
|
+
"- Use **getMastraExports** to explore related APIs"
|
|
1594
|
+
);
|
|
1595
|
+
return output.join("\n");
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
var readEmbeddedDocsTool = {
|
|
1599
|
+
name: "readMastraDocs",
|
|
1600
|
+
description: `[\u{1F4E6} LOCAL PACKAGES] Read comprehensive guides and documentation on Mastra concepts, patterns, and implementation examples.
|
|
1601
|
+
|
|
1602
|
+
Use this when you need to:
|
|
1603
|
+
- Learn how to implement Mastra features (agents, tools, workflows, memory, RAG, etc.)
|
|
1604
|
+
- Understand Mastra architecture and design patterns
|
|
1605
|
+
- See practical code examples and tutorials
|
|
1606
|
+
- Read getting started guides and best practices
|
|
1607
|
+
- Understand how different components work together
|
|
1608
|
+
|
|
1609
|
+
Returns: Topic-based documentation with explanations, examples, and usage patterns.
|
|
1610
|
+
Available topics: agents, tools, workflows, memory, rag, integrations, deployment, and more.`,
|
|
1611
|
+
parameters: z.object({
|
|
1612
|
+
package: z.string().describe('Package name to read docs from (e.g., "@mastra/core", "@mastra/memory")'),
|
|
1613
|
+
topic: z.string().optional().describe(
|
|
1614
|
+
'Optional: topic folder to read (e.g., "agents", "tools", "workflows"). Omit to list all available topics.'
|
|
1615
|
+
),
|
|
1616
|
+
file: z.string().optional().describe('Optional: specific documentation file within the topic (e.g., "01-overview.md")'),
|
|
1617
|
+
projectPath: z.string().describe("Absolute path to your project root (we will search upward for node_modules)")
|
|
1618
|
+
}),
|
|
1619
|
+
execute: async (args) => {
|
|
1620
|
+
void logger.debug("Executing readMastraEmbeddedDocs tool", { args });
|
|
1621
|
+
const packageInfo = await getPackageRootPath(args.package, args.projectPath);
|
|
1622
|
+
if (!packageInfo) {
|
|
1623
|
+
return `Package ${args.package} not found. Make sure it's installed.`;
|
|
1624
|
+
}
|
|
1625
|
+
const docsPath = path5__default.join(packageInfo.rootPath, "dist", "docs");
|
|
1626
|
+
try {
|
|
1627
|
+
await fs3.stat(docsPath);
|
|
1628
|
+
} catch {
|
|
1629
|
+
return `No embedded docs found for ${args.package}.
|
|
1630
|
+
|
|
1631
|
+
Make sure the package is installed and has documentation generated.`;
|
|
1632
|
+
}
|
|
1633
|
+
if (!args.topic) {
|
|
1634
|
+
const entries = await fs3.readdir(docsPath, { withFileTypes: true });
|
|
1635
|
+
const topics = entries.filter((e) => e.isDirectory()).map((e) => e.name);
|
|
1636
|
+
const files = entries.filter((e) => e.isFile()).map((e) => e.name);
|
|
1637
|
+
return [
|
|
1638
|
+
`# ${args.package} - Available Documentation`,
|
|
1639
|
+
"",
|
|
1640
|
+
"## Root Files",
|
|
1641
|
+
...files.map((f) => `- ${f}`),
|
|
1642
|
+
"",
|
|
1643
|
+
"## Documentation Topics",
|
|
1644
|
+
...topics.map((t) => `- **${t}/** - Run readMastraDocs with topic="${t}" to read`),
|
|
1645
|
+
"",
|
|
1646
|
+
"## Next Steps",
|
|
1647
|
+
"",
|
|
1648
|
+
"- Choose a topic and run **readMastraDocs** with the topic parameter",
|
|
1649
|
+
"- Use **searchMastraDocs** to search for specific information",
|
|
1650
|
+
"- Use **getMastraExports** to see available APIs"
|
|
1651
|
+
].join("\n");
|
|
1652
|
+
}
|
|
1653
|
+
const topicPath = path5__default.join(docsPath, args.topic);
|
|
1654
|
+
if (args.file) {
|
|
1655
|
+
try {
|
|
1656
|
+
const content = await fs3.readFile(path5__default.join(topicPath, args.file), "utf-8");
|
|
1657
|
+
return `# ${args.package}/${args.topic}/${args.file}
|
|
1658
|
+
|
|
1659
|
+
${content}
|
|
1660
|
+
|
|
1661
|
+
## Next Steps
|
|
1662
|
+
|
|
1663
|
+
- Use **getMastraExportDetails** to see API references for specific classes/functions mentioned
|
|
1664
|
+
- Use **searchMastraDocs** to find related topics
|
|
1665
|
+
- Use **getMastraExports** to explore available APIs`;
|
|
1666
|
+
} catch {
|
|
1667
|
+
return `File not found: ${args.topic}/${args.file}
|
|
1668
|
+
|
|
1669
|
+
Run readMastraDocs with package="${args.package}" and topic="${args.topic}" (without file parameter) to see available files.`;
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
try {
|
|
1673
|
+
const entries = await fs3.readdir(topicPath, { withFileTypes: true });
|
|
1674
|
+
const files = entries.filter((e) => e.isFile() && e.name.endsWith(".md")).sort();
|
|
1675
|
+
if (files.length === 0) {
|
|
1676
|
+
return `No markdown files in ${args.topic}/
|
|
1677
|
+
|
|
1678
|
+
Run readMastraDocs with package="${args.package}" (without topic parameter) to see available topics.`;
|
|
1679
|
+
}
|
|
1680
|
+
const contents = [`# ${args.package} - ${args.topic}`, ""];
|
|
1681
|
+
for (const file of files) {
|
|
1682
|
+
const content = await fs3.readFile(path5__default.join(topicPath, file.name), "utf-8");
|
|
1683
|
+
contents.push(`## ${file.name}`, "", content, "", "---", "");
|
|
1684
|
+
}
|
|
1685
|
+
contents.push(
|
|
1686
|
+
"",
|
|
1687
|
+
"## Next Steps",
|
|
1688
|
+
"",
|
|
1689
|
+
"- Use **getMastraExportDetails** to see API references for specific classes/functions mentioned above",
|
|
1690
|
+
"- Use **searchMastraDocs** to find related information",
|
|
1691
|
+
"- Use **getMastraExports** to explore the complete API surface"
|
|
1692
|
+
);
|
|
1693
|
+
return contents.join("\n");
|
|
1694
|
+
} catch {
|
|
1695
|
+
return `Topic not found: ${args.topic}
|
|
1696
|
+
|
|
1697
|
+
Run readMastraDocs with package="${args.package}" (without topic parameter) to see available topics.`;
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
};
|
|
1701
|
+
var searchEmbeddedDocsTool = {
|
|
1702
|
+
name: "searchMastraDocs",
|
|
1703
|
+
description: `[\u{1F4E6} LOCAL PACKAGES] Search across all Mastra documentation to find specific information, patterns, or examples.
|
|
1704
|
+
|
|
1705
|
+
Use this when you need to:
|
|
1706
|
+
- Find specific topics or concepts quickly (e.g., "memory processors", "tool composition")
|
|
1707
|
+
- Locate examples of specific features or patterns
|
|
1708
|
+
- Search for error messages or troubleshooting info
|
|
1709
|
+
- Find mentions of specific APIs or configuration options
|
|
1710
|
+
- Discover where a feature is documented
|
|
1711
|
+
|
|
1712
|
+
Returns: Relevant documentation excerpts with file paths, ranked by relevance.
|
|
1713
|
+
Tip: Use specific terms for better results (e.g., "agent memory" vs "memory").`,
|
|
1714
|
+
parameters: z.object({
|
|
1715
|
+
query: z.string().describe('What to search for (case-insensitive, e.g., "workflow steps", "vector store", "authentication")'),
|
|
1716
|
+
package: z.string().optional().describe('Optional: limit search to a specific package (e.g., "@mastra/core"). Omit to search all packages.'),
|
|
1717
|
+
maxResults: z.number().optional().default(10).describe("Optional: maximum number of results to return (default: 10)"),
|
|
1718
|
+
projectPath: z.string().describe("Absolute path to your project root (we will search upward for node_modules)")
|
|
1719
|
+
}),
|
|
1720
|
+
execute: async (args) => {
|
|
1721
|
+
void logger.debug("Executing searchMastraEmbeddedDocs tool", { args });
|
|
1722
|
+
const packages = args.package ? [args.package] : await getInstalledMastraPackages(args.projectPath);
|
|
1723
|
+
if (packages.length === 0) return "No Mastra packages found.";
|
|
1724
|
+
const queryLower = args.query.toLowerCase();
|
|
1725
|
+
const results = [];
|
|
1726
|
+
for (const pkg of packages) {
|
|
1727
|
+
const packageInfo = await getPackageRootPath(pkg, args.projectPath);
|
|
1728
|
+
if (!packageInfo) continue;
|
|
1729
|
+
const docsPath = path5__default.join(packageInfo.rootPath, "dist", "docs");
|
|
1730
|
+
try {
|
|
1731
|
+
const findFiles = async (dir) => {
|
|
1732
|
+
const entries = await fs3.readdir(dir, { withFileTypes: true });
|
|
1733
|
+
const files = [];
|
|
1734
|
+
for (const entry of entries) {
|
|
1735
|
+
const fullPath = path5__default.join(dir, entry.name);
|
|
1736
|
+
if (entry.isDirectory()) files.push(...await findFiles(fullPath));
|
|
1737
|
+
else if (entry.name.endsWith(".md")) files.push(fullPath);
|
|
1738
|
+
}
|
|
1739
|
+
return files;
|
|
1740
|
+
};
|
|
1741
|
+
for (const file of await findFiles(docsPath)) {
|
|
1742
|
+
const content = await fs3.readFile(file, "utf-8");
|
|
1743
|
+
if (!content.toLowerCase().includes(queryLower)) continue;
|
|
1744
|
+
const lines = content.split("\n");
|
|
1745
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1746
|
+
if (lines[i].toLowerCase().includes(queryLower)) {
|
|
1747
|
+
const start = Math.max(0, i - 1);
|
|
1748
|
+
const end = Math.min(lines.length, i + 3);
|
|
1749
|
+
const excerpt = lines.slice(start, end).join("\n").slice(0, 300);
|
|
1750
|
+
const contentLower = content.toLowerCase();
|
|
1751
|
+
const occurrences = contentLower.split(queryLower).length - 1;
|
|
1752
|
+
results.push({
|
|
1753
|
+
pkg,
|
|
1754
|
+
file: path5__default.relative(docsPath, file),
|
|
1755
|
+
excerpt,
|
|
1756
|
+
score: occurrences
|
|
1757
|
+
});
|
|
1758
|
+
break;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
} catch {
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
results.sort((a, b) => b.score - a.score);
|
|
1766
|
+
const topResults = results.slice(0, args.maxResults || 10);
|
|
1767
|
+
if (topResults.length === 0) {
|
|
1768
|
+
return `No results found for "${args.query}".
|
|
1769
|
+
|
|
1770
|
+
Try:
|
|
1771
|
+
- Using different search terms
|
|
1772
|
+
- Searching for broader topics
|
|
1773
|
+
- Using **listMastraPackages** to see available packages
|
|
1774
|
+
- Using **readMastraDocs** to browse documentation by topic`;
|
|
1775
|
+
}
|
|
1776
|
+
return [
|
|
1777
|
+
`# Search Results: "${args.query}"`,
|
|
1778
|
+
"",
|
|
1779
|
+
`Found ${results.length} result(s), showing top ${topResults.length}:`,
|
|
1780
|
+
"",
|
|
1781
|
+
...topResults.map((r, i) => `## ${i + 1}. ${r.pkg} - ${r.file}
|
|
1782
|
+
|
|
1783
|
+
\`\`\`
|
|
1784
|
+
${r.excerpt}
|
|
1785
|
+
\`\`\`
|
|
1786
|
+
`),
|
|
1787
|
+
"",
|
|
1788
|
+
"## Next Steps",
|
|
1789
|
+
"",
|
|
1790
|
+
"- Use **readMastraDocs** with a package and topic to read full documentation",
|
|
1791
|
+
"- Use **getMastraExportDetails** to see API details for mentioned classes/functions",
|
|
1792
|
+
"- Refine your search with more specific terms if needed"
|
|
1793
|
+
].join("\n");
|
|
1794
|
+
}
|
|
1795
|
+
};
|
|
1796
|
+
var embeddedDocsTools = {
|
|
1797
|
+
getMastraHelp: getMastraHelpTool,
|
|
1798
|
+
listMastraPackages: listInstalledPackagesTool,
|
|
1799
|
+
getMastraExports: readSourceMapTool,
|
|
1800
|
+
getMastraExportDetails: findExportTool,
|
|
1801
|
+
readMastraDocs: readEmbeddedDocsTool,
|
|
1802
|
+
searchMastraDocs: searchEmbeddedDocsTool
|
|
1803
|
+
};
|
|
1127
1804
|
var examplesDir = fromPackageRoot(".docs/organized/code-examples");
|
|
1128
1805
|
async function listCodeExamples() {
|
|
1129
1806
|
void logger.debug("Listing code examples");
|
|
@@ -1138,7 +1815,7 @@ async function listCodeExamples() {
|
|
|
1138
1815
|
}
|
|
1139
1816
|
}
|
|
1140
1817
|
async function readCodeExample(filename, queryKeywords) {
|
|
1141
|
-
const filePath =
|
|
1818
|
+
const filePath = path5__default.join(examplesDir, filename);
|
|
1142
1819
|
void logger.debug(`Reading example: ${filename}`);
|
|
1143
1820
|
try {
|
|
1144
1821
|
const content = await fs3.readFile(filePath, "utf-8");
|
|
@@ -1167,7 +1844,7 @@ var examplesInputSchema = z.object({
|
|
|
1167
1844
|
});
|
|
1168
1845
|
var examplesTool = {
|
|
1169
1846
|
name: "mastraExamples",
|
|
1170
|
-
description: `Get code examples from the Mastra.ai examples directory.
|
|
1847
|
+
description: `[\u{1F310} REMOTE] Get code examples from the Mastra.ai examples directory.
|
|
1171
1848
|
Without a specific example name, lists all available examples.
|
|
1172
1849
|
With an example name, returns the full source code of that example.
|
|
1173
1850
|
You can also use keywords from the user query to find relevant examples, but prioritize example names.`,
|
|
@@ -1233,11 +1910,11 @@ function parseMdxSections(content) {
|
|
|
1233
1910
|
}
|
|
1234
1911
|
async function discoverMigrations(baseDir, relativePath = "") {
|
|
1235
1912
|
const migrations = [];
|
|
1236
|
-
const fullPath =
|
|
1913
|
+
const fullPath = path5__default.join(baseDir, relativePath);
|
|
1237
1914
|
try {
|
|
1238
1915
|
const entries = await fs3.readdir(fullPath, { withFileTypes: true });
|
|
1239
1916
|
for (const entry of entries) {
|
|
1240
|
-
const entryRelativePath =
|
|
1917
|
+
const entryRelativePath = path5__default.join(relativePath, entry.name);
|
|
1241
1918
|
if (entry.isDirectory()) {
|
|
1242
1919
|
migrations.push({
|
|
1243
1920
|
path: entryRelativePath,
|
|
@@ -1247,7 +1924,7 @@ async function discoverMigrations(baseDir, relativePath = "") {
|
|
|
1247
1924
|
migrations.push(...subMigrations);
|
|
1248
1925
|
} else if (entry.isFile() && entry.name.endsWith(".mdx") && entry.name !== "_template.mdx") {
|
|
1249
1926
|
migrations.push({
|
|
1250
|
-
path:
|
|
1927
|
+
path: path5__default.join(relativePath, entry.name.replace(".mdx", "")),
|
|
1251
1928
|
type: "file"
|
|
1252
1929
|
});
|
|
1253
1930
|
}
|
|
@@ -1259,9 +1936,9 @@ async function discoverMigrations(baseDir, relativePath = "") {
|
|
|
1259
1936
|
}
|
|
1260
1937
|
async function listDirectoryContents(dirPath = "") {
|
|
1261
1938
|
try {
|
|
1262
|
-
const fullPath =
|
|
1263
|
-
const resolvedPath =
|
|
1264
|
-
const resolvedBaseDir =
|
|
1939
|
+
const fullPath = path5__default.join(migrationsBaseDir, dirPath);
|
|
1940
|
+
const resolvedPath = path5__default.resolve(fullPath);
|
|
1941
|
+
const resolvedBaseDir = path5__default.resolve(migrationsBaseDir);
|
|
1265
1942
|
if (!resolvedPath.startsWith(resolvedBaseDir)) {
|
|
1266
1943
|
return "Invalid path";
|
|
1267
1944
|
}
|
|
@@ -1316,9 +1993,9 @@ async function listDirectoryContents(dirPath = "") {
|
|
|
1316
1993
|
async function readMigrationContent(migrationPath) {
|
|
1317
1994
|
try {
|
|
1318
1995
|
let filename = migrationPath.endsWith(".mdx") ? migrationPath : `${migrationPath}.mdx`;
|
|
1319
|
-
let filePath =
|
|
1320
|
-
const resolvedPath =
|
|
1321
|
-
const resolvedBaseDir =
|
|
1996
|
+
let filePath = path5__default.join(migrationsBaseDir, filename);
|
|
1997
|
+
const resolvedPath = path5__default.resolve(filePath);
|
|
1998
|
+
const resolvedBaseDir = path5__default.resolve(migrationsBaseDir);
|
|
1322
1999
|
if (!resolvedPath.startsWith(resolvedBaseDir)) {
|
|
1323
2000
|
void logger.error("Path traversal attempt detected");
|
|
1324
2001
|
return null;
|
|
@@ -1377,7 +2054,7 @@ var migrationInputSchema = z.object({
|
|
|
1377
2054
|
});
|
|
1378
2055
|
var migrationTool = {
|
|
1379
2056
|
name: "mastraMigration",
|
|
1380
|
-
description: `Get migration guidance for Mastra version upgrades and breaking changes.
|
|
2057
|
+
description: `[\u{1F310} REMOTE] Get migration guidance for Mastra version upgrades and breaking changes.
|
|
1381
2058
|
|
|
1382
2059
|
This tool works like a file browser - navigate through directories to find migration guides:
|
|
1383
2060
|
|
|
@@ -1483,7 +2160,9 @@ server = new MCPServer({
|
|
|
1483
2160
|
getMastraCourseStatus,
|
|
1484
2161
|
startMastraCourseLesson,
|
|
1485
2162
|
nextMastraCourseStep,
|
|
1486
|
-
clearMastraCourseHistory
|
|
2163
|
+
clearMastraCourseHistory,
|
|
2164
|
+
// Embedded docs tools for reading docs from installed packages
|
|
2165
|
+
...embeddedDocsTools
|
|
1487
2166
|
},
|
|
1488
2167
|
prompts: migrationPromptMessages
|
|
1489
2168
|
});
|
|
@@ -1499,6 +2178,24 @@ async function runServer() {
|
|
|
1499
2178
|
}
|
|
1500
2179
|
|
|
1501
2180
|
// src/stdio.ts
|
|
2181
|
+
function parseLogLevel() {
|
|
2182
|
+
const args = process.argv.slice(2);
|
|
2183
|
+
const logLevelIndex = args.indexOf("--log-level");
|
|
2184
|
+
if (logLevelIndex === -1 || logLevelIndex === args.length - 1) {
|
|
2185
|
+
return void 0;
|
|
2186
|
+
}
|
|
2187
|
+
const level = args[logLevelIndex + 1];
|
|
2188
|
+
const validLevels = ["debug", "info", "warn", "error", "none"];
|
|
2189
|
+
if (validLevels.includes(level)) {
|
|
2190
|
+
return level;
|
|
2191
|
+
}
|
|
2192
|
+
console.error(`Invalid log level: ${level}. Valid levels: ${validLevels.join(", ")}`);
|
|
2193
|
+
return void 0;
|
|
2194
|
+
}
|
|
2195
|
+
var logLevel = parseLogLevel();
|
|
2196
|
+
if (logLevel) {
|
|
2197
|
+
setLogLevel(logLevel);
|
|
2198
|
+
}
|
|
1502
2199
|
runServer().catch((error) => {
|
|
1503
2200
|
const errorMessage = "Fatal error running server";
|
|
1504
2201
|
console.error(errorMessage, error);
|