MCP settings: suggestion catalog for GitHub, HubSpot and Make
The connections list now serves a shipped catalog of well-known hosted MCP servers (data in the binary, like the entitlements catalog — never a TIER fork). 'Use' prefills name/url/transport/authKind and shows a secretHint placeholder; the credential stays the user's to paste (write-only discipline unchanged). Verified against vendor docs: GitHub (api.githubcopilot.com/mcp/) and Make (<zone>.make.com/mcp/v2) accept Bearer tokens and are connectable today. HubSpot's remote MCP (mcp.hubspot.com) requires OAuth 2.1 + PKCE with no static-token path — the client speaks none/bearer/header only, so the entry is shown honestly labeled 'OAuth required' with a note and docs link, and NO Use button. Go test asserts the catalog; browser regression covers the prefill and the HubSpot treatment.
This commit is contained in:
@@ -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<Response> {
|
||||
|
||||
export function McpSettings() {
|
||||
const [connections, setConnections] = useState<McpConnection[]>([])
|
||||
const [suggestions, setSuggestions] = useState<Suggestion[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [form, setForm] = useState<FormState | null>(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() {
|
||||
<Button size="sm" onClick={openCreate}><Plus className="h-4 w-4 mr-1" /> Add connection</Button>
|
||||
</div>
|
||||
|
||||
{suggestions.length > 0 && (
|
||||
<div className="space-y-2">
|
||||
{suggestions.map(s => (
|
||||
<div key={s.kind} className="flex items-start gap-3 rounded-md border border-dashed p-3">
|
||||
<PlugZap className="mt-0.5 h-5 w-5 shrink-0 text-muted-foreground" />
|
||||
<div className="min-w-0 flex-1 space-y-0.5">
|
||||
<p className="text-sm font-medium flex items-center gap-2">
|
||||
{s.name}
|
||||
{!s.available && <Badge variant="outline" className="text-[10px] text-amber-600 dark:text-amber-400">OAuth required</Badge>}
|
||||
</p>
|
||||
{s.description && <p className="text-xs text-muted-foreground">{s.description}</p>}
|
||||
<p className="truncate text-xs text-muted-foreground font-mono">{s.url}</p>
|
||||
{s.note && <p className="text-xs text-muted-foreground">{s.note}</p>}
|
||||
</div>
|
||||
{s.available
|
||||
? <Button size="sm" variant="outline" className="shrink-0" onClick={() => openSuggestion(s)}>Use</Button>
|
||||
: s.docsUrl && (
|
||||
<a href={s.docsUrl} target="_blank" rel="noreferrer" className="shrink-0 text-xs text-muted-foreground underline hover:text-foreground">Docs</a>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{connections.length === 0 ? (
|
||||
<p className="text-sm text-muted-foreground">No MCP connections yet.</p>
|
||||
) : (
|
||||
@@ -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 && <p className="mt-1 text-xs text-muted-foreground">Stored credentials are never shown; blank keeps the current one.</p>}
|
||||
|
||||
Reference in New Issue
Block a user