@mastra/mcp-docs-server 0.0.3 → 0.0.4-alpha.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/%40mastra%2Fastra.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fcomposio.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +23 -23
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +35 -35
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +35 -35
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +32 -32
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +26 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +35 -35
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Frag.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fspeech-azure.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fspeech-deepgram.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fspeech-elevenlabs.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fspeech-google.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fspeech-ibm.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fspeech-murf.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fspeech-openai.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fspeech-playai.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fspeech-replicate.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fspeech-speechify.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fstabilityai.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +25 -0
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +31 -31
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +30 -30
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +25 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +27 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +26 -26
- package/.docs/organized/changelogs/create-mastra.md +22 -22
- package/.docs/organized/changelogs/mastra.md +47 -47
- package/.docs/organized/code-examples/ai-sdk-useChat.md +2 -1
- package/.docs/raw/agents/02-adding-tools.mdx +6 -0
- package/.docs/raw/agents/02a-mcp-guide.mdx +192 -0
- package/.docs/raw/agents/03-adding-voice.mdx +8 -8
- package/.docs/raw/deployment/deployment.mdx +5 -42
- package/.docs/raw/deployment/server.mdx +45 -3
- package/.docs/raw/evals/00-overview.mdx +2 -2
- package/.docs/raw/evals/03-running-in-ci.mdx +7 -4
- package/.docs/raw/getting-started/mcp-docs-server.mdx +5 -2
- package/.docs/raw/guides/04-research-assistant.mdx +273 -0
- package/.docs/raw/local-dev/mastra-dev.mdx +2 -2
- package/.docs/raw/observability/logging.mdx +38 -0
- package/.docs/raw/observability/nextjs-tracing.mdx +102 -0
- package/.docs/raw/observability/tracing.mdx +110 -0
- package/.docs/raw/rag/overview.mdx +3 -3
- package/.docs/raw/rag/retrieval.mdx +7 -4
- package/.docs/raw/rag/vector-databases.mdx +107 -40
- package/.docs/raw/reference/client-js/memory.mdx +6 -3
- package/.docs/raw/reference/client-js/workflows.mdx +1 -0
- package/.docs/raw/reference/observability/providers/langsmith.mdx +2 -0
- package/.docs/raw/reference/rag/libsql.mdx +3 -3
- package/.docs/raw/reference/rag/upstash.mdx +50 -1
- package/.docs/raw/reference/rag/vectorize.mdx +48 -3
- package/.docs/raw/reference/tools/client.mdx +10 -2
- package/.docs/raw/reference/tools/vector-query-tool.mdx +1 -1
- package/.docs/raw/reference/voice/sarvam.mdx +260 -0
- package/.docs/raw/reference/workflows/afterEvent.mdx +76 -0
- package/.docs/raw/reference/workflows/events.mdx +305 -0
- package/.docs/raw/reference/workflows/resumeWithEvent.mdx +134 -0
- package/.docs/raw/reference/workflows/snapshots.mdx +204 -0
- package/.docs/raw/reference/workflows/step-retries.mdx +203 -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/dynamic-workflows.mdx +4 -0
- package/.docs/raw/workflows/error-handling.mdx +183 -0
- package/.docs/raw/workflows/steps.mdx +12 -2
- package/.docs/raw/workflows/suspend-and-resume.mdx +207 -2
- package/.docs/raw/workflows/variables.mdx +23 -3
- package/dist/_tsup-dts-rollup.d.ts +83 -0
- package/dist/chunk-YEOOTUPA.js +191 -0
- package/dist/prepare-docs/prepare.d.ts +1 -1
- package/dist/prepare-docs/prepare.js +1 -13
- package/dist/stdio.d.ts +0 -1
- package/dist/stdio.js +352 -5
- package/package.json +9 -15
- package/.docs/raw/deployment/logging-and-tracing.mdx +0 -242
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -19
- package/dist/prepare-docs/code-examples.d.ts +0 -4
- package/dist/prepare-docs/code-examples.js +0 -91
- package/dist/prepare-docs/copy-raw.d.ts +0 -1
- package/dist/prepare-docs/copy-raw.js +0 -41
- package/dist/prepare-docs/index.d.ts +0 -1
- package/dist/prepare-docs/index.js +0 -8
- package/dist/prepare-docs/package-changes.d.ts +0 -4
- package/dist/prepare-docs/package-changes.js +0 -92
- package/dist/sse.d.ts +0 -1
- package/dist/sse.js +0 -9
- package/dist/tools/__tests__/blog.test.d.ts +0 -1
- package/dist/tools/__tests__/blog.test.js +0 -48
- package/dist/tools/__tests__/changes.test.d.ts +0 -1
- package/dist/tools/__tests__/changes.test.js +0 -37
- package/dist/tools/__tests__/docs.test.d.ts +0 -1
- package/dist/tools/__tests__/docs.test.js +0 -46
- package/dist/tools/__tests__/examples.test.d.ts +0 -1
- package/dist/tools/__tests__/examples.test.js +0 -53
- package/dist/tools/blog.d.ts +0 -15
- package/dist/tools/blog.js +0 -73
- package/dist/tools/changes.d.ts +0 -11
- package/dist/tools/changes.js +0 -69
- package/dist/tools/docs.d.ts +0 -11
- package/dist/tools/docs.js +0 -176
- package/dist/tools/examples.d.ts +0 -11
- package/dist/tools/examples.js +0 -61
- package/dist/utils.d.ts +0 -6
- package/dist/utils.js +0 -9
package/dist/tools/docs.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = path.dirname(__filename);
|
|
7
|
-
const docsBaseDir = path.join(__dirname, '../../.docs/raw/');
|
|
8
|
-
// Helper function to list contents of a directory
|
|
9
|
-
async function listDirContents(dirPath) {
|
|
10
|
-
const entries = await fs.readdir(dirPath, { withFileTypes: true });
|
|
11
|
-
const dirs = [];
|
|
12
|
-
const files = [];
|
|
13
|
-
for (const entry of entries) {
|
|
14
|
-
if (entry.isDirectory()) {
|
|
15
|
-
dirs.push(entry.name + '/');
|
|
16
|
-
}
|
|
17
|
-
else if (entry.isFile() && entry.name.endsWith('.mdx')) {
|
|
18
|
-
files.push(entry.name);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
dirs: dirs.sort(),
|
|
23
|
-
files: files.sort(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
// Helper function to read MDX files from a path
|
|
27
|
-
async function readMdxContent(docPath) {
|
|
28
|
-
const fullPath = path.join(docsBaseDir, docPath);
|
|
29
|
-
// Check if path exists
|
|
30
|
-
try {
|
|
31
|
-
const stats = await fs.stat(fullPath);
|
|
32
|
-
if (stats.isDirectory()) {
|
|
33
|
-
const { dirs, files } = await listDirContents(fullPath);
|
|
34
|
-
const dirListing = [
|
|
35
|
-
`Directory contents of ${docPath}:`,
|
|
36
|
-
'',
|
|
37
|
-
dirs.length > 0 ? 'Subdirectories:' : 'No subdirectories.',
|
|
38
|
-
...dirs.map(d => `- ${d}`),
|
|
39
|
-
'',
|
|
40
|
-
files.length > 0 ? 'Files in this directory:' : 'No files in this directory.',
|
|
41
|
-
...files.map(f => `- ${f}`),
|
|
42
|
-
'',
|
|
43
|
-
'---',
|
|
44
|
-
'',
|
|
45
|
-
'Contents of all files in this directory:',
|
|
46
|
-
'',
|
|
47
|
-
].join('\n');
|
|
48
|
-
// Append all file contents
|
|
49
|
-
let fileContents = '';
|
|
50
|
-
for (const file of files) {
|
|
51
|
-
const filePath = path.join(fullPath, file);
|
|
52
|
-
const content = await fs.readFile(filePath, 'utf-8');
|
|
53
|
-
fileContents += `\n\n# ${file}\n\n${content}`;
|
|
54
|
-
}
|
|
55
|
-
return dirListing + fileContents;
|
|
56
|
-
}
|
|
57
|
-
// If it's a file, just read it
|
|
58
|
-
return fs.readFile(fullPath, 'utf-8');
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
throw new Error(`Path not found: ${docPath}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// Helper function to find nearest existing directory and its contents
|
|
65
|
-
async function findNearestDirectory(docPath, availablePaths) {
|
|
66
|
-
// Split path into parts and try each parent directory
|
|
67
|
-
const parts = docPath.split('/');
|
|
68
|
-
while (parts.length > 0) {
|
|
69
|
-
const testPath = parts.join('/');
|
|
70
|
-
try {
|
|
71
|
-
const fullPath = path.join(docsBaseDir, testPath);
|
|
72
|
-
const stats = await fs.stat(fullPath);
|
|
73
|
-
if (stats.isDirectory()) {
|
|
74
|
-
const { dirs, files } = await listDirContents(fullPath);
|
|
75
|
-
return [
|
|
76
|
-
`Path "${docPath}" not found.`,
|
|
77
|
-
`Here are the available paths in "${testPath}":`,
|
|
78
|
-
'',
|
|
79
|
-
dirs.length > 0 ? 'Directories:' : 'No subdirectories.',
|
|
80
|
-
...dirs.map(d => `- ${testPath}/${d}`),
|
|
81
|
-
'',
|
|
82
|
-
files.length > 0 ? 'Files:' : 'No files.',
|
|
83
|
-
...files.map(f => `- ${testPath}/${f}`),
|
|
84
|
-
].join('\n');
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
catch {
|
|
88
|
-
// Directory doesn't exist, try parent
|
|
89
|
-
}
|
|
90
|
-
parts.pop();
|
|
91
|
-
}
|
|
92
|
-
// If no parent directories found, return root listing
|
|
93
|
-
return [`Path "${docPath}" not found.`, 'Here are all available paths:', '', availablePaths].join('\n');
|
|
94
|
-
}
|
|
95
|
-
// Get initial directory listing for the description
|
|
96
|
-
async function getAvailablePaths() {
|
|
97
|
-
const { dirs, files } = await listDirContents(docsBaseDir);
|
|
98
|
-
// Get reference directory contents if it exists
|
|
99
|
-
let referenceDirs = [];
|
|
100
|
-
if (dirs.includes('reference/')) {
|
|
101
|
-
const { dirs: refDirs } = await listDirContents(path.join(docsBaseDir, 'reference'));
|
|
102
|
-
referenceDirs = refDirs.map(d => `reference/${d}`);
|
|
103
|
-
}
|
|
104
|
-
return [
|
|
105
|
-
'Available top-level paths:',
|
|
106
|
-
'',
|
|
107
|
-
'Directories:',
|
|
108
|
-
...dirs.map(d => `- ${d}`),
|
|
109
|
-
'',
|
|
110
|
-
referenceDirs.length > 0 ? 'Reference subdirectories:' : '',
|
|
111
|
-
...referenceDirs.map(d => `- ${d}`),
|
|
112
|
-
'',
|
|
113
|
-
'Files:',
|
|
114
|
-
...files.map(f => `- ${f}`),
|
|
115
|
-
]
|
|
116
|
-
.filter(Boolean)
|
|
117
|
-
.join('\n');
|
|
118
|
-
}
|
|
119
|
-
// Initialize available paths
|
|
120
|
-
const availablePaths = await getAvailablePaths();
|
|
121
|
-
const docsSchema = z.object({
|
|
122
|
-
paths: z
|
|
123
|
-
.array(z.string())
|
|
124
|
-
.min(1)
|
|
125
|
-
.describe(`One or more documentation paths to fetch\nAvailable paths:\n${availablePaths}`),
|
|
126
|
-
});
|
|
127
|
-
export const docsTool = {
|
|
128
|
-
name: 'mastraDocs',
|
|
129
|
-
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',
|
|
130
|
-
parameters: docsSchema,
|
|
131
|
-
execute: async (args, _context) => {
|
|
132
|
-
try {
|
|
133
|
-
const results = await Promise.all(args.paths.map(async (path) => {
|
|
134
|
-
try {
|
|
135
|
-
const content = await readMdxContent(path);
|
|
136
|
-
return {
|
|
137
|
-
path,
|
|
138
|
-
content,
|
|
139
|
-
error: null,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
if (error instanceof Error && error.message.includes('Path not found')) {
|
|
144
|
-
const suggestions = await findNearestDirectory(path, availablePaths);
|
|
145
|
-
return {
|
|
146
|
-
path,
|
|
147
|
-
content: null,
|
|
148
|
-
error: suggestions,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
path,
|
|
153
|
-
content: null,
|
|
154
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
}));
|
|
158
|
-
// Format the results
|
|
159
|
-
const output = results
|
|
160
|
-
.map(result => {
|
|
161
|
-
if (result.error) {
|
|
162
|
-
return `## ${result.path}\n\n${result.error}\n\n---\n`;
|
|
163
|
-
}
|
|
164
|
-
return `## ${result.path}\n\n${result.content}\n\n---\n`;
|
|
165
|
-
})
|
|
166
|
-
.join('\n');
|
|
167
|
-
return output;
|
|
168
|
-
}
|
|
169
|
-
catch (error) {
|
|
170
|
-
if (error instanceof Error) {
|
|
171
|
-
throw new Error(`Failed to fetch documentation: ${error.message}`);
|
|
172
|
-
}
|
|
173
|
-
throw error;
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
};
|
package/dist/tools/examples.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Tool } from 'tylerbarnes-fastmcp-fix';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
declare const examplesSchema: z.ZodObject<{
|
|
4
|
-
example: z.ZodOptional<z.ZodString>;
|
|
5
|
-
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
example?: string | undefined;
|
|
7
|
-
}, {
|
|
8
|
-
example?: string | undefined;
|
|
9
|
-
}>;
|
|
10
|
-
export declare const examplesTool: Tool<any, typeof examplesSchema>;
|
|
11
|
-
export {};
|
package/dist/tools/examples.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = path.dirname(__filename);
|
|
7
|
-
// Helper function to list code examples
|
|
8
|
-
async function listCodeExamples() {
|
|
9
|
-
const examplesDir = path.resolve(__dirname, '../../.docs/organized/code-examples');
|
|
10
|
-
try {
|
|
11
|
-
const files = await fs.readdir(examplesDir);
|
|
12
|
-
return files
|
|
13
|
-
.filter(f => f.endsWith('.md'))
|
|
14
|
-
.map(f => ({
|
|
15
|
-
name: f.replace('.md', ''),
|
|
16
|
-
path: f,
|
|
17
|
-
}))
|
|
18
|
-
.sort((a, b) => a.name.localeCompare(b.name));
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
// Helper function to read a code example
|
|
25
|
-
async function readCodeExample(filename) {
|
|
26
|
-
const examplesDir = path.resolve(__dirname, '../../.docs/organized/code-examples');
|
|
27
|
-
const filePath = path.join(examplesDir, filename);
|
|
28
|
-
try {
|
|
29
|
-
return await fs.readFile(filePath, 'utf-8');
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
const examples = await listCodeExamples();
|
|
33
|
-
const availableExamples = examples.map(ex => `- ${ex.name}`).join('\n');
|
|
34
|
-
throw new Error(`Example "${filename}" not found.\n\nAvailable examples:\n${availableExamples}`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// Get initial examples for the description
|
|
38
|
-
const initialExamples = await listCodeExamples();
|
|
39
|
-
const examplesListing = initialExamples.length > 0
|
|
40
|
-
? '\n\nAvailable examples: ' + initialExamples.map(ex => ex.name).join(', ')
|
|
41
|
-
: '\n\nNo examples available yet. Run the documentation preparation script first.';
|
|
42
|
-
const examplesSchema = z.object({
|
|
43
|
-
example: z
|
|
44
|
-
.string()
|
|
45
|
-
.optional()
|
|
46
|
-
.describe('Name of the specific example to fetch. If not provided, lists all available examples.' + examplesListing),
|
|
47
|
-
});
|
|
48
|
-
export const examplesTool = {
|
|
49
|
-
name: 'mastraExamples',
|
|
50
|
-
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.',
|
|
51
|
-
parameters: examplesSchema,
|
|
52
|
-
execute: async (args, _context) => {
|
|
53
|
-
if (!args.example) {
|
|
54
|
-
const examples = await listCodeExamples();
|
|
55
|
-
return ['Available code examples:', '', ...examples.map(ex => `- ${ex.name}`)].join('\n');
|
|
56
|
-
}
|
|
57
|
-
const filename = args.example.endsWith('.md') ? args.example : `${args.example}.md`;
|
|
58
|
-
const content = await readCodeExample(filename);
|
|
59
|
-
return content;
|
|
60
|
-
},
|
|
61
|
-
};
|
package/dist/utils.d.ts
DELETED
package/dist/utils.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
export function fromRepoRoot(relative) {
|
|
3
|
-
return path.resolve(import.meta.dirname, `../../../`, relative);
|
|
4
|
-
}
|
|
5
|
-
export function fromPackageRoot(relative) {
|
|
6
|
-
return path.resolve(import.meta.dirname, `../`, relative);
|
|
7
|
-
}
|
|
8
|
-
// can't use console.log() because it writes to stdout which will interfere with the MCP Stdio protocol
|
|
9
|
-
export const log = console.error;
|