import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; interface ConnectionRow { serverId: string; serverName: string; connected: boolean; authKind: 'oauth' | 'api_key'; ownerId: string | null; } interface ConnectionListResponse { connections: ConnectionRow[]; } async function fetchConnections(): Promise { const res = await fetch('/api/mcp/connections', { credentials: 'include' }); if (!res.ok) throw new Error(`${res.status}`); const data: ConnectionListResponse = await res.json(); return data.connections ?? []; } async function disconnectMcp(serverId: string): Promise { const res = await fetch(`/api/mcp/connections/${encodeURIComponent(serverId)}`, { method: 'DELETE', credentials: 'include', }); if (!res.ok) throw new Error(`${res.status}`); } function OwnerBadge({ ownerId }: { ownerId: string | null }) { if (ownerId === null) { return ( global ); } return ( personal ); } export function McpConnectionsPanel() { const qc = useQueryClient(); const { data, isLoading, error } = useQuery({ queryKey: ['mcp-connections'], queryFn: fetchConnections, staleTime: 30_000, }); const disconnect = useMutation({ mutationFn: disconnectMcp, onSuccess: () => qc.invalidateQueries({ queryKey: ['mcp-connections'] }), }); return (

MCP 接続

外部 MCP サーバーとの連携を管理します。OAuth サーバーは「連携する」を押すと 外部サービスの認可ページに飛び、戻ってくると自動で連携が確立します。 API key サーバーはサーバー登録と同時に接続済みになります。

{isLoading &&
Loading…
} {error &&
読み込みに失敗しました: {String(error)}
} {!isLoading && !error && (data?.length ?? 0) === 0 && (
利用可能な MCP サーバーがありません。「mcp-servers/」でサーバーを登録してください。
)}
    {(data ?? []).map((c) => (
  • {c.serverName}
    {c.serverId}
    {c.authKind === 'oauth' ? ( c.connected ? (
    連携済み
    ) : ( 連携する ) ) : ( /* api_key */ c.connected ? (
    API key 接続済み {c.ownerId !== null && ( 削除は mcp-servers タブから )}
    ) : ( API key が未設定です ) )}
  • ))}
); }