diff --git a/API.md b/API.md index 24a2965..2aba0f3 100644 --- a/API.md +++ b/API.md @@ -111,7 +111,7 @@ Bearer / custom-header auth. Stored in `McpConnection` (migration 018). | Method | Path | Returns | |---|---|---| -| GET | `/api/mcp/connections` | `{connections:[…]}` — secret masked `••••••••` when set, never plaintext | +| GET | `/api/mcp/connections` | `{connections:[…],suggestions:[…]}` — secret masked `••••••••` when set, never plaintext; suggestions are the shipped catalog of well-known hosted MCP servers (GitHub, HubSpot, Make) with `available:false` marking auth the client cannot satisfy (HubSpot requires OAuth 2.1 + PKCE) | | POST | `/api/mcp/connections` | 201 masked projection; body `{name,url,transport,authKind,headerName?,secret?}`; secret required for bearer/header; cap 10 per user | | PATCH | `/api/mcp/connections/{id}` | masked projection; **requires `version`** (409 on stale); a mask or omitted `secret` keeps the stored value; switching `authKind` to `none` clears it | | DELETE | `/api/mcp/connections/{id}` | `{ok:true}`; 404 for another user's row | diff --git a/internal/handlers/mcp.go b/internal/handlers/mcp.go index 3a75753..d5a0e61 100644 --- a/internal/handlers/mcp.go +++ b/internal/handlers/mcp.go @@ -59,7 +59,46 @@ func mcpProjection(row object) object { } } -// HandleMcpConnectionsList returns the caller's connections, masked. +// mcpSuggestions is the product catalog of well-known hosted MCP servers +// offered on the MCP settings tab — DATA in the shipped binary (like the +// entitlements catalog), not deployment config and never a TIER fork. +// "Use" prefills the connection form; the user still supplies the credential +// and confirms. available=false marks a server whose authentication this +// client cannot satisfy today: HubSpot's remote MCP requires OAuth 2.1 with +// PKCE (no static-token path), while internal/mcpclient speaks none/bearer/ +// header only — the entry stays visible, honestly labeled, without a Use +// button. URLs/auth verified against the vendors' docs 2026-11. +var mcpSuggestions = []object{ + { + "kind": "github", "name": "GitHub", + "url": "https://api.githubcopilot.com/mcp/", + "transport": "streamable-http", "authKind": "bearer", "available": true, + "description": "Repos, issues, pull requests, code search and Actions.", + "secretHint": "GitHub personal access token (fine-grained recommended)", + "note": "Append /readonly to the URL for read-only tools.", + "docsUrl": "https://github.com/github/github-mcp-server", + }, + { + "kind": "hubspot", "name": "HubSpot", + "url": "https://mcp.hubspot.com", + "transport": "streamable-http", "authKind": "bearer", "available": false, + "description": "CRM contacts, companies, deals, tickets and activities.", + "note": "Requires OAuth 2.1 sign-in (PKCE) — HubSpot refuses token-only connections, and Superbrain's MCP client does not do OAuth flows yet.", + "docsUrl": "https://developers.hubspot.com/ai-tools/mcp", + }, + { + "kind": "make", "name": "Make", + "url": "https://us1.make.com/mcp/v2", + "transport": "streamable-http", "authKind": "bearer", "available": true, + "description": "Run your Make scenarios as tools; manage scenarios and data stores.", + "secretHint": "Make API token with the mcp:use scope (Profile → API access)", + "note": "Swap in your account's zone: eu1, eu2, us1 or us2.make.com.", + "docsUrl": "https://developers.make.com/mcp-server/", + }, +} + +// HandleMcpConnectionsList returns the caller's connections, masked, plus +// the suggestion catalog (always an array so clients can map() blindly). func HandleMcpConnectionsList(w http.ResponseWriter, r *http.Request) { rows, e := db.Many(r.Context(), database(r), `SELECT to_jsonb(t) FROM "McpConnection" t WHERE "ownerId"=$1 ORDER BY "createdAt"`, user(r)) @@ -71,7 +110,7 @@ func HandleMcpConnectionsList(w http.ResponseWriter, r *http.Request) { for _, row := range rows { out = append(out, mcpProjection(row)) } - respond(w, 200, object{"connections": out}, nil) + respond(w, 200, object{"connections": out, "suggestions": mcpSuggestions}, nil) } func cleanMcpFields(b object, create bool) (object, error) { diff --git a/internal/http/mcp_connections_test.go b/internal/http/mcp_connections_test.go index f8f7009..960ad3a 100644 --- a/internal/http/mcp_connections_test.go +++ b/internal/http/mcp_connections_test.go @@ -5,6 +5,7 @@ import ( "net/http" "net/http/cookiejar" "net/http/httptest" + "strings" "testing" mcpsdk "github.com/modelcontextprotocol/go-sdk/mcp" @@ -135,3 +136,34 @@ func TestMcpConnections(t *testing.T) { // maxTestMcpConns mirrors handlers.maxMcpConns. const maxTestMcpConns = 10 + +// The suggestion catalog ships with the list: GitHub and Make are +// token-connectable (bearer), HubSpot is honestly flagged unavailable +// because its remote MCP requires OAuth 2.1 + PKCE, which the client +// (none/bearer/header) cannot do. +func TestMcpSuggestions(t *testing.T) { + srv := testServer(t) + c, _ := accountClient(t, srv.URL, "mcp-sugg@superbrain.test") + list := c.request("GET", "/api/mcp/connections", nil, 200) + sugg, _ := list["suggestions"].([]any) + byKind := map[string]map[string]any{} + for _, s := range sugg { + m := s.(map[string]any) + byKind[m["kind"].(string)] = m + } + if len(byKind) != 3 { + t.Fatalf("want github/hubspot/make suggestions, got %v", byKind) + } + gh := byKind["github"] + if gh["url"] != "https://api.githubcopilot.com/mcp/" || gh["authKind"] != "bearer" || gh["available"] != true { + t.Fatalf("github suggestion wrong: %v", gh) + } + mk := byKind["make"] + if mk["authKind"] != "bearer" || mk["available"] != true || !strings.Contains(mk["url"].(string), "make.com/mcp/v2") { + t.Fatalf("make suggestion wrong: %v", mk) + } + hs := byKind["hubspot"] + if hs["available"] != false || hs["url"] != "https://mcp.hubspot.com" { + t.Fatalf("hubspot must be flagged OAuth-only: %v", hs) + } +} diff --git a/scripts/regressions.mjs b/scripts/regressions.mjs index 73ce3ea..7cd8bff 100644 --- a/scripts/regressions.mjs +++ b/scripts/regressions.mjs @@ -73,6 +73,11 @@ const carddavSuggestions = [{ kind: 'nextcloud', name: 'Nextcloud contacts', url // Unified Nextcloud connect fixture: mirrors handlers/nextcloud.go — the // origin is normalized, per-user DAV roots composed server-side, repeat // connects report "exists", and a wrong password stores nothing. +const mcpSuggestions = [ + { kind: 'github', name: 'GitHub', url: 'https://api.githubcopilot.com/mcp/', transport: 'streamable-http', authKind: 'bearer', available: true, description: 'Repos, issues, pull requests, code search and Actions.', secretHint: 'GitHub personal access token (fine-grained recommended)', note: 'Append /readonly to the URL for read-only tools.' }, + { kind: 'hubspot', name: 'HubSpot', url: 'https://mcp.hubspot.com', transport: 'streamable-http', authKind: 'bearer', available: false, description: 'CRM contacts, companies, deals, tickets and activities.', note: 'Requires OAuth 2.1 sign-in (PKCE) — HubSpot refuses token-only connections, and Superbrain\'s MCP client does not do OAuth flows yet.' }, + { kind: 'make', name: 'Make', url: 'https://us1.make.com/mcp/v2', transport: 'streamable-http', authKind: 'bearer', available: true, description: 'Run your Make scenarios as tools; manage scenarios and data stores.', secretHint: 'Make API token with the mcp:use scope (Profile → API access)', note: 'Swap in your account\'s zone: eu1, eu2, us1 or us2.make.com.' }, +] let lastNextcloudConnect = null // Automations fixture: the sidebar dropdown and the /automations workspace // exercise against the same projection handlers/agent.go returns. @@ -319,6 +324,8 @@ const api = http.createServer(async (req, res) => { results[key] = { status: 'created', id: conn.id, name: conn.name, url: u } } result = { results } + } else if (url.pathname === '/api/mcp/connections') { + result = { connections: [], suggestions: mcpSuggestions } } else if (url.pathname === '/api/agent/tasks') { result = agentTasks } else if (url.pathname === '/api/agent/runs') { @@ -915,6 +922,21 @@ try { await page.getByPlaceholder('https://cloud.example.com').waitFor() console.log('PASS: Automations lives in the sidebar with a task dropdown, deep-links to /automations, and the legacy settings tab redirects') + // Settings → MCP: the suggestion catalog offers GitHub and Make (token + // auth) with a Use prefill; HubSpot is honestly flagged OAuth-required + // with no Use button — the client speaks none/bearer/header only. + await page.goto(`${base}/settings`) + await page.getByRole('tab', { name: 'MCP' }).click() + await page.getByText('Repos, issues, pull requests, code search and Actions.').waitFor() + assert.equal(await page.getByRole('button', { name: 'Use', exact: true }).count(), 2, 'only token-connectable suggestions may offer Use') + await page.getByText('OAuth required').waitFor() + await page.getByRole('button', { name: 'Use', exact: true }).first().click() + assert.equal(await page.getByPlaceholder('https://mcp.example.tld/mcp').inputValue(), 'https://api.githubcopilot.com/mcp/') + assert.equal(await page.getByPlaceholder('e.g. House gateway, Maps tools…').inputValue(), 'GitHub') + await page.getByPlaceholder('GitHub personal access token (fine-grained recommended)').waitFor() + await page.locator('[role="dialog"]').getByRole('button', { name: 'Cancel' }).click() + console.log('PASS: Settings → MCP offers GitHub/Make suggestions with Use prefill and flags HubSpot as OAuth-required') + // Mobile pass (390x844): the shell becomes a drawer, tables become cards, // rail screens become master-detail, and NO screen may overflow the // viewport horizontally. A separate context keeps the desktop session and diff --git a/web/components/mcp-settings.tsx b/web/components/mcp-settings.tsx index 1779150..cba27ef 100644 --- a/web/components/mcp-settings.tsx +++ b/web/components/mcp-settings.tsx @@ -23,12 +23,16 @@ type McpConnection = { id: string; name: string; url: string; transport: string; authKind: string headerName: string; secret: string; enabled: boolean; version: number } +type Suggestion = { + kind: string; name: string; url: string; transport: string; authKind: string + available: boolean; description?: string; secretHint?: string; note?: string; docsUrl?: string +} type TestResult = { ok: boolean; count?: number; tools?: { name: string; description: string }[]; error?: string } type FormState = { id: string | null; version: number name: string; url: string; transport: string; authKind: string; headerName: string - secret: string; hasStoredSecret: boolean + secret: string; hasStoredSecret: boolean; secretHint?: string } const emptyForm: FormState = { @@ -42,6 +46,7 @@ async function api(path: string, init?: RequestInit): Promise { export function McpSettings() { const [connections, setConnections] = useState([]) + const [suggestions, setSuggestions] = useState([]) const [loading, setLoading] = useState(true) const [form, setForm] = useState(null) const [saving, setSaving] = useState(false) @@ -51,13 +56,22 @@ export function McpSettings() { const reload = useCallback(() => api('/api/mcp/connections') .then(r => r.json()) - .then(data => setConnections(Array.isArray(data?.connections) ? data.connections : [])) + .then(data => { + setConnections(Array.isArray(data?.connections) ? data.connections : []) + setSuggestions(Array.isArray(data?.suggestions) ? data.suggestions : []) + }) .catch(() => toast.error('Could not load MCP connections')) .finally(() => setLoading(false)), []) useEffect(() => { reload() }, [reload]) const openCreate = () => setForm({ ...emptyForm }) + // A suggestion prefills everything except the credential — the user still + // pastes their own token and confirms (write-only discipline unchanged). + const openSuggestion = (s: Suggestion) => setForm({ + ...emptyForm, name: s.name, url: s.url, transport: s.transport, + authKind: s.authKind, secretHint: s.secretHint, + }) const openEdit = (c: McpConnection) => setForm({ id: c.id, version: c.version, name: c.name, url: c.url, transport: c.transport, authKind: c.authKind, headerName: c.headerName, secret: '', hasStoredSecret: c.secret === KEY_MASK, @@ -140,6 +154,30 @@ export function McpSettings() { + {suggestions.length > 0 && ( +
+ {suggestions.map(s => ( +
+ +
+

+ {s.name} + {!s.available && OAuth required} +

+ {s.description &&

{s.description}

} +

{s.url}

+ {s.note &&

{s.note}

} +
+ {s.available + ? + : s.docsUrl && ( + Docs + )} +
+ ))} +
+ )} + {connections.length === 0 ? (

No MCP connections yet.

) : ( @@ -231,7 +269,7 @@ export function McpSettings() { type="password" value={form.secret} onChange={e => setForm({ ...form, secret: e.target.value })} - placeholder={form.hasStoredSecret ? `${KEY_MASK} (leave blank to keep)` : 'Paste the credential'} + placeholder={form.hasStoredSecret ? `${KEY_MASK} (leave blank to keep)` : (form.secretHint || 'Paste the credential')} maxLength={2000} /> {form.hasStoredSecret &&

Stored credentials are never shown; blank keeps the current one.

}