agent: wire MCP connectors into the loop (rmcp v3, Initialize lifecycle)

- src/mcp: streamable-HTTP client (rmcp v3.12) negotiating Initialize +
  LATEST_WITH_INITIALIZE; namespaced mcp__{connector}__{tool} surface, write
  badges from ToolAnnotations, persisted discovery (tools_json) so the agent
  tool declarations stay byte-stable for KV-cache reuse.
- store: mcp_connectors catalog + tools_json column (idempotent migration) and
  set_mcp_tools; per-session per-tool allowlist (SessionSettings.mcp_enabled).
- agent: execute_mcp routes namespaced calls, gated on the session allowlist
  before any network call; Bearer token comes from the DB catalog, never echoed.
- api/sessions: build the MCP surface into Ambient + the agent tool declarations
  on both the turn and prewarm paths (identical rebuild keeps the prefix stable).
- api/mcp + GUI: connector CRUD, tool-discovery picker, per-session enable.
- examples/mcp_probe: read-only CLI discovery spike.

Live-verified: 22 gmail tools discovered, gmail_labels returned 25 labels, and a
full model-driven GUI turn (7 enabled tools) with a 9197-token RESUME cache hit.
This commit is contained in:
adm committed 2026-11-30 02:29:55 +01:00
1 parent 2f5b263d4e
commit 0d335b808c
18 files changed
+2266 -17

No files matched your search

+23
View File
@@ -15,6 +15,29 @@
"settings.maxtokens": "Max token",
"settings.fontsize": "Dimensione del font",
"settings.fontsize.hint": "Preferenza di questo dispositivo (non influisce sul modello).",
"settings.mcp.catalog": "Connettori MCP",
"settings.mcp.catalog.hint": "Server MCP esterni. Incolla qui il token Bearer del connettore: viene salvato nel database locale, come tutto il resto.",
"settings.mcp.tools": "Strumenti MCP",
"settings.mcp.tools.hint": "Scegli quali tool di ogni connettore il modello può usare in questa chat. Salva per applicare.",
"settings.mcp.name.ph": "nome (es. gmail)",
"settings.mcp.url.ph": "http://host:porta/",
"settings.mcp.token.ph": "Token Bearer",
"settings.mcp.add": "Aggiungi",
"settings.mcp.edit": "Modifica",
"settings.mcp.delete": "Elimina",
"settings.mcp.delete.confirm": "Eliminare il connettore '{name}' dal catalogo?",
"settings.mcp.empty": "Nessun connettore. Aggiungine uno qui sotto.",
"settings.mcp.noconnectors": "Nessun connettore nel catalogo. Aggiungili in Impostazioni generali.",
"settings.mcp.choose": "Scegli strumenti",
"settings.mcp.enabled.count": "{n} abilitati",
"settings.mcp.write": "scrittura",
"settings.mcp.ok": "OK",
"settings.mcp.loading": "Connessione e lettura dei tool…",
"settings.mcp.picker.title": "Strumenti di {name}",
"settings.mcp.picker.hint": "{n} tool disponibili. Spunta quelli da abilitare per questa chat.",
"settings.mcp.fields.required": "Nome, URL e token sono obbligatori.",
"settings.mcp.saved": "Connettore salvato.",
"settings.mcp.error": "Errore MCP: {msg}",
"settings.save": "Salva",
"settings.cancel": "Annulla",
"settings.hint.session": "Modifiche valide solo per questa sessione.",