一键导入
mastra-mcp
Configure Mastra as MCP Server to expose agents and tools via Model Context Protocol. Enables Claude Desktop and other MCP clients to use Mastra tools.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Configure Mastra as MCP Server to expose agents and tools via Model Context Protocol. Enables Claude Desktop and other MCP clients to use Mastra tools.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Cross-project audit and sync. Backs up, bootstraps, promotes, syncs, and verifies all downstream projects.
Structured pre-planning research. Explores codebase, asks clarifying questions, and produces a brainstorm output file for /plan-feature input.
Capture knowledge from development sessions. Debug patterns, architecture decisions, framework gotchas, and integration learnings compound over time.
Load project context and show current status. Use at the start of a session or when context is needed.
Run parallel code reviews using specialized agents (security, performance, simplicity, nextjs-react). Produces a structured report.
Initialize a new project from Agent Kit boilerplate. Use when creating a new downstream project.
| name | mastra-mcp |
| description | Configure Mastra as MCP Server to expose agents and tools via Model Context Protocol. Enables Claude Desktop and other MCP clients to use Mastra tools. |
| disable-model-invocation | true |
| allowed-tools | Read, Write, Bash, Glob, Grep |
| argument-hint | ["setup|client|server|claude-config"] |
Konfiguriere Mastra als MCP Server oder Client für das Model Context Protocol.
┌─────────────────────────────────────────────────────────────────────┐
│ MASTRA MCP ARCHITECTURE │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ MCP SERVER MODE MCP CLIENT MODE │
│ ────────────── ──────────────── │
│ Mastra → exposes tools Mastra → uses external tools │
│ to MCP clients from MCP servers │
│ │
│ ┌─────────────┐ ┌─────────────┐ │
│ │ Mastra │ │ External │ │
│ │ Tools │─────────────────►│ MCP │ │
│ │ Agents │ MCP Protocol │ Server │ │
│ └─────────────┘ └─────────────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌─────────────┐ ┌─────────────┐ │
│ │ Claude │ │ Mastra │ │
│ │ Desktop │ │ Agent │ │
│ └─────────────┘ └─────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────┘
# In deinem Mastra-Projekt
pnpm add @mastra/mcp
/mastra-mcp setupVollständige MCP-Konfiguration für ein Mastra-Projekt einrichten.
Was wird erstellt:
src/mcp-server.ts)claude_desktop_config.json)mcp:serve)/mastra-mcp serverMCP Server Code für Mastra Tools generieren.
/mastra-mcp client [server-url]MCP Client konfigurieren um externe Tools zu nutzen.
/mastra-mcp claude-configClaude Desktop Konfiguration für den lokalen MCP Server generieren.
Exponiere deine Mastra Tools als MCP Server für Claude Desktop und andere Clients.
Erstelle src/mcp-server.ts:
/**
* Mastra MCP Server
*
* Exposes Mastra tools via Model Context Protocol.
* Use with Claude Desktop or any MCP-compatible client.
*/
import { MCPServer } from '@mastra/mcp/server';
import { tools } from './tools';
const server = new MCPServer({
name: 'mastra-tools',
version: '1.0.0',
tools: Object.values(tools),
});
// Stdio transport for Claude Desktop
server.start();
{
"scripts": {
"mcp:serve": "bun run src/mcp-server.ts"
}
}
Pfad: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
{
"mcpServers": {
"mastra-tools": {
"command": "bun",
"args": ["run", "mcp:serve"],
"cwd": "/path/to/your/mastra/project"
}
}
}
Nutze externe MCP Server Tools in deinen Mastra Agents.
import { MCPClient } from '@mastra/mcp';
// Stdio Transport (lokales CLI Tool)
const localClient = new MCPClient({
command: 'npx',
args: ['-y', '@anthropic/mcp-server-filesystem'],
});
// HTTP Transport (Remote Server)
const remoteClient = new MCPClient({
url: 'https://mcp-server.example.com/api',
});
// Tools entdecken
const tools = await client.getTools();
// In Agent verwenden
const agent = new Agent({
tools: {
...tools,
// eigene Tools
},
});
Nach /mastra-mcp setup:
mastra/
├── src/
│ ├── index.ts # Hauptserver
│ ├── mcp-server.ts # MCP Server Entry Point
│ ├── tools/
│ │ └── index.ts # Exportierte Tools
│ └── agents/
│ └── assistant.ts # Agent Definition
│
├── claude_desktop_config.json # Claude Config (kopieren!)
└── package.json # Mit mcp:serve Script
// Server startet via command line
// Input/Output über stdin/stdout
const server = new MCPServer({ ... });
server.start(); // Stdio mode
// Server über HTTP
// Protocol version 2025-03-26
const server = new MCPServer({
transport: 'http',
port: 3100,
});
// Server-Sent Events
// Protocol version 2024-11-05
// Fallback wenn HTTP Streamable nicht funktioniert
# Filesystem Access
npx @anthropic/mcp-server-filesystem
# Git Operations
npx @anthropic/mcp-server-git
# Memory/Knowledge Base
npx @anthropic/mcp-server-memory
# n8n Workflows
npx @anthropic-ai/mcp-server-n8n
# Notion
npx @anthropic-ai/mcp-server-notion
# Slack
npx @anthropic-ai/mcp-server-slack
# MCP Server mit Debug Output starten
DEBUG=mastra:mcp bun run mcp:serve
# macOS
tail -f ~/Library/Logs/Claude/mcp*.log
# MCP Inspector Tool
npx @modelcontextprotocol/inspector stdio bun run mcp:serve
❌ Ein großes "do_everything" Tool
✅ Kleine, fokussierte Tools
// Zod Schemas für robuste Validation
inputSchema: z.object({
query: z.string().min(1).max(1000),
limit: z.number().int().min(1).max(100).default(10),
}),
execute: async (args) => {
try {
// Tool logic
} catch (error) {
return {
error: true,
message: error instanceof Error ? error.message : 'Unknown error',
};
}
},
Tools sollten bei mehrfachem Aufruf
mit gleichen Parametern das gleiche
Ergebnis liefern.