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:
1 parent
2f5b263d4e
commit
0d335b808c
18 files changed
+2266
-17
No files matched your search
@@ -126,6 +126,25 @@
|
||||
</select>
|
||||
</label>
|
||||
<p id="set-fontsize-hint" class="muted small" data-i18n="settings.fontsize.hint">Preferenza di questo dispositivo.</p>
|
||||
<!-- MCP: global connector catalog (Generali scope) -->
|
||||
<div id="set-mcp-catalog" class="mcp-block" hidden>
|
||||
<h3 data-i18n="settings.mcp.catalog">Connettori MCP</h3>
|
||||
<p class="muted small" data-i18n="settings.mcp.catalog.hint">Server MCP esterni. Incolla qui il token Bearer del connettore: viene salvato nel database locale, come tutto il resto.</p>
|
||||
<div id="mcp-connector-list" class="mcp-list"></div>
|
||||
<div class="mcp-add">
|
||||
<input id="mcp-new-name" type="text" autocomplete="off" data-i18n-ph="settings.mcp.name.ph" placeholder="nome (es. gmail)" />
|
||||
<input id="mcp-new-url" type="text" autocomplete="off" data-i18n-ph="settings.mcp.url.ph" placeholder="http://host:porta/" />
|
||||
<input id="mcp-new-token" type="password" autocomplete="off" data-i18n-ph="settings.mcp.token.ph" placeholder="Token Bearer" />
|
||||
<button id="mcp-add-btn" class="btn" data-i18n="settings.mcp.add">Aggiungi</button>
|
||||
</div>
|
||||
<p id="mcp-catalog-hint" class="muted small"></p>
|
||||
</div>
|
||||
<!-- MCP: per-session tool allowlist (Sessione scope) -->
|
||||
<div id="set-mcp-tools" class="mcp-block" hidden>
|
||||
<h3 data-i18n="settings.mcp.tools">Strumenti MCP</h3>
|
||||
<p class="muted small" data-i18n="settings.mcp.tools.hint">Scegli quali tool di ogni connettore il modello può usare in questa chat. Salva per applicare.</p>
|
||||
<div id="mcp-tools-list" class="mcp-list"></div>
|
||||
</div>
|
||||
<div class="dialog-actions">
|
||||
<button id="set-cancel" class="btn" data-i18n="settings.cancel">Annulla</button>
|
||||
<button id="set-save" class="btn primary" data-i18n="settings.save">Salva</button>
|
||||
@@ -133,6 +152,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MCP per-tool picker: live tools/list + checkboxes (write badge) -->
|
||||
<div id="mcp-picker-modal" hidden>
|
||||
<div class="modal-card">
|
||||
<h2 id="mcp-picker-title">Strumenti</h2>
|
||||
<p id="mcp-picker-hint" class="muted small"></p>
|
||||
<div id="mcp-picker-list" class="mcp-picker-list"></div>
|
||||
<div class="dialog-actions">
|
||||
<button id="mcp-picker-cancel" class="btn" data-i18n="settings.cancel">Annulla</button>
|
||||
<button id="mcp-picker-ok" class="btn primary" data-i18n="settings.mcp.ok">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="module" src="/assets/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user