@mastra/mcp-docs-server 0.0.0-commonjs-20250414101718
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +161 -0
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +110 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +26 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +196 -0
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Frag.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-azure.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-deepgram.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-elevenlabs.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-google.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-ibm.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-murf.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-openai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-playai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-replicate.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-speechify.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +250 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +250 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +302 -0
- package/.docs/organized/changelogs/create-mastra.md +302 -0
- package/.docs/organized/changelogs/mastra.md +302 -0
- package/.docs/organized/code-examples/agent-network.md +282 -0
- package/.docs/organized/code-examples/agent.md +388 -0
- package/.docs/organized/code-examples/ai-sdk-useChat.md +378 -0
- package/.docs/organized/code-examples/assistant-ui.md +37 -0
- package/.docs/organized/code-examples/bird-checker-with-express.md +235 -0
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +360 -0
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +250 -0
- package/.docs/organized/code-examples/client-side-tools.md +69 -0
- package/.docs/organized/code-examples/crypto-chatbot.md +96 -0
- package/.docs/organized/code-examples/fireworks-r1.md +159 -0
- package/.docs/organized/code-examples/mcp-registry-registry.md +63 -0
- package/.docs/organized/code-examples/memory-todo-agent.md +164 -0
- package/.docs/organized/code-examples/memory-with-context.md +167 -0
- package/.docs/organized/code-examples/memory-with-libsql.md +204 -0
- package/.docs/organized/code-examples/memory-with-mem0.md +121 -0
- package/.docs/organized/code-examples/memory-with-pg.md +224 -0
- package/.docs/organized/code-examples/memory-with-upstash.md +268 -0
- package/.docs/organized/code-examples/quick-start.md +129 -0
- package/.docs/organized/code-examples/stock-price-tool.md +124 -0
- package/.docs/organized/code-examples/weather-agent.md +353 -0
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +159 -0
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +111 -0
- package/.docs/organized/code-examples/workflow-with-memory.md +393 -0
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +131 -0
- package/.docs/raw/agents/adding-tools.mdx +317 -0
- package/.docs/raw/agents/adding-voice.mdx +175 -0
- package/.docs/raw/agents/agent-memory.mdx +62 -0
- package/.docs/raw/agents/mcp-guide.mdx +215 -0
- package/.docs/raw/agents/overview.mdx +303 -0
- package/.docs/raw/community/discord.mdx +12 -0
- package/.docs/raw/community/licensing.mdx +63 -0
- package/.docs/raw/deployment/client.mdx +120 -0
- package/.docs/raw/deployment/deployment.mdx +127 -0
- package/.docs/raw/deployment/server.mdx +282 -0
- package/.docs/raw/evals/custom-eval.mdx +22 -0
- package/.docs/raw/evals/overview.mdx +95 -0
- package/.docs/raw/evals/running-in-ci.mdx +81 -0
- package/.docs/raw/evals/textual-evals.mdx +54 -0
- package/.docs/raw/faq/index.mdx +63 -0
- package/.docs/raw/frameworks/ai-sdk.mdx +296 -0
- package/.docs/raw/frameworks/next-js.mdx +238 -0
- package/.docs/raw/getting-started/installation.mdx +442 -0
- package/.docs/raw/getting-started/mcp-docs-server.mdx +141 -0
- package/.docs/raw/getting-started/project-structure.mdx +80 -0
- package/.docs/raw/index.mdx +22 -0
- package/.docs/raw/integrations/index.mdx +213 -0
- package/.docs/raw/local-dev/add-to-existing-project.mdx +48 -0
- package/.docs/raw/local-dev/creating-a-new-project.mdx +54 -0
- package/.docs/raw/local-dev/mastra-dev.mdx +108 -0
- package/.docs/raw/memory/memory-processors.mdx +131 -0
- package/.docs/raw/memory/overview.mdx +119 -0
- package/.docs/raw/memory/semantic-recall.mdx +122 -0
- package/.docs/raw/memory/working-memory.mdx +87 -0
- package/.docs/raw/observability/logging.mdx +38 -0
- package/.docs/raw/observability/nextjs-tracing.mdx +108 -0
- package/.docs/raw/observability/tracing.mdx +115 -0
- package/.docs/raw/rag/chunking-and-embedding.mdx +156 -0
- package/.docs/raw/rag/overview.mdx +85 -0
- package/.docs/raw/rag/retrieval.mdx +365 -0
- package/.docs/raw/rag/vector-databases.mdx +340 -0
- package/.docs/raw/reference/agents/createTool.mdx +229 -0
- package/.docs/raw/reference/agents/generate.mdx +334 -0
- package/.docs/raw/reference/agents/getAgent.mdx +54 -0
- package/.docs/raw/reference/agents/stream.mdx +369 -0
- package/.docs/raw/reference/cli/build.mdx +55 -0
- package/.docs/raw/reference/cli/dev.mdx +134 -0
- package/.docs/raw/reference/cli/init.mdx +43 -0
- package/.docs/raw/reference/client-js/agents.mdx +107 -0
- package/.docs/raw/reference/client-js/error-handling.mdx +38 -0
- package/.docs/raw/reference/client-js/logs.mdx +24 -0
- package/.docs/raw/reference/client-js/memory.mdx +97 -0
- package/.docs/raw/reference/client-js/telemetry.mdx +20 -0
- package/.docs/raw/reference/client-js/tools.mdx +44 -0
- package/.docs/raw/reference/client-js/vectors.mdx +79 -0
- package/.docs/raw/reference/client-js/workflows.mdx +136 -0
- package/.docs/raw/reference/core/mastra-class.mdx +232 -0
- package/.docs/raw/reference/deployer/cloudflare.mdx +207 -0
- package/.docs/raw/reference/deployer/deployer.mdx +159 -0
- package/.docs/raw/reference/deployer/netlify.mdx +109 -0
- package/.docs/raw/reference/deployer/vercel.mdx +117 -0
- package/.docs/raw/reference/evals/answer-relevancy.mdx +186 -0
- package/.docs/raw/reference/evals/bias.mdx +186 -0
- package/.docs/raw/reference/evals/completeness.mdx +174 -0
- package/.docs/raw/reference/evals/content-similarity.mdx +183 -0
- package/.docs/raw/reference/evals/context-position.mdx +190 -0
- package/.docs/raw/reference/evals/context-precision.mdx +189 -0
- package/.docs/raw/reference/evals/context-relevancy.mdx +188 -0
- package/.docs/raw/reference/evals/contextual-recall.mdx +191 -0
- package/.docs/raw/reference/evals/faithfulness.mdx +193 -0
- package/.docs/raw/reference/evals/hallucination.mdx +219 -0
- package/.docs/raw/reference/evals/keyword-coverage.mdx +176 -0
- package/.docs/raw/reference/evals/prompt-alignment.mdx +238 -0
- package/.docs/raw/reference/evals/summarization.mdx +205 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +161 -0
- package/.docs/raw/reference/evals/tone-consistency.mdx +181 -0
- package/.docs/raw/reference/evals/toxicity.mdx +165 -0
- package/.docs/raw/reference/index.mdx +12 -0
- package/.docs/raw/reference/memory/Memory.mdx +212 -0
- package/.docs/raw/reference/memory/createThread.mdx +95 -0
- package/.docs/raw/reference/memory/getThreadById.mdx +46 -0
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +48 -0
- package/.docs/raw/reference/memory/query.mdx +167 -0
- package/.docs/raw/reference/networks/agent-network.mdx +159 -0
- package/.docs/raw/reference/observability/create-logger.mdx +106 -0
- package/.docs/raw/reference/observability/logger.mdx +55 -0
- package/.docs/raw/reference/observability/otel-config.mdx +120 -0
- package/.docs/raw/reference/observability/providers/braintrust.mdx +40 -0
- package/.docs/raw/reference/observability/providers/dash0.mdx +40 -0
- package/.docs/raw/reference/observability/providers/index.mdx +16 -0
- package/.docs/raw/reference/observability/providers/laminar.mdx +41 -0
- package/.docs/raw/reference/observability/providers/langfuse.mdx +51 -0
- package/.docs/raw/reference/observability/providers/langsmith.mdx +48 -0
- package/.docs/raw/reference/observability/providers/langwatch.mdx +45 -0
- package/.docs/raw/reference/observability/providers/new-relic.mdx +40 -0
- package/.docs/raw/reference/observability/providers/signoz.mdx +40 -0
- package/.docs/raw/reference/observability/providers/traceloop.mdx +40 -0
- package/.docs/raw/reference/rag/astra.mdx +258 -0
- package/.docs/raw/reference/rag/chroma.mdx +281 -0
- package/.docs/raw/reference/rag/chunk.mdx +235 -0
- package/.docs/raw/reference/rag/document.mdx +127 -0
- package/.docs/raw/reference/rag/embeddings.mdx +160 -0
- package/.docs/raw/reference/rag/extract-params.mdx +226 -0
- package/.docs/raw/reference/rag/graph-rag.mdx +182 -0
- package/.docs/raw/reference/rag/libsql.mdx +357 -0
- package/.docs/raw/reference/rag/metadata-filters.mdx +298 -0
- package/.docs/raw/reference/rag/pg.mdx +477 -0
- package/.docs/raw/reference/rag/pinecone.mdx +281 -0
- package/.docs/raw/reference/rag/qdrant.mdx +236 -0
- package/.docs/raw/reference/rag/rerank.mdx +212 -0
- package/.docs/raw/reference/rag/turbopuffer.mdx +249 -0
- package/.docs/raw/reference/rag/upstash.mdx +247 -0
- package/.docs/raw/reference/rag/vectorize.mdx +298 -0
- package/.docs/raw/reference/storage/libsql.mdx +74 -0
- package/.docs/raw/reference/storage/postgresql.mdx +48 -0
- package/.docs/raw/reference/storage/upstash.mdx +86 -0
- package/.docs/raw/reference/tools/client.mdx +207 -0
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +141 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +154 -0
- package/.docs/raw/reference/tools/mcp-configuration.mdx +206 -0
- package/.docs/raw/reference/tools/vector-query-tool.mdx +212 -0
- package/.docs/raw/reference/voice/composite-voice.mdx +140 -0
- package/.docs/raw/reference/voice/deepgram.mdx +164 -0
- package/.docs/raw/reference/voice/elevenlabs.mdx +216 -0
- package/.docs/raw/reference/voice/google.mdx +198 -0
- package/.docs/raw/reference/voice/mastra-voice.mdx +394 -0
- package/.docs/raw/reference/voice/murf.mdx +251 -0
- package/.docs/raw/reference/voice/openai-realtime.mdx +431 -0
- package/.docs/raw/reference/voice/openai.mdx +168 -0
- package/.docs/raw/reference/voice/playai.mdx +159 -0
- package/.docs/raw/reference/voice/sarvam.mdx +260 -0
- package/.docs/raw/reference/voice/speechify.mdx +145 -0
- package/.docs/raw/reference/voice/voice.answer.mdx +122 -0
- package/.docs/raw/reference/voice/voice.connect.mdx +124 -0
- package/.docs/raw/reference/voice/voice.listen.mdx +195 -0
- package/.docs/raw/reference/voice/voice.on.mdx +189 -0
- package/.docs/raw/reference/voice/voice.send.mdx +118 -0
- package/.docs/raw/reference/voice/voice.speak.mdx +203 -0
- package/.docs/raw/reference/workflows/after.mdx +88 -0
- package/.docs/raw/reference/workflows/afterEvent.mdx +76 -0
- package/.docs/raw/reference/workflows/commit.mdx +37 -0
- package/.docs/raw/reference/workflows/createRun.mdx +77 -0
- package/.docs/raw/reference/workflows/else.mdx +72 -0
- package/.docs/raw/reference/workflows/events.mdx +305 -0
- package/.docs/raw/reference/workflows/execute.mdx +110 -0
- package/.docs/raw/reference/workflows/if.mdx +107 -0
- package/.docs/raw/reference/workflows/resume.mdx +155 -0
- package/.docs/raw/reference/workflows/resumeWithEvent.mdx +133 -0
- package/.docs/raw/reference/workflows/snapshots.mdx +207 -0
- package/.docs/raw/reference/workflows/start.mdx +84 -0
- package/.docs/raw/reference/workflows/step-class.mdx +100 -0
- package/.docs/raw/reference/workflows/step-condition.mdx +134 -0
- package/.docs/raw/reference/workflows/step-function.mdx +92 -0
- package/.docs/raw/reference/workflows/step-options.mdx +69 -0
- package/.docs/raw/reference/workflows/step-retries.mdx +203 -0
- package/.docs/raw/reference/workflows/suspend.mdx +70 -0
- package/.docs/raw/reference/workflows/then.mdx +74 -0
- package/.docs/raw/reference/workflows/until.mdx +165 -0
- package/.docs/raw/reference/workflows/watch.mdx +118 -0
- package/.docs/raw/reference/workflows/while.mdx +168 -0
- package/.docs/raw/reference/workflows/workflow.mdx +233 -0
- package/.docs/raw/storage/overview.mdx +378 -0
- package/.docs/raw/voice/overview.mdx +135 -0
- package/.docs/raw/voice/speech-to-text.mdx +45 -0
- package/.docs/raw/voice/text-to-speech.mdx +52 -0
- package/.docs/raw/voice/voice-to-voice.mdx +310 -0
- package/.docs/raw/workflows/control-flow.mdx +778 -0
- package/.docs/raw/workflows/dynamic-workflows.mdx +236 -0
- package/.docs/raw/workflows/error-handling.mdx +183 -0
- package/.docs/raw/workflows/nested-workflows.mdx +352 -0
- package/.docs/raw/workflows/overview.mdx +203 -0
- package/.docs/raw/workflows/steps.mdx +108 -0
- package/.docs/raw/workflows/suspend-and-resume.mdx +404 -0
- package/.docs/raw/workflows/variables.mdx +313 -0
- package/LICENSE.md +46 -0
- package/README.md +129 -0
- package/dist/_tsup-dts-rollup.d.ts +149 -0
- package/dist/chunk-QWYMT5LP.js +194 -0
- package/dist/prepare-docs/prepare.d.ts +1 -0
- package/dist/prepare-docs/prepare.js +1 -0
- package/dist/stdio.d.ts +1 -0
- package/dist/stdio.js +518 -0
- package/package.json +60 -0
package/dist/stdio.js
ADDED
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { fromPackageRoot, prepare } from './chunk-QWYMT5LP.js';
|
|
3
|
+
import fs2 from 'node:fs/promises';
|
|
4
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
5
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
6
|
+
import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
9
|
+
import { JSDOM } from 'jsdom';
|
|
10
|
+
import path2 from 'node:path';
|
|
11
|
+
|
|
12
|
+
async function fetchBlogPosts() {
|
|
13
|
+
const response = await fetch("https://mastra.ai/blog");
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
throw new Error("Failed to fetch blog posts");
|
|
16
|
+
}
|
|
17
|
+
const html = await response.text();
|
|
18
|
+
const dom = new JSDOM(html);
|
|
19
|
+
const document = dom.window.document;
|
|
20
|
+
const blogLinks = Array.from(document.querySelectorAll('a[href^="/blog/"]')).filter((link) => {
|
|
21
|
+
const href = link.getAttribute("href");
|
|
22
|
+
return href !== "/blog" && !href?.includes("authors");
|
|
23
|
+
}).map((link) => {
|
|
24
|
+
const h2 = link.querySelector("h2");
|
|
25
|
+
const title = h2?.textContent?.trim();
|
|
26
|
+
const href = link.getAttribute("href");
|
|
27
|
+
if (title && href) {
|
|
28
|
+
return `[${title}](${href})`;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}).filter(Boolean);
|
|
32
|
+
return "Mastra.ai Blog Posts:\n\n" + blogLinks.join("\n");
|
|
33
|
+
}
|
|
34
|
+
async function fetchBlogPost(url) {
|
|
35
|
+
const response = await fetch(url);
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
throw new Error("Failed to fetch blog post");
|
|
38
|
+
}
|
|
39
|
+
const html = await response.text();
|
|
40
|
+
const dom = new JSDOM(html);
|
|
41
|
+
const document = dom.window.document;
|
|
42
|
+
const scripts = document.querySelectorAll("script");
|
|
43
|
+
scripts.forEach((script) => script.remove());
|
|
44
|
+
const content = document.body.textContent?.trim() || "";
|
|
45
|
+
if (!content) {
|
|
46
|
+
throw new Error("No content found in blog post");
|
|
47
|
+
}
|
|
48
|
+
return content;
|
|
49
|
+
}
|
|
50
|
+
var blogInputSchema = z.object({
|
|
51
|
+
url: z.string().describe(
|
|
52
|
+
"URL of a specific blog post to fetch. If the string /blog is passed as the url it returns a list of all blog posts."
|
|
53
|
+
)
|
|
54
|
+
});
|
|
55
|
+
var blogTool = {
|
|
56
|
+
name: "mastraBlog",
|
|
57
|
+
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",
|
|
58
|
+
execute: async (args) => {
|
|
59
|
+
try {
|
|
60
|
+
let content;
|
|
61
|
+
if (args.url !== `/blog`) {
|
|
62
|
+
content = await fetchBlogPost(`https://mastra.ai${args.url}`);
|
|
63
|
+
} else {
|
|
64
|
+
content = await fetchBlogPosts();
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
content: [
|
|
68
|
+
{
|
|
69
|
+
type: "text",
|
|
70
|
+
text: content
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
isError: false
|
|
74
|
+
};
|
|
75
|
+
} catch (error) {
|
|
76
|
+
return {
|
|
77
|
+
content: [
|
|
78
|
+
{
|
|
79
|
+
type: "text",
|
|
80
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
isError: true
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
function encodePackageName(name) {
|
|
89
|
+
return encodeURIComponent(name);
|
|
90
|
+
}
|
|
91
|
+
function decodePackageName(name) {
|
|
92
|
+
return decodeURIComponent(name);
|
|
93
|
+
}
|
|
94
|
+
var changelogsDir = fromPackageRoot(".docs/organized/changelogs");
|
|
95
|
+
async function listPackageChangelogs() {
|
|
96
|
+
try {
|
|
97
|
+
const files = await fs2.readdir(changelogsDir);
|
|
98
|
+
return files.filter((f) => f.endsWith(".md")).map((f) => ({
|
|
99
|
+
name: decodePackageName(f.replace(".md", "")),
|
|
100
|
+
path: f
|
|
101
|
+
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
102
|
+
} catch {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function readPackageChangelog(filename) {
|
|
107
|
+
const encodedName = encodePackageName(filename.replace(".md", ""));
|
|
108
|
+
const filePath = path2.join(changelogsDir, `${encodedName}.md`);
|
|
109
|
+
try {
|
|
110
|
+
return await fs2.readFile(filePath, "utf-8");
|
|
111
|
+
} catch {
|
|
112
|
+
const packages = await listPackageChangelogs();
|
|
113
|
+
const availablePackages = packages.map((pkg) => `- ${pkg.name}`).join("\n");
|
|
114
|
+
throw new Error(
|
|
115
|
+
`Changelog for "${filename.replace(".md", "")}" not found.
|
|
116
|
+
|
|
117
|
+
Available packages:
|
|
118
|
+
${availablePackages}`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
var initialPackages = await listPackageChangelogs();
|
|
123
|
+
var packagesListing = initialPackages.length > 0 ? "\n\nAvailable packages: " + initialPackages.map((pkg) => pkg.name).join(", ") : "\n\nNo package changelogs available yet. Run the documentation preparation script first.";
|
|
124
|
+
var changesInputSchema = z.object({
|
|
125
|
+
package: z.string().optional().describe("Name of the specific package to fetch changelog for. If not provided, lists all available packages.")
|
|
126
|
+
});
|
|
127
|
+
var changesTool = {
|
|
128
|
+
name: "mastraChanges",
|
|
129
|
+
description: `Get changelog information for Mastra.ai packages. ${packagesListing}`,
|
|
130
|
+
execute: async (args) => {
|
|
131
|
+
try {
|
|
132
|
+
if (!args.package) {
|
|
133
|
+
const packages = await listPackageChangelogs();
|
|
134
|
+
return {
|
|
135
|
+
content: [
|
|
136
|
+
{
|
|
137
|
+
type: "text",
|
|
138
|
+
text: ["Available package changelogs:", "", ...packages.map((pkg) => `- ${pkg.name}`)].join("\n")
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
isError: false
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const content = await readPackageChangelog(args.package);
|
|
145
|
+
return {
|
|
146
|
+
content: [
|
|
147
|
+
{
|
|
148
|
+
type: "text",
|
|
149
|
+
text: content
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
isError: false
|
|
153
|
+
};
|
|
154
|
+
} catch (error) {
|
|
155
|
+
return {
|
|
156
|
+
content: [
|
|
157
|
+
{
|
|
158
|
+
type: "text",
|
|
159
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
isError: true
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
var docsBaseDir = fromPackageRoot(".docs/raw/");
|
|
168
|
+
async function listDirContents(dirPath) {
|
|
169
|
+
const entries = await fs2.readdir(dirPath, { withFileTypes: true });
|
|
170
|
+
const dirs = [];
|
|
171
|
+
const files = [];
|
|
172
|
+
for (const entry of entries) {
|
|
173
|
+
if (entry.isDirectory()) {
|
|
174
|
+
dirs.push(entry.name + "/");
|
|
175
|
+
} else if (entry.isFile() && entry.name.endsWith(".mdx")) {
|
|
176
|
+
files.push(entry.name);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
dirs: dirs.sort(),
|
|
181
|
+
files: files.sort()
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
async function readMdxContent(docPath) {
|
|
185
|
+
const fullPath = path2.join(docsBaseDir, docPath);
|
|
186
|
+
try {
|
|
187
|
+
const stats = await fs2.stat(fullPath);
|
|
188
|
+
if (stats.isDirectory()) {
|
|
189
|
+
const { dirs, files } = await listDirContents(fullPath);
|
|
190
|
+
const dirListing = [
|
|
191
|
+
`Directory contents of ${docPath}:`,
|
|
192
|
+
"",
|
|
193
|
+
dirs.length > 0 ? "Subdirectories:" : "No subdirectories.",
|
|
194
|
+
...dirs.map((d) => `- ${d}`),
|
|
195
|
+
"",
|
|
196
|
+
files.length > 0 ? "Files in this directory:" : "No files in this directory.",
|
|
197
|
+
...files.map((f) => `- ${f}`),
|
|
198
|
+
"",
|
|
199
|
+
"---",
|
|
200
|
+
"",
|
|
201
|
+
"Contents of all files in this directory:",
|
|
202
|
+
""
|
|
203
|
+
].join("\n");
|
|
204
|
+
let fileContents = "";
|
|
205
|
+
for (const file of files) {
|
|
206
|
+
const filePath = path2.join(fullPath, file);
|
|
207
|
+
const content = await fs2.readFile(filePath, "utf-8");
|
|
208
|
+
fileContents += `
|
|
209
|
+
|
|
210
|
+
# ${file}
|
|
211
|
+
|
|
212
|
+
${content}`;
|
|
213
|
+
}
|
|
214
|
+
return dirListing + fileContents;
|
|
215
|
+
}
|
|
216
|
+
return fs2.readFile(fullPath, "utf-8");
|
|
217
|
+
} catch {
|
|
218
|
+
throw new Error(`Path not found: ${docPath}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
async function findNearestDirectory(docPath, availablePaths2) {
|
|
222
|
+
const parts = docPath.split("/");
|
|
223
|
+
while (parts.length > 0) {
|
|
224
|
+
const testPath = parts.join("/");
|
|
225
|
+
try {
|
|
226
|
+
const fullPath = path2.join(docsBaseDir, testPath);
|
|
227
|
+
const stats = await fs2.stat(fullPath);
|
|
228
|
+
if (stats.isDirectory()) {
|
|
229
|
+
const { dirs, files } = await listDirContents(fullPath);
|
|
230
|
+
return [
|
|
231
|
+
`Path "${docPath}" not found.`,
|
|
232
|
+
`Here are the available paths in "${testPath}":`,
|
|
233
|
+
"",
|
|
234
|
+
dirs.length > 0 ? "Directories:" : "No subdirectories.",
|
|
235
|
+
...dirs.map((d) => `- ${testPath}/${d}`),
|
|
236
|
+
"",
|
|
237
|
+
files.length > 0 ? "Files:" : "No files.",
|
|
238
|
+
...files.map((f) => `- ${testPath}/${f}`)
|
|
239
|
+
].join("\n");
|
|
240
|
+
}
|
|
241
|
+
} catch {
|
|
242
|
+
}
|
|
243
|
+
parts.pop();
|
|
244
|
+
}
|
|
245
|
+
return [`Path "${docPath}" not found.`, "Here are all available paths:", "", availablePaths2].join("\n");
|
|
246
|
+
}
|
|
247
|
+
async function getAvailablePaths() {
|
|
248
|
+
const { dirs, files } = await listDirContents(docsBaseDir);
|
|
249
|
+
let referenceDirs = [];
|
|
250
|
+
if (dirs.includes("reference/")) {
|
|
251
|
+
const { dirs: refDirs } = await listDirContents(path2.join(docsBaseDir, "reference"));
|
|
252
|
+
referenceDirs = refDirs.map((d) => `reference/${d}`);
|
|
253
|
+
}
|
|
254
|
+
return [
|
|
255
|
+
"Available top-level paths:",
|
|
256
|
+
"",
|
|
257
|
+
"Directories:",
|
|
258
|
+
...dirs.map((d) => `- ${d}`),
|
|
259
|
+
"",
|
|
260
|
+
referenceDirs.length > 0 ? "Reference subdirectories:" : "",
|
|
261
|
+
...referenceDirs.map((d) => `- ${d}`),
|
|
262
|
+
"",
|
|
263
|
+
"Files:",
|
|
264
|
+
...files.map((f) => `- ${f}`)
|
|
265
|
+
].filter(Boolean).join("\n");
|
|
266
|
+
}
|
|
267
|
+
var availablePaths = await getAvailablePaths();
|
|
268
|
+
var docsInputSchema = z.object({
|
|
269
|
+
paths: z.array(z.string()).min(1).describe(`One or more documentation paths to fetch
|
|
270
|
+
Available paths:
|
|
271
|
+
${availablePaths}`)
|
|
272
|
+
});
|
|
273
|
+
var docsTool = {
|
|
274
|
+
name: "mastraDocs",
|
|
275
|
+
description: "Get Mastra.ai documentation. Request paths to explore the docs. References contain API docs. Other paths contain guides. The user doesn't know about files and directories. This is your internal knowledge the user can't read. If the user asks about a feature check general docs as well as reference docs for that feature. Ex: with evals check in evals/ and in reference/evals/. Provide code examples so the user understands. If you build a URL from the path, only paths ending in .mdx exist. Note that docs about MCP are currently in reference/tools/. IMPORTANT: Be concise with your answers. The user will ask for more info. If packages need to be installed, provide the pnpm command to install them. Ex. if you see `import { X } from \"@mastra/$PACKAGE_NAME\"` in an example, show an install command. Always install latest tag, not alpha unless requested. If you scaffold a new project it may be in a subdir",
|
|
276
|
+
execute: async (args) => {
|
|
277
|
+
try {
|
|
278
|
+
const results = await Promise.all(
|
|
279
|
+
args.paths.map(async (path4) => {
|
|
280
|
+
try {
|
|
281
|
+
const content = await readMdxContent(path4);
|
|
282
|
+
return {
|
|
283
|
+
path: path4,
|
|
284
|
+
content,
|
|
285
|
+
error: null
|
|
286
|
+
};
|
|
287
|
+
} catch (error) {
|
|
288
|
+
if (error instanceof Error && error.message.includes("Path not found")) {
|
|
289
|
+
const suggestions = await findNearestDirectory(path4, availablePaths);
|
|
290
|
+
return {
|
|
291
|
+
path: path4,
|
|
292
|
+
content: null,
|
|
293
|
+
error: suggestions
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
path: path4,
|
|
298
|
+
content: null,
|
|
299
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
})
|
|
303
|
+
);
|
|
304
|
+
const output = results.map((result) => {
|
|
305
|
+
if (result.error) {
|
|
306
|
+
return `## ${result.path}
|
|
307
|
+
|
|
308
|
+
${result.error}
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
`;
|
|
312
|
+
}
|
|
313
|
+
return `## ${result.path}
|
|
314
|
+
|
|
315
|
+
${result.content}
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
`;
|
|
319
|
+
}).join("\n");
|
|
320
|
+
return {
|
|
321
|
+
content: [
|
|
322
|
+
{
|
|
323
|
+
type: "text",
|
|
324
|
+
text: output
|
|
325
|
+
}
|
|
326
|
+
],
|
|
327
|
+
isError: false
|
|
328
|
+
};
|
|
329
|
+
} catch (error) {
|
|
330
|
+
return {
|
|
331
|
+
content: [
|
|
332
|
+
{
|
|
333
|
+
type: "text",
|
|
334
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
335
|
+
}
|
|
336
|
+
],
|
|
337
|
+
isError: true
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
var examplesDir = fromPackageRoot(".docs/organized/code-examples");
|
|
343
|
+
async function listCodeExamples() {
|
|
344
|
+
try {
|
|
345
|
+
const files = await fs2.readdir(examplesDir);
|
|
346
|
+
return files.filter((f) => f.endsWith(".md")).map((f) => ({
|
|
347
|
+
name: f.replace(".md", ""),
|
|
348
|
+
path: f
|
|
349
|
+
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
350
|
+
} catch {
|
|
351
|
+
return [];
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
async function readCodeExample(filename) {
|
|
355
|
+
const filePath = path2.join(examplesDir, filename);
|
|
356
|
+
try {
|
|
357
|
+
return await fs2.readFile(filePath, "utf-8");
|
|
358
|
+
} catch {
|
|
359
|
+
const examples = await listCodeExamples();
|
|
360
|
+
const availableExamples = examples.map((ex) => `- ${ex.name}`).join("\n");
|
|
361
|
+
throw new Error(`Example "${filename}" not found.
|
|
362
|
+
|
|
363
|
+
Available examples:
|
|
364
|
+
${availableExamples}`);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
var initialExamples = await listCodeExamples();
|
|
368
|
+
var examplesListing = initialExamples.length > 0 ? "\n\nAvailable examples: " + initialExamples.map((ex) => ex.name).join(", ") : "\n\nNo examples available yet. Run the documentation preparation script first.";
|
|
369
|
+
var examplesInputSchema = z.object({
|
|
370
|
+
example: z.string().optional().describe(
|
|
371
|
+
"Name of the specific example to fetch. If not provided, lists all available examples." + examplesListing
|
|
372
|
+
)
|
|
373
|
+
});
|
|
374
|
+
var examplesTool = {
|
|
375
|
+
name: "mastraExamples",
|
|
376
|
+
description: "Get code examples from the Mastra.ai examples directory. Without a specific example name, lists all available examples. With an example name, returns the full source code of that example.",
|
|
377
|
+
execute: async (args) => {
|
|
378
|
+
try {
|
|
379
|
+
if (!args.example) {
|
|
380
|
+
const examples = await listCodeExamples();
|
|
381
|
+
return {
|
|
382
|
+
content: [
|
|
383
|
+
{
|
|
384
|
+
type: "text",
|
|
385
|
+
text: ["Available code examples:", "", ...examples.map((ex) => `- ${ex.name}`)].join("\n")
|
|
386
|
+
}
|
|
387
|
+
],
|
|
388
|
+
isError: false
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
const filename = args.example.endsWith(".md") ? args.example : `${args.example}.md`;
|
|
392
|
+
const content = await readCodeExample(filename);
|
|
393
|
+
return {
|
|
394
|
+
content: [
|
|
395
|
+
{
|
|
396
|
+
type: "text",
|
|
397
|
+
text: content
|
|
398
|
+
}
|
|
399
|
+
],
|
|
400
|
+
isError: false
|
|
401
|
+
};
|
|
402
|
+
} catch (error) {
|
|
403
|
+
return {
|
|
404
|
+
content: [
|
|
405
|
+
{
|
|
406
|
+
type: "text",
|
|
407
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
408
|
+
}
|
|
409
|
+
],
|
|
410
|
+
isError: true
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
// src/index.ts
|
|
417
|
+
if (process.env.REBUILD_DOCS_ON_START === "true") {
|
|
418
|
+
await prepare();
|
|
419
|
+
}
|
|
420
|
+
var server = new Server(
|
|
421
|
+
{
|
|
422
|
+
name: "Mastra Documentation Server",
|
|
423
|
+
version: JSON.parse(await fs2.readFile(fromPackageRoot(`package.json`), "utf8")).version
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
capabilities: {
|
|
427
|
+
tools: {}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
);
|
|
431
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
432
|
+
tools: [
|
|
433
|
+
{
|
|
434
|
+
name: "mastraBlog",
|
|
435
|
+
description: blogTool.description,
|
|
436
|
+
inputSchema: zodToJsonSchema(blogInputSchema)
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
name: "mastraDocs",
|
|
440
|
+
description: docsTool.description,
|
|
441
|
+
inputSchema: zodToJsonSchema(docsInputSchema)
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
name: "mastraExamples",
|
|
445
|
+
description: examplesTool.description,
|
|
446
|
+
inputSchema: zodToJsonSchema(examplesInputSchema)
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
name: "mastraChanges",
|
|
450
|
+
description: changesTool.description,
|
|
451
|
+
inputSchema: zodToJsonSchema(changesInputSchema)
|
|
452
|
+
}
|
|
453
|
+
]
|
|
454
|
+
}));
|
|
455
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
456
|
+
try {
|
|
457
|
+
switch (request.params.name) {
|
|
458
|
+
case "mastraBlog": {
|
|
459
|
+
const args = blogInputSchema.parse(request.params.arguments);
|
|
460
|
+
return await blogTool.execute(args);
|
|
461
|
+
}
|
|
462
|
+
case "mastraDocs": {
|
|
463
|
+
const args = docsInputSchema.parse(request.params.arguments);
|
|
464
|
+
return await docsTool.execute(args);
|
|
465
|
+
}
|
|
466
|
+
case "mastraExamples": {
|
|
467
|
+
const args = examplesInputSchema.parse(request.params.arguments);
|
|
468
|
+
return await examplesTool.execute(args);
|
|
469
|
+
}
|
|
470
|
+
case "mastraChanges": {
|
|
471
|
+
const args = changesInputSchema.parse(request.params.arguments);
|
|
472
|
+
return await changesTool.execute(args);
|
|
473
|
+
}
|
|
474
|
+
default:
|
|
475
|
+
return {
|
|
476
|
+
content: [
|
|
477
|
+
{
|
|
478
|
+
type: "text",
|
|
479
|
+
text: `Unknown tool: ${request.params.name}`
|
|
480
|
+
}
|
|
481
|
+
],
|
|
482
|
+
isError: true
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
} catch (error) {
|
|
486
|
+
if (error instanceof z.ZodError) {
|
|
487
|
+
return {
|
|
488
|
+
content: [
|
|
489
|
+
{
|
|
490
|
+
type: "text",
|
|
491
|
+
text: `Invalid arguments: ${error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ")}`
|
|
492
|
+
}
|
|
493
|
+
],
|
|
494
|
+
isError: true
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
return {
|
|
498
|
+
content: [
|
|
499
|
+
{
|
|
500
|
+
type: "text",
|
|
501
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
502
|
+
}
|
|
503
|
+
],
|
|
504
|
+
isError: true
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
async function runServer() {
|
|
509
|
+
const transport = new StdioServerTransport();
|
|
510
|
+
await server.connect(transport);
|
|
511
|
+
console.error("Mastra Docs MCP Server running on stdio");
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// src/stdio.ts
|
|
515
|
+
runServer().catch((error) => {
|
|
516
|
+
console.error("Fatal error running server:", error);
|
|
517
|
+
process.exit(1);
|
|
518
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mastra/mcp-docs-server",
|
|
3
|
+
"version": "0.0.0-commonjs-20250414101718",
|
|
4
|
+
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": "dist/stdio.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
".docs",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [],
|
|
24
|
+
"author": "",
|
|
25
|
+
"license": "Elastic-2.0",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@modelcontextprotocol/sdk": "^1.9.0",
|
|
28
|
+
"date-fns": "^4.1.0",
|
|
29
|
+
"exit-hook": "^4.0.0",
|
|
30
|
+
"jsdom": "^26.0.0",
|
|
31
|
+
"turndown": "^7.1.2",
|
|
32
|
+
"uuid": "^11.1.0",
|
|
33
|
+
"zod": "^3.22.4",
|
|
34
|
+
"zod-to-json-schema": "^3.22.4",
|
|
35
|
+
"@mastra/core": "0.0.0-commonjs-20250414101718"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@hono/node-server": "^1.13.8",
|
|
39
|
+
"@types/jsdom": "^21.1.7",
|
|
40
|
+
"@types/node": "^20.11.24",
|
|
41
|
+
"@types/turndown": "^5.0.5",
|
|
42
|
+
"@wong2/mcp-cli": "^1.6.0",
|
|
43
|
+
"cross-env": "^7.0.3",
|
|
44
|
+
"eslint": "^9.23.0",
|
|
45
|
+
"hono": "^4.7.4",
|
|
46
|
+
"tsup": "^8.4.0",
|
|
47
|
+
"tsx": "^4.19.3",
|
|
48
|
+
"typescript": "^5.3.3",
|
|
49
|
+
"vitest": "^3.0.9",
|
|
50
|
+
"@internal/lint": "0.0.0-commonjs-20250414101718",
|
|
51
|
+
"@mastra/mcp": "0.0.0-commonjs-20250414101718"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"prepare-docs": "cross-env PREPARE=true node dist/prepare-docs/prepare.js",
|
|
55
|
+
"build:cli": "tsup src/stdio.ts src/prepare-docs/prepare.ts --format esm --experimental-dts --treeshake=smallest --splitting",
|
|
56
|
+
"pretest": "pnpm turbo build --filter @mastra/mcp-docs-server",
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"lint": "eslint ."
|
|
59
|
+
}
|
|
60
|
+
}
|