mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-19 17:41:26 +02:00
feat(api): MCP server endpoint — expose AI tools to external clients
Mount an MCP (Model Context Protocol) server at /api/v1/mcp in the
unified Hono API. External clients like Claude Desktop, Cursor, and
VS Code Copilot can discover and call all 29 Mana tools via the
standard MCP protocol.
Architecture:
- WebStandardStreamableHTTPServerTransport for Bun/Hono compatibility
- AI_TOOL_CATALOG → MCP tool definitions with JSON Schema (via Zod)
- Stateful sessions with Mcp-Session-Id header
- Auth via existing authMiddleware (JWT or API key)
Phase 1 scope: tools/list returns all 29 tools with schemas,
tools/call acknowledges with descriptive messages. Phase 2 will add
actual DB reads/writes via sync_changes.
Usage:
Claude Desktop config:
{"mcpServers": {"mana": {"url": "http://localhost:3060/api/v1/mcp"}}}
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
827b252090
commit
db4dd437bd
6 changed files with 508 additions and 5 deletions
|
|
@ -15,6 +15,9 @@ import {
|
|||
rateLimitMiddleware,
|
||||
} from '@mana/shared-hono';
|
||||
|
||||
// MCP server
|
||||
import { handleMcpRequest } from './mcp/server';
|
||||
|
||||
// Module routes
|
||||
import { calendarRoutes } from './modules/calendar/routes';
|
||||
import { contactsRoutes } from './modules/contacts/routes';
|
||||
|
|
@ -48,6 +51,10 @@ app.route('/health', healthRoute('mana-api'));
|
|||
app.use('/api/*', rateLimitMiddleware({ max: 200, windowMs: 60_000 }));
|
||||
app.use('/api/*', authMiddleware());
|
||||
|
||||
// ─── MCP Endpoint ──────────────────────────────────────────
|
||||
// Streamable HTTP transport: POST (messages), GET (SSE stream), DELETE (close)
|
||||
app.all('/api/v1/mcp', (c) => handleMcpRequest(c.req.raw));
|
||||
|
||||
// ─── Module Routes ──────────────────────────────────────────
|
||||
app.route('/api/v1/calendar', calendarRoutes);
|
||||
app.route('/api/v1/contacts', contactsRoutes);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue