MCP catalog: core-hub suggestion from MCP_HUB_URL (deployment data)

When the deployment sets MCP_HUB_URL (the Core installer now writes
https://mcphub.$DOMAIN, the NEXTCLOUD_URL pattern), the MCP list appends
a core-hub suggestion: the federated tool hub over SSE with the user's
own mhub_ bearer token (DESIGN_MCP_HUB_AUTH.md step 3). Unset/invalid ->
no suggestion; never a TIER fork. The UI renders it generically (Use
prefills URL/transport/auth + token hint). Go test covers the env gate;
regression fixture carries the entry.
This commit is contained in:
Andrew S Erwin
2026-11-25 01:26:43 -06:00
parent 922cb46596
commit 5b3dcfdbb7
6 changed files with 63 additions and 3 deletions
+1 -1
View File
@@ -111,7 +111,7 @@ Bearer / custom-header auth. Stored in `McpConnection` (migration 018).
| Method | Path | Returns | | Method | Path | Returns |
|---|---|---| |---|---|---|
| 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) | | 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), plus a `core-hub` entry (SSE + bearer) when the deployment sets `MCP_HUB_URL` — deployment DATA like `NEXTCLOUD_URL`, never a TIER fork |
| POST | `/api/mcp/connections` | 201 masked projection; body `{name,url,transport,authKind,headerName?,secret?}`; secret required for bearer/header; cap 10 per user | | 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 | | 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 | | DELETE | `/api/mcp/connections/{id}` | `{ok:true}`; 404 for another user's row |
+6
View File
@@ -244,6 +244,12 @@ NETGUARD_TRUSTED_HOSTS=mail.$DOMAIN
# connection still needs the person's own username and app password; see the # connection still needs the person's own username and app password; see the
# three DAV sections in API.md). # three DAV sections in API.md).
NEXTCLOUD_URL=https://nextcloud.$DOMAIN NEXTCLOUD_URL=https://nextcloud.$DOMAIN
# --- MCP hub (Settings → MCP) ----------------------------------------------
# The core's federated tool hub (mcpserver-hub) as a one-connection MCP
# suggestion; each person connects with their OWN mhub_ bearer token
# (mcphub-token CLI; DESIGN_MCP_HUB_AUTH.md). Purely a hint, like NEXTCLOUD_URL.
MCP_HUB_URL=https://mcphub.$DOMAIN
EOF EOF
chmod 600 /federated/apps/superbrain/.env chmod 600 /federated/apps/superbrain/.env
+17
View File
@@ -222,6 +222,23 @@ func NextcloudSuggestion() string {
return raw return raw
} }
// McpHubSuggestion is the same deployment-data pattern for the core's MCP
// hub (DESIGN_MCP_HUB_AUTH.md): when MCP_HUB_URL points at the federated
// mcpserver-hub origin, Settings → MCP offers it as a one-connection
// suggestion (SSE + the user's own mhub_ bearer token). Unset or invalid →
// no suggestion; never a TIER fork.
func McpHubSuggestion() string {
raw := strings.TrimRight(strings.TrimSpace(os.Getenv("MCP_HUB_URL")), "/")
if raw == "" {
return ""
}
u, err := url.Parse(raw)
if err != nil || (u.Scheme != "http" && u.Scheme != "https") || u.Host == "" {
return ""
}
return raw
}
// Validate fails fast on configuration the app cannot use, instead of // Validate fails fast on configuration the app cannot use, instead of
// discovering it on the first request (review M-12). // discovering it on the first request (review M-12).
func (c *Config) Validate() error { func (c *Config) Validate() error {
+13 -1
View File
@@ -99,6 +99,8 @@ var mcpSuggestions = []object{
// HandleMcpConnectionsList returns the caller's connections, masked, plus // HandleMcpConnectionsList returns the caller's connections, masked, plus
// the suggestion catalog (always an array so clients can map() blindly). // the suggestion catalog (always an array so clients can map() blindly).
// The shipped catalog is static product data; the core-hub entry is
// deployment DATA (MCP_HUB_URL), exactly like the Nextcloud DAV prefills.
func HandleMcpConnectionsList(w http.ResponseWriter, r *http.Request) { func HandleMcpConnectionsList(w http.ResponseWriter, r *http.Request) {
rows, e := db.Many(r.Context(), database(r), rows, e := db.Many(r.Context(), database(r),
`SELECT to_jsonb(t) FROM "McpConnection" t WHERE "ownerId"=$1 ORDER BY "createdAt"`, user(r)) `SELECT to_jsonb(t) FROM "McpConnection" t WHERE "ownerId"=$1 ORDER BY "createdAt"`, user(r))
@@ -110,7 +112,17 @@ func HandleMcpConnectionsList(w http.ResponseWriter, r *http.Request) {
for _, row := range rows { for _, row := range rows {
out = append(out, mcpProjection(row)) out = append(out, mcpProjection(row))
} }
respond(w, 200, object{"connections": out, "suggestions": mcpSuggestions}, nil) suggestions := append([]object{}, mcpSuggestions...)
if hub := config.McpHubSuggestion(); hub != "" {
suggestions = append(suggestions, object{
"kind": "core-hub", "name": "Core tool hub",
"url": hub + "/sse",
"transport": "sse", "authKind": "bearer", "available": true,
"description": "Files, calendar, contacts, repos and more from your core's apps — one connection.",
"secretHint": "Your hub token (mhub_…, from your core operator)",
})
}
respond(w, 200, object{"connections": out, "suggestions": suggestions}, nil)
} }
func cleanMcpFields(b object, create bool) (object, error) { func cleanMcpFields(b object, create bool) (object, error) {
+23
View File
@@ -166,4 +166,27 @@ func TestMcpSuggestions(t *testing.T) {
if hs["available"] != false || hs["url"] != "https://mcp.hubspot.com" { if hs["available"] != false || hs["url"] != "https://mcp.hubspot.com" {
t.Fatalf("hubspot must be flagged OAuth-only: %v", hs) t.Fatalf("hubspot must be flagged OAuth-only: %v", hs)
} }
if _, present := byKind["core-hub"]; present {
t.Fatal("no MCP_HUB_URL -> no core-hub suggestion")
}
// The core hub is deployment DATA (the NEXTCLOUD_URL pattern): present
// only when MCP_HUB_URL is set, SSE + bearer, origin + /sse.
t.Setenv("MCP_HUB_URL", "https://mcphub.example/")
list = c.request("GET", "/api/mcp/connections", nil, 200)
for _, s := range list["suggestions"].([]any) {
m := s.(map[string]any)
if m["kind"] == "core-hub" {
if m["url"] != "https://mcphub.example/sse" || m["transport"] != "sse" || m["authKind"] != "bearer" || m["available"] != true {
t.Fatalf("core-hub suggestion wrong: %v", m)
}
}
}
t.Setenv("MCP_HUB_URL", "not a url")
list = c.request("GET", "/api/mcp/connections", nil, 200)
for _, s := range list["suggestions"].([]any) {
if s.(map[string]any)["kind"] == "core-hub" {
t.Fatal("garbage MCP_HUB_URL must suggest nothing")
}
}
} }
+3 -1
View File
@@ -77,6 +77,7 @@ 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: '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: '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.' }, { 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.' },
{ kind: 'core-hub', name: 'Core tool hub', url: 'https://mcphub.federatedcomputer.ai/sse', transport: 'sse', authKind: 'bearer', available: true, description: 'Files, calendar, contacts, repos and more from your core\'s apps — one connection.', secretHint: 'Your hub token (mhub_…, from your core operator)' },
] ]
let lastNextcloudConnect = null let lastNextcloudConnect = null
// Automations fixture: the sidebar dropdown and the /automations workspace // Automations fixture: the sidebar dropdown and the /automations workspace
@@ -928,8 +929,9 @@ try {
await page.goto(`${base}/settings`) await page.goto(`${base}/settings`)
await page.getByRole('tab', { name: 'MCP' }).click() await page.getByRole('tab', { name: 'MCP' }).click()
await page.getByText('Repos, issues, pull requests, code search and Actions.').waitFor() 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') assert.equal(await page.getByRole('button', { name: 'Use', exact: true }).count(), 3, 'only token-connectable suggestions may offer Use')
await page.getByText('OAuth required').waitFor() await page.getByText('OAuth required').waitFor()
await page.getByText('https://mcphub.federatedcomputer.ai/sse').waitFor()
await page.getByRole('button', { name: 'Use', exact: true }).first().click() 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('https://mcp.example.tld/mcp').inputValue(), 'https://api.githubcopilot.com/mcp/')
assert.equal(await page.getByPlaceholder('e.g. House gateway, Maps tools…').inputValue(), 'GitHub') assert.equal(await page.getByPlaceholder('e.g. House gateway, Maps tools…').inputValue(), 'GitHub')