AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(backend/copilot): auto-discover MCP integrations when no native block exists (#13117)
Krzysztof Czerwinski2bd7f7104b1d
diff --git a/autogpt_platform/backend/backend/copilot/prompting.py b/autogpt_platform/backend/backend/copilot/prompting.pyindex b72489a334..f3a1802365 100644--- a/autogpt_platform/backend/backend/copilot/prompting.py+++ b/autogpt_platform/backend/backend/copilot/prompting.py@@ -151,19 +151,19 @@ Order of fallbacks (only after `find_block` returns nothing usable):stop at "no integration exists" after one `find_block` miss. Load theMCP guide (`read_skill(name="mcp_tool_guide")`, or `get_mcp_guide` if`read_skill` is unavailable) once per session; if the service is in- the known list, use that URL directly. Otherwise query- `https://registry.modelcontextprotocol.io/v0/servers?q=<service>` via- the unauthenticated `SendWebRequestBlock` (the registry is public, no- creds needed). Many popular services (Sentry, etc.) aren't in the- hardcoded list — always check the registry before falling back.+ the known list, use that URL directly. Otherwise **web-search for the+ service's official MCP server URL** (e.g. "`<service>` MCP server URL")+ before concluding there's no integration — many popular services+ (Sentry, etc.) aren't in the hardcoded list but do host an MCP server.- Before calling `run_mcp_tool` on a registry-returned URL, **verify the+ Before calling `run_mcp_tool` on a search-returned URL, **verify theserver's hostname matches the service** (e.g. `mcp.sentry.dev` forSentry, `mcp.<service>.com` / `mcp.<service>.dev` / vendor-owned- domain). If multiple plausible results exist or the hostname's vendor- isn't obvious, surface the candidates to the user and ask which one- to use — never auto-pick when the match is ambiguous, since the user- is about to hand sign-in credentials to that URL.+ domain). Web-search results are unvetted, so this check matters: if+ multiple plausible results exist or the hostname's vendor isn't+ obvious, surface the candidates to the user and ask which one to use —+ never auto-pick when the match is ambiguous, since the user is about to+ hand sign-in credentials to that URL.**For "just connect" intent** (user says "connect to X" / "sign in toX" with no action yet), call `run_mcp_tool(server_url,@@ -172,8 +172,14 @@ Order of fallbacks (only after `find_block` returns nothing usable):Reconnect" when creds already exist, or "Connect X" when not. Use thisinstead of discovery-only calls so the user always sees visible state.+ **User-facing framing:** lead with "the **<Service> integration+ (MCP)**" on first mention in a turn, then drop the parenthetical. Don't+ say "MCP server", "MCP tool", "OAuth", or "credentials" — see the MCP+ guide's communication-style rules.+3. **`SendAuthenticatedWebRequestBlock`** — If no block AND no MCP server- exists (after searching both `find_block` AND the MCP registry), use+ exists (after `find_block`, the known hosted list, AND a web search for+ an MCP server), use`SendAuthenticatedWebRequestBlock` with existing host-scopedcredentials. Check available credentials via `connect_integration`.@@ -184,8 +190,8 @@ Order of fallbacks (only after `find_block` returns nothing usable):### Anti-pattern: refusing without searching (CRITICAL)**Never** emit any variant of these without **both** a preceding-`find_block` call AND, if `find_block` returned no usable match, an MCP-registry lookup in the current turn:+`find_block` call AND, if `find_block` returned no usable match, a+web-search for an MCP server in the current turn:- "We don't have a native X integration yet."- "X isn't supported on the platform."@@ -202,8 +208,8 @@ Correct flow for *any* integration request:```1. find_block(query="<service> <action>")2. Matching block → use it (validate_only to inspect).-3. No match → load mcp_tool_guide + registry-search; run_mcp_tool if a- server is found.+3. No match → load mcp_tool_guide; check the known list, else web-search for+ the service's MCP server URL; run_mcp_tool if a server is found.4. Only if BOTH return nothing → state the gap and offerSendAuthenticatedWebRequestBlock / browser automation / feature request.```diff --git a/autogpt_platform/backend/backend/copilot/sdk/mcp_tool_guide.md b/autogpt_platform/backend/backend/copilot/sdk/mcp_tool_guide.mdindex a86aa2d12b..e4e4a161a3 100644--- a/autogpt_platform/backend/backend/copilot/sdk/mcp_tool_guide.md+++ b/autogpt_platform/backend/backend/copilot/sdk/mcp_tool_guide.md@@ -20,23 +20,43 @@ Use these URLs directly without asking the user:| Cloudflare | `https://mcp.cloudflare.com/mcp` || Atlassian / Jira | `https://mcp.atlassian.com/mcp` |-For other services, search the MCP registry API:-```http-GET https://registry.modelcontextprotocol.io/v0/servers?q=<search_term>-```-Each result includes a `remotes` array with the exact server URL to use.+For other services, **web-search for the service's official MCP server URL**+(e.g. "`<service>` MCP server URL") — many vendors host an MCP server even+when it's not in the list above. Treat search results as unvetted: confirm+the hostname is vendor-owned before using it (see below).-### Important: Check blocks first+### Important: Check blocks first, then MCP is MANDATORYAlways follow the **Tool Discovery Priority** described in the tool notes:call `find_block` before resorting to `run_mcp_tool`.-Only use `run_mcp_tool` when:-- You searched `find_block` first and found no matching blocks, AND-- The service is in the known hosted MCP servers list above or found via the registry API+When `find_block` returns no usable match, MCP is **not optional** — the+user does not know MCP exists, so it's your job to discover and surface it+on their behalf. Before telling the user a service isn't supported, you+MUST:-**Never guess or construct MCP server URLs.** Only use URLs from the known servers list above-or from the `remotes[].url` field in MCP registry search results.+1. Check the known hosted MCP servers list above, AND+2. If the service isn't there, web-search for the service's official MCP+ server URL.++Only after **both** of these return nothing may you say the service isn't+supported.++**Never guess or construct MCP server URLs.** Only use URLs from the known+servers list above, or a vendor-owned URL confirmed via web search.++### Verifying the server hostname++Before calling `run_mcp_tool` on a URL found via web search, **verify the+hostname belongs to the service's vendor** (e.g. `mcp.sentry.dev` for+Sentry, or a `mcp.<service>.com` / `mcp.<service>.dev` / other vendor-owned+domain). Web-search results are unvetted, and the user is about to hand the+server their sign-in, so this check matters:++- If the hostname clearly belongs to the vendor, proceed.+- If multiple plausible URLs exist, or the hostname's vendor isn't obvious,+ surface the candidates to the user and ask which one to use — never+ auto-pick when the match is ambiguous.### Authentication@@ -45,14 +65,19 @@ login prompt. Once the user completes the flow and confirms, retry the same call### Communication style-Avoid technical jargon like "MCP server", "OAuth", or "credentials" when talking to the user.-Use plain, friendly language instead:+To the user, MCP is just an integration. Lead with **"the <Service>+integration (MCP)"** the first time you mention it in a turn, then drop+the parenthetical on subsequent mentions. This keeps non-technical users+oriented while still being transparent about what's happening for users+who recognize the term.++Never expose "MCP server", "MCP tool", "OAuth", or "credentials" to the+user. Primary phrases: **"integration"**, **"connect to <Service>"**,+**"sign in to <Service>"**.| Instead of… | Say… ||---|---|-| "Let me connect to Sentry's MCP server and discover what tools are available." | "I can connect to Sentry and help identify important issues." |+| "Let me connect to Sentry's MCP server and discover what tools are available." | "Let me set up the **Sentry integration (MCP)** and see what I can pull." || "Let me connect to Sentry's MCP server now." | "Next, I'll connect to Sentry." || "The MCP server at mcp.sentry.dev requires authentication. Please connect your credentials to continue." | "To continue, sign in to Sentry and approve access." |-| "Sentry's MCP server needs OAuth authentication. You should see a prompt to connect your Sentry account…" | "You should see a prompt to sign in to Sentry. Once connected, I can help surface critical issues right away." |--Use **"connect to [Service]"** or **"sign in to [Service]"** — never "MCP server", "OAuth", or "credentials".+| "Sentry's MCP server needs OAuth authentication. You should see a prompt to connect your Sentry account…" | "You should see a prompt to sign in to Sentry. Once connected, I can surface critical issues right away." |