import { useState } from 'react'; import { useQuery } from '@tanstack/react-query'; import { apiFetch } from '../../lib/api'; import { useLayoutContext } from '../Layout'; type Project = { id: string; name: string }; export default function McpIntegration({ project }: { project: Project }) { const [copied, setCopied] = useState(null); const { onOpenSettings } = useLayoutContext(); const mcpHost = window.location.hostname; const mcpUrl = `http://${mcpHost}:3001/mcp/${project.id}`; const { data: keyStatus } = useQuery({ queryKey: ['api-key-status'], queryFn: () => apiFetch<{ hasKey: boolean; prefix: string | null }>('/auth/api-key/status'), }); const serverName = project.name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/(^-|-$)/g, ''); const configSnippet = JSON.stringify({ mcpServers: { [serverName]: { type: 'http', url: mcpUrl, headers: { Authorization: 'Bearer ' }, }, }, }, null, 2); const copyText = (text: string, key: string) => { navigator.clipboard.writeText(text); setCopied(key); setTimeout(() => setCopied(null), 2000); }; return (
{/* MCP URL */}

MCP Service URL

Connect your LLM client to this endpoint.

{mcpUrl}
{/* Config snippet */}

Configuration for Claude Code / Cursor

Add this to your MCP client configuration.

{configSnippet}
{/* API Key guidance */} {keyStatus && (
{keyStatus.hasKey ? (

API key generated. Copy it from{' '} {' '}and replace <your-api-key> above.

) : (

You need to generate an API key before using MCP.

)}
)}
{/* Available tools */}

Available MCP Tools

5 tools for progressive drill-down, designed for minimal token usage.

{[ { name: 'get_project_overview', desc: 'Get project name, version, base URL, and module summary. Call this first.', num: '1' }, { name: 'list_modules', desc: 'List all modules with descriptions and endpoint counts.', num: '2' }, { name: 'list_endpoints', desc: 'List endpoints in a module. Provide moduleId.', num: '3' }, { name: 'get_endpoint_detail', desc: 'Get full endpoint details: parameters, request body, responses.', num: '4' }, { name: 'search_endpoints', desc: 'Search by keyword across all endpoints. Optional moduleId filter.', num: '5' }, ].map((t) => (
{t.num}
{t.name}

{t.desc}

))}
); }