.claude/skills/mastra-mcp/SKILL.md
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.
npx skillsauth add lucidlabs-hq/agent-kit mastra-mcpInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
development
Deploy invoice-accounting-assistant to HQ server. Runs tests first (TDD), then builds and deploys. Use when ready to push changes to staging/production.
testing
Visual UI verification with agent-browser. Use after implementing UI components to take screenshots, verify interactions, and self-check your work. FASTER than E2E tests.
documentation
Update README with current project status and features. Use after completing features.
tools
--- name: time-report description: Cross-project time report. Aggregates all session data from ~/.claude-time/sessions/. Use to see how much time was spent across all projects. disable-model-invocation: true allowed-tools: Bash, Read argument-hint: [all | this-week | this-month | last-month | {project-name}] --- # Time Report: Cross-Project Session Overview ## Objective Read ALL session files from `~/.claude-time/sessions/*.json` and produce an aggregated time report. Supports filtering by pe