Skip to content

feat(copilot): run_mcp_tool โ€” MCP server discovery and execution in Otto#12213

Merged
majdyz merged 36 commits intodevfrom
feat/mcp-copilot
Mar 4, 2026
Merged

feat(copilot): run_mcp_tool โ€” MCP server discovery and execution in Otto#12213
majdyz merged 36 commits intodevfrom
feat/mcp-copilot

Conversation

@majdyz
Copy link
Contributor

@majdyz majdyz commented Feb 26, 2026

Summary

Enables Otto (the AutoGPT copilot) to connect to any MCP (Model Context Protocol) server, discover its tools, and execute them โ€” with the same credential login UI used in the graph builder.

Why a dedicated run_mcp_tool instead of reusing run_block + MCPToolBlock?
Two blockers make run_block unworkable for MCP:

  1. No discovery mode โ€” MCPToolBlock errors with "No tool selected" when selected_tool is empty; the agent can't learn what tools exist before picking one.
  2. Credential matching bug โ€” find_matching_credential() (the block execution path) does NOT check MCP server URLs; it would match any stored MCP OAuth credential regardless of server. The correct _credential_is_for_mcp_server() helper only applies in the graph path.

Changes

Backend

  • New run_mcp_tool copilot tool (run_mcp_tool.py) โ€” two-stage flow:
    1. run_mcp_tool(server_url) โ†’ discovers available tools via MCPClient.list_tools()
    2. run_mcp_tool(server_url, tool_name, tool_arguments) โ†’ executes via MCPClient.call_tool()
    • Lazy auth: fast DB credential lookup first (MCPToolBlock._auto_lookup_credential); on HTTP 401/403 with no stored creds, returns SetupRequirementsResponse so the frontend renders the existing CredentialsGroupedView OAuth login card
  • New response models in models.py: MCPToolsDiscoveredResponse, MCPToolOutputResponse, MCPToolInfo
  • Exclude MCPToolBlock from find_block / run_block (COPILOT_EXCLUDED_BLOCK_TYPES)
  • System prompt update โ€” MCP section with two-step flow, input_schema guidance, auth-wait instruction, and registry URL (registry.modelcontextprotocol.io)

Frontend

  • RunMCPToolComponent โ€” routes between credential prompt (reuses SetupRequirementsCard from RunBlock) and result card; discovery step shows only a minimal in-progress animation (agent-internal, not user-facing)
  • MCPToolOutputCard โ€” renders tool result as formatted JSON or plain text
  • helpers.tsx โ€” type guards (isMCPToolOutput, isSetupRequirementsOutput, isErrorOutput), output parsing, animation text
  • Registered tool-run_mcp_tool case in ChatMessagesContainer

Test plan

  • Call run_mcp_tool(server_url) with a public MCP server โ†’ see discovery animation, agent gets tool list
  • Call run_mcp_tool(server_url, tool_name, tool_arguments) โ†’ see MCPToolOutputCard with result
  • Call with an auth-required server and no stored creds โ†’ SetupRequirementsCard renders with MCP OAuth button
  • After connecting credentials, retry โ†’ executes successfully
  • find_block("MCP") returns no results (MCPToolBlock excluded)
  • Backend unit tests: mock MCPClient for discovery + execution + auth error paths

@github-project-automation github-project-automation bot moved this to ๐Ÿ†• Needs initial review in AutoGPT development kanban Feb 26, 2026
@github-actions github-actions bot added platform/frontend AutoGPT Platform - Front end platform/backend AutoGPT Platform - Back end labels Feb 26, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • โ–ถ๏ธ Resume reviews
  • ๐Ÿ” Trigger review

Walkthrough

Adds end-to-end Model Context Protocol (MCP) support: new backend RunMCPTool tool (discover + execute + credential flows), MCP response models and token API, frontend UI/components/helpers for discovery, setup (OAuth/manual token) and output rendering, OpenAPI updates, and tests.

Changes

Cohort / File(s) Summary
Backend: Docs
autogpt_platform/backend/backend/copilot/service.py
Docs added: MCP live-integration guidance, discovery/execute usage, and behavioral guidelines.
Backend: Tool Registry
autogpt_platform/backend/backend/copilot/tools/__init__.py
Register new RunMCPToolTool under run_mcp_tool.
Backend: Models & Filtering
autogpt_platform/backend/backend/copilot/tools/find_block.py, autogpt_platform/backend/backend/copilot/tools/models.py
Add BlockType.MCP_TOOL to excluded types; extend ResponseType with mcp_tools_discovered and mcp_tool_output; add MCPToolInfo, MCPToolsDiscoveredResponse, MCPToolOutputResponse.
Backend: New Tool
autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
New RunMCPToolTool: two-stage flow (discover via server_url; execute with tool_name+arguments), URL validation, credential lookup/building, MCPClient integration, SetupRequirementsResponse handling, and error mapping.
Backend: MCP Token API
autogpt_platform/backend/backend/api/features/mcp/routes.py
New POST /v2/mcp/token endpoint and MCPStoreTokenRequest; normalizes server_url, stores bearer token as MCP credential, rotates old tokens.
Backend: Chat Responses
autogpt_platform/backend/backend/api/features/chat/routes.py
Include MCP tool response models in chat tool response union.
Backend: Tests
autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
Extensive unit tests for RunMCPToolTool: helper behavior, validation, discovery/execution, credential flows, error mapping.
Backend: Web Fetch
autogpt_platform/backend/backend/copilot/tools/web_fetch.py
Treat RFC7807 content-types (application/problem+json, application/problem+xml, application/ld+json) as text.
Frontend: Chat Rendering
autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
Render RunMCPToolComponent for tool-run_mcp_tool parts.
Frontend: MCP UI / Helpers
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/...
Add RunMCPToolComponent, typed helpers/type guards, ToolIcon, MCPToolOutputCard, MCPSetupCard (OAuth/manual token flow), parsing/formatting helpers, and exported types.
Frontend: Setup Card Props
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
Added optional retryInstruction and credentialsLabel props and used them in retry/credentials messaging.
Frontend: OpenAPI / API Schema
autogpt_platform/frontend/src/app/api/openapi.json
Add MCP schemas (MCPToolInfo, MCPToolsDiscoveredResponse, MCPToolOutputResponse, MCPStoreTokenRequest), extend ResponseType enum, and add /api/mcp/token path.
Frontend: Tests
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
Unit tests for helpers, type guards, output parsing, hostname extraction, and UI animation text.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Frontend as RunMCPToolComponent
    participant Backend as RunMCPToolTool
    participant MCPClient as MCPClient
    participant Server as MCP Server

    User->>Frontend: submit server_url
    Frontend->>Backend: run_mcp_tool(server_url)
    Backend->>Backend: lookup stored credentials
    alt credentials missing / 401
        Backend-->>Frontend: SetupRequirementsResponse (needs token/OAuth)
        Frontend->>User: show MCPSetupCard (OAuth/manual token)
        User->>Frontend: provide credentials
        Frontend->>Backend: re-run run_mcp_tool(server_url)
    else credentials present
        Backend->>MCPClient: init with creds
        MCPClient->>Server: list tools (discover)
        Server-->>MCPClient: tools metadata
        MCPClient-->>Backend: discovered tools
        Backend-->>Frontend: MCPToolsDiscoveredResponse
    end
Loading
sequenceDiagram
    actor User
    participant Frontend as RunMCPToolComponent
    participant Backend as RunMCPToolTool
    participant MCPClient as MCPClient
    participant Server as MCP Server

    User->>Frontend: select tool + args
    Frontend->>Backend: run_mcp_tool(server_url, tool_name, tool_arguments)
    Backend->>MCPClient: invoke tool with args
    MCPClient->>Server: execute tool
    Server-->>MCPClient: returns result (text/json/image)
    MCPClient-->>Backend: parsed result
    Backend-->>Frontend: MCPToolOutputResponse
    Frontend->>User: render formatted output (card/image/code/text)
Loading

Estimated code review effort

๐ŸŽฏ 4 (Complex) | โฑ๏ธ ~45 minutes

Possibly related PRs

Suggested labels

Possible security concern, Review effort 4/5

Suggested reviewers

  • ntindle
  • Swiftyos
  • kcze
  • Bentlybro

Poem

๐Ÿ‡
I sniff the host and hop the wire,
I fetch the tools that you require,
I open OAuth, stash the key,
Then paint results for you to see โ€”
Hooray, the MCP replied with glee!

๐Ÿšฅ Pre-merge checks | โœ… 2 | โŒ 1

โŒ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage โš ๏ธ Warning Docstring coverage is 55.93% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
โœ… Passed checks (2 passed)
Check name Status Explanation
Title check โœ… Passed The title clearly and specifically describes the main feature being added: a new MCP tool for server discovery and execution in the Otto copilot.
Description check โœ… Passed The description thoroughly explains the motivation, implementation, changes made, and includes a test plan, directly addressing the pull request's MCP tool integration feature.

โœ๏ธ Tip: You can configure your own custom pre-merge checks in the settings.

โœจ Finishing Touches
๐Ÿงช Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/mcp-copilot

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

๐Ÿ” PR Overlap Detection

This check compares your PR against all other open PRs targeting the same branch to detect potential merge conflicts early.

๐Ÿ”ด Merge Conflicts Detected

The following PRs have been tested and will have merge conflicts if merged after this PR. Consider coordinating with the authors.

  • feat(frontend/copilot): collapse repeated block executions into grouped summary rowsย #12259 (0ubbe ยท updated 6h ago)

    • ๐Ÿ“ autogpt_platform/frontend/src/app/
      • (platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx (2 conflicts, ~44 lines)
      • (platform)/copilot/components/ChatMessagesContainer/components/MessagePartRenderer.tsx (3 conflicts, ~17 lines)
      • (platform)/copilot/components/ChatMessagesContainer/components/ThinkingIndicator.tsx (3 conflicts, ~46 lines)
      • (platform)/copilot/useCopilotPage.ts (2 conflicts, ~172 lines)
      • (platform)/copilot/useCopilotStream.ts (4 conflicts, ~28 lines)
      • api/chat/sessions/[sessionId]/stream/route.ts (1 conflict, ~15 lines)
  • feat(copilot): local agent generation with validation, fixing, MCP & sub-agent supportย #12238 (majdyz ยท updated 48m ago)

    • ๐Ÿ“ autogpt_platform/
      • backend/backend/copilot/sdk/service.py (2 conflicts, ~39 lines)
      • backend/backend/copilot/tools/models.py (2 conflicts, ~87 lines)
      • frontend/src/app/api/openapi.json (1 conflict, ~7 lines)
  • feat(backend/api): External API v2ย #12206 (Pwuts ยท updated 28m ago)

    • ๐Ÿ“ autogpt_platform/backend/backend/copilot/tools/
      • __init__.py (1 conflict, ~61 lines)
      • base.py (1 conflict, ~19 lines)

๐ŸŸข Low Risk โ€” File Overlap Only

These PRs touch the same files but different sections (click to expand)

Summary: 3 conflict(s), 0 medium risk, 5 low risk (out of 8 PRs with file overlap)


Auto-generated on push. Ignores: openapi.json, lock files.

@majdyz
Copy link
Contributor Author

majdyz commented Feb 26, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2026

โœ… Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

๐Ÿค– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py`:
- Around line 150-156: The exception handler in run_mcp_tool.py (the except
block that logs an error and returns ErrorResponse) currently returns raw
exception text via message=f"Unexpected error: {e}", which can leak internals;
change the ErrorResponse returned by that except block (in the function handling
the MCP server call) to return a generic, non-sensitive message (e.g.,
"Unexpected server error") and keep session_id as before, while retaining the
detailed exception only in the logger via logger.error(..., exc_info=True) so
the full stack is not sent to the client.
- Around line 98-123: The code currently accepts any server_url and immediately
instantiates MCPClient and calls client.initialize, which allows SSRF; fix by
validating and constraining server_url before using it: parse server_url (e.g.,
in the block that sets server_url) to ensure it uses an allowed scheme
(http/https), enforce a hostname/domain whitelist or at minimum reject hostnames
that resolve to loopback/private/metadata IP ranges, disallow IP literals or
ports if not expected, reject overly long or malformed URLs, and only proceed to
call MCPToolBlock._auto_lookup_credential and create MCPClient/await
client.initialize() after the validation passes; reference server_url,
MCPToolBlock._auto_lookup_credential, MCPClient, and client.initialize when
applying the checks.
- Around line 246-253: The code directly mutates field_info.discriminator_values
when applying the server_url discriminator; instead, call the discriminator
helper to get a properly scoped copy and then add the server_url value. Update
the loop over mcp_block.input_schema.get_credentials_fields_info() to, for each
field_info where field_info.discriminator == "server_url", call
field_info.discriminate() (or the module's discriminate(...) helper) to obtain
the discriminated FieldInfo and then add server_url to that returned object's
discriminator_values rather than mutating the original
field_info.discriminator_values.

In
`@autogpt_platform/frontend/src/app/`(platform)/copilot/tools/RunMCPTool/helpers.tsx:
- Around line 23-24: This file uses manually maintained inline MCP response
interfaces (lines ~23-61) which should be replaced with the generated OpenAPI
models: run "pnpm generate:api" to regenerate the frontend API artifacts, then
import the MCP response types from the generated module
"@/app/api/__generated__/endpoints/" and replace the inline interfaces in
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx;
update all function signatures and variables in this file that reference the
inline MCP types to use the corresponding generated types so the contracts match
backend tools/models.py.

In
`@autogpt_platform/frontend/src/app/`(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx:
- Around line 37-50: The UI currently only sets isError and hides backend error
payloads for part.state === "output-available"; update RunMCPTool.tsx so that
error payloads are surfaced via the ErrorCard component instead of just toggling
red status text: adjust the isError calculation to include isErrorOutput(output)
when output exists and, where setupRequirementsOutput or mcpToolOutput are
computed, branch to render <ErrorCard /> with the backend error message when
isErrorOutput(output) is true (use the same output variable checked by
isMCPToolOutput/isSetupRequirementsOutput). Also ensure any mutation-related
failures use toast notifications and wrap unexpected exceptions with
Sentry.captureException() where errors are caught.

โ„น๏ธ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 195b142 and 556dcec.

๐Ÿ“’ Files selected for processing (9)
  • autogpt_platform/backend/backend/copilot/service.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/find_block.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
๐Ÿ“œ Review details
โฐ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: types
  • GitHub Check: Check PR Status
  • GitHub Check: end-to-end tests
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.11)
๐Ÿงฐ Additional context used
๐Ÿ““ Path-based instructions (14)
autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}: Use Node.js 21+ with pnpm package manager for frontend development
Always run 'pnpm format' for formatting and linting code in frontend development

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
autogpt_platform/frontend/**/*.{tsx,ts}

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{tsx,ts}: Use function declarations for components and handlers (not arrow functions) in React components
Only use arrow functions for small inline lambdas (map, filter, etc.) in React components
Use PascalCase for component names and camelCase with 'use' prefix for hook names in React
Use Tailwind CSS utilities only for styling in frontend components
Use design system components from 'src/components/' (atoms, molecules, organisms) in frontend development
Never use 'src/components/legacy/' in frontend code
Only use Phosphor Icons (@phosphor-icons/react) for icons in frontend components
Use generated API hooks from '@/app/api/generated/endpoints/' instead of deprecated 'BackendAPI' or 'src/lib/autogpt-server-api/
'
Use React Query for server state (via generated hooks) in frontend development
Default to client components ('use client') in Next.js; only use server components for SEO or extreme TTFB needs
Use '' component for rendering errors in frontend UI; use toast notifications for mutation errors; use 'Sentry.captureException()' for manual exceptions
Separate render logic from data/behavior in React components; keep comments minimal (code should be self-documenting)

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
autogpt_platform/frontend/**/*.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{ts,tsx}: No barrel files or 'index.ts' re-exports in frontend code
Regenerate API hooks with 'pnpm generate:api' after backend OpenAPI spec changes in frontend development

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
autogpt_platform/frontend/src/**/*.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/frontend/CLAUDE.md)

autogpt_platform/frontend/src/**/*.{ts,tsx}: Fully capitalize acronyms in symbols, e.g. graphID, useBackendAPI
Use function declarations (not arrow functions) for components and handlers
Separate render logic (.tsx) from business logic (use*.ts hooks)
Use shadcn/ui (Radix UI primitives) with Tailwind CSS styling for UI components
Use Phosphor Icons only for icons
Use ErrorCard for render errors, toast for mutations, and Sentry for exceptions
Use design system components from src/components/ (atoms, molecules, organisms)
Never use src/components/__legacy__/* components
Use generated API hooks from @/app/api/__generated__/endpoints/ with pattern use{Method}{Version}{OperationName}
Use Tailwind CSS only for styling, with design tokens
Do not use useCallback or useMemo unless asked to optimize a given function
Never type with any unless a variable/attribute can ACTUALLY be of any type

autogpt_platform/frontend/src/**/*.{ts,tsx}: Structure components as ComponentName/ComponentName.tsx + useComponentName.ts + helpers.ts and use design system components from src/components/ (atoms, molecules, organisms)
Use generated API hooks from @/app/api/__generated__/endpoints/ with pattern use{Method}{Version}{OperationName} and regenerate with pnpm generate:api
Use function declarations (not arrow functions) for components and handlers
Separate render logic from business logic with component.tsx + useComponent.ts + helpers.ts structure
Colocate state when possible, avoid creating large components, use sub-components in local /components folder
Avoid large hooks, abstract logic into helpers.ts files when sensible
Use arrow functions only for callbacks, not for component declarations
Avoid comments at all times unless the code is very complex
Do not use useCallback or useMemo unless asked to optimize a given function

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
autogpt_platform/frontend/src/app/(platform)/**/components/**/*.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/frontend/CLAUDE.md)

Put sub-components in local components/ folder within feature directories

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
autogpt_platform/frontend/src/**/*.tsx

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/frontend/CLAUDE.md)

Component props should be type Props = { ... } (not exported) unless it needs to be used outside the component

Component props should be interface Props { ... } (not exported) unless the interface needs to be used outside the component

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
autogpt_platform/frontend/**/*.{js,jsx,ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

autogpt_platform/frontend/**/*.{js,jsx,ts,tsx}: Format frontend code using pnpm format
Never use components from src/components/__legacy__/*

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
autogpt_platform/frontend/**/*.{js,jsx,ts,tsx,css}

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Use Tailwind CSS only for styling, use design tokens, and use Phosphor Icons only

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
autogpt_platform/**/*.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Never type with any, if no types available use unknown

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
autogpt_platform/frontend/src/app/(platform)/**/*.tsx

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

If adding protected frontend routes, update frontend/lib/supabase/middleware.ts

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
autogpt_platform/backend/**/*.py

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/backend/**/*.py: Use Python 3.11 (required; managed by Poetry via pyproject.toml) for backend development
Always run 'poetry run format' (Black + isort) before linting in backend development
Always run 'poetry run lint' (ruff) after formatting in backend development

Files:

  • autogpt_platform/backend/backend/copilot/service.py
  • autogpt_platform/backend/backend/copilot/tools/find_block.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/**/*.{py,txt}

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)

Use poetry run prefix for all Python commands, including testing, linting, formatting, and migrations

Files:

  • autogpt_platform/backend/backend/copilot/service.py
  • autogpt_platform/backend/backend/copilot/tools/find_block.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/backend/**/*.py

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)

Use Prisma ORM for database operations in PostgreSQL with pgvector for embeddings

Files:

  • autogpt_platform/backend/backend/copilot/service.py
  • autogpt_platform/backend/backend/copilot/tools/find_block.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/**/*.py

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Format Python code with poetry run format

Files:

  • autogpt_platform/backend/backend/copilot/service.py
  • autogpt_platform/backend/backend/copilot/tools/find_block.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿง  Learnings (14)
๐Ÿ“š Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/frontend/**/*.{tsx,ts} : Use '<ErrorCard />' component for rendering errors in frontend UI; use toast notifications for mutation errors; use 'Sentry.captureException()' for manual exceptions

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
๐Ÿ“š Learning: 2026-02-04T16:50:33.615Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-04T16:50:33.615Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : Use ErrorCard for render errors, toast for mutations, and Sentry for exceptions

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
๐Ÿ“š Learning: 2026-02-26T10:12:58.845Z
Learnt from: 0ubbe
Repo: Significant-Gravitas/AutoGPT PR: 12207
File: autogpt_platform/frontend/src/components/ai-elements/conversation.tsx:0-0
Timestamp: 2026-02-26T10:12:58.845Z
Learning: Guideline: Do not apply dark mode CSS classes (e.g., dark:text-*) to copilot UI components until dark mode support is implemented. Applies to all copilot-related components (paths containing /copilot/). When reviewing, search for dark:* class names within copilot components and refactor to use conditional class sets or feature-flag gates, ensuring no dark-mode styles are present in the code paths that render copilot UI unless dark mode support is officially enabled.

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx
๐Ÿ“š Learning: 2026-02-04T16:50:51.495Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-04T16:50:51.495Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : Separate render logic from business logic with component.tsx + useComponent.ts + helpers.ts structure

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:50:33.615Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-04T16:50:33.615Z
Learning: Applies to autogpt_platform/frontend/src/components/**/*.{ts,tsx} : Structure components as `ComponentName/ComponentName.tsx` + `useComponentName.ts` + `helpers.ts`

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:50:51.495Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-04T16:50:51.495Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : Structure components as `ComponentName/ComponentName.tsx` + `useComponentName.ts` + `helpers.ts` and use design system components from `src/components/` (atoms, molecules, organisms)

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:50:51.495Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-04T16:50:51.495Z
Learning: Applies to autogpt_platform/frontend/src/**/*.tsx : Component props should be `interface Props { ... }` (not exported) unless the interface needs to be used outside the component

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/frontend/src/components/**/*.{tsx,ts} : Structure React components as: ComponentName/ComponentName.tsx + useComponentName.ts + helpers.ts (exception: small 3-4 line components can be inline; render-only components can be direct files)

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:50:33.615Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-04T16:50:33.615Z
Learning: Applies to autogpt_platform/frontend/src/**/*.tsx : Component props should be `type Props = { ... }` (not exported) unless it needs to be used outside the component

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/frontend/**/*.{tsx,ts} : Use PascalCase for component names and camelCase with 'use' prefix for hook names in React

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:50:33.615Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-04T16:50:33.615Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : Separate render logic (`.tsx`) from business logic (`use*.ts` hooks)

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/frontend/**/*.{tsx,ts} : Separate render logic from data/behavior in React components; keep comments minimal (code should be self-documenting)

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/frontend/**/*.{stories.tsx,stories.ts} : Add/update Storybook stories for UI components in frontend development

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:50:51.495Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-04T16:50:51.495Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : Avoid large hooks, abstract logic into `helpers.ts` files when sensible

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
๐Ÿงฌ Code graph analysis (7)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx (2)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx (1)
  • MCPToolOutputResult (40-48)
autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolAccordion/AccordionContent.tsx (5)
  • ContentGrid (9-17)
  • ContentMessage (112-124)
  • ContentCard (23-40)
  • ContentCardTitle (60-75)
  • ContentCodeBlock (144-161)
autogpt_platform/backend/backend/copilot/tools/find_block.py (1)
autogpt_platform/backend/backend/blocks/_base.py (1)
  • BlockType (56-67)
autogpt_platform/backend/backend/copilot/tools/__init__.py (1)
autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py (1)
  • RunMCPToolTool (32-297)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx (4)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx (7)
  • getAnimationText (147-178)
  • getRunMCPToolOutput (125-128)
  • isErrorOutput (88-94)
  • isSetupRequirementsOutput (79-86)
  • isMCPToolOutput (73-77)
  • ToolIcon (180-202)
  • serverHost (139-145)
autogpt_platform/frontend/src/app/(platform)/copilot/components/MorphingTextAnimation/MorphingTextAnimation.tsx (1)
  • MorphingTextAnimation (9-54)
autogpt_platform/frontend/src/app/(platform)/copilot/components/ToolAccordion/ToolAccordion.tsx (1)
  • ToolAccordion (21-102)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx (1)
  • MCPToolOutputCard (26-51)
autogpt_platform/backend/backend/copilot/tools/models.py (3)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx (1)
  • MCPToolInfo (26-30)
autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py (2)
  • name (44-45)
  • description (48-56)
autogpt_platform/backend/backend/copilot/response_model.py (1)
  • ResponseType (20-44)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx (3)
autogpt_platform/backend/backend/copilot/tools/models.py (2)
  • MCPToolInfo (485-490)
  • SetupRequirementsResponse (176-182)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/FindBlocks/helpers.tsx (1)
  • parseOutput (6-24)
autogpt_platform/frontend/src/app/(platform)/copilot/components/OrbitLoader/OrbitLoader.tsx (1)
  • OrbitLoader (9-28)
autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx (1)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx (1)
  • RunMCPToolComponent (31-83)
๐Ÿ”‡ Additional comments (7)
autogpt_platform/backend/backend/copilot/tools/__init__.py (1)

23-23: MCP tool registry integration is wired correctly.

The import and TOOL_REGISTRY entry follow the existing pattern, and the tool will be automatically exposed via tools generation.

Also applies to: 49-49

autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx (1)

26-26: tool-run_mcp_tool routing is integrated cleanly.

The new case is consistent with the existing tool-rendering switch and correctly delegates UI rendering to RunMCPToolComponent.

Also applies to: 329-335

autogpt_platform/backend/backend/copilot/tools/find_block.py (1)

35-35: Excluding BlockType.MCP_TOOL here is the right safeguard.

This keeps find_block aligned with the dedicated MCP execution flow.

autogpt_platform/backend/backend/copilot/service.py (1)

110-110: MCP prompt guidance additions are clear and consistent.

The instructions preserve the intended two-step flow and explicitly handle auth confirmation before retrying execution.

Also applies to: 141-153, 173-173

autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx (1)

16-24: Result rendering split (JSON vs plain text) is solid.

formatResult and the conditional ContentCodeBlock/text path are robust and keep output readable.

Also applies to: 33-49

autogpt_platform/backend/backend/copilot/tools/models.py (1)

51-53: MCP response model additions are well-structured.

The new enum values and Pydantic models are consistent with the two-stage MCP discovery/execution contract.

Also applies to: 484-508

autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py (1)

121-132: No resource cleanup required for MCPClient.

MCPClient does not maintain persistent sessions or streams. Each HTTP request creates a fresh Requests object that is not stored as instance stateโ€”only simple metadata (url, token, request IDs) are retained. There is no resource leak concern and no explicit cleanup needed.

Likely an incorrect or invalid review comment.

@majdyz
Copy link
Contributor Author

majdyz commented Feb 26, 2026

Addressing CodeRabbit review (commit 2a3efca):

[SSRF โ€” run_mcp_tool.py:123] โœ… Fixed โ€” added await validate_url(server_url, trusted_origins=[]) before MCPClient creation. Uses the same backend.util.request.validate_url that web_fetch uses โ€” blocks loopback, private IP ranges, and invalid schemes. Returns ErrorResponse on ValueError.

[Raw exception exposure โ€” run_mcp_tool.py:156] โœ… Fixed โ€” generic except Exception now logs the full traceback server-side but returns a sanitized "An unexpected error occurred connecting to the MCP server. Please try again." message to the client.

[Shared state mutation โ€” run_mcp_tool.py:253] โœ… Safe โ€” get_credentials_fields_info() calls CredentialsFieldInfo.model_validate() for each field, returning fresh objects every invocation. No singleton/class-level state. Verified in backend/blocks/_base.py:296-318.

[Inline interfaces instead of generated types โ€” helpers.tsx:24] โŒ Not applicable โ€” MCPToolsDiscoveredResponse, MCPToolOutputResult, etc. are returned as embedded JSON within the SSE stream, not as first-class REST API endpoints. They are not exposed in openapi.json as standalone schemas (only the ResponseType enum values were added). The pattern of inline types in helpers.tsx matches the existing RunBlock/helpers.tsx approach for the same reason.

[Error card โ€” RunMCPTool.tsx:50] โœ… Fixed โ€” added an error detail card that renders errorOutput.message and optionally errorOutput.error when the output is an MCPErrorOutput, matching the visibility of error messages in RunBlock/ErrorCard.

@majdyz
Copy link
Contributor Author

majdyz commented Feb 27, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

โœ… Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

โ™ป๏ธ Duplicate comments (1)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx (1)

68-77: โš ๏ธ Potential issue | ๐ŸŸ  Major

Use <ErrorCard /> for MCP render errors instead of a custom red container.

This still bypasses the shared error UI contract and duplicates styling/behavior that should stay centralized.

Suggested fix
+import { ErrorCard } from "@/components/molecules/ErrorCard/ErrorCard";
 import { PlugsConnectedIcon } from "@phosphor-icons/react";
@@
-      {/* Error detail card */}
       {errorOutput && (
-        <div className="mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700">
-          {errorOutput.message}
-          {errorOutput.error && (
-            <pre className="mt-1 whitespace-pre-wrap break-words text-xs opacity-80">
-              {errorOutput.error}
-            </pre>
-          )}
-        </div>
+        <div className="mt-2">
+          <ErrorCard
+            responseError={{
+              message: errorOutput.message,
+              error: errorOutput.error ?? undefined,
+            }}
+            context="execution"
+          />
+        </div>
       )}

As per coding guidelines: "Use '' component for rendering errors in frontend UI; use toast notifications for mutation errors; use 'Sentry.captureException()' for manual exceptions".

๐Ÿค– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@autogpt_platform/frontend/src/app/`(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
around lines 68 - 77, Replace the custom red container rendering in
RunMCPTool.tsx with the shared ErrorCard component: where the code currently
checks errorOutput and renders the div with errorOutput.message and
errorOutput.error, instead render <ErrorCard error={errorOutput} /> (or pass the
appropriate props required by ErrorCard) so the shared UI/behavior is used;
ensure you remove the duplicated styling/markup and keep any existing logic that
decides when to show errors, and if this is a mutation error follow the
guideline to use a toast instead and call Sentry.captureException() for manual
exception reporting.
๐Ÿค– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py`:
- Around line 309-313: The _server_host function should not return
urlparse(server_url).netloc because that can include credentials; instead parse
with urlparse(server_url), use parsed.hostname (and if parsed.port present
append f":{parsed.port}") to preserve port without leaking userinfo, and on any
parsing failure fall back to a sanitized server_url with userinfo stripped or
the original string; update the return logic in _server_host to use
parsed.hostname and parsed.port rather than netloc and keep the try/except
around urlparse(server_url).
- Line 100: The assignment to tool_arguments in run_mcp_tool (variable
tool_arguments in run_mcp_tool.py) can accept non-object types and should be
validated before being passed to MCP; update the run_mcp_tool function to check
that kwargs.get("tool_arguments") is a dict (or mapping) and if not either
coerce/normalize to an empty dict or raise a descriptive error, then use the
validated dict for the tool_arguments variable so downstream MCP calls only
receive objects; reference the tool_arguments variable and the run_mcp_tool
entry point when making this change.

---

Duplicate comments:
In
`@autogpt_platform/frontend/src/app/`(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx:
- Around line 68-77: Replace the custom red container rendering in
RunMCPTool.tsx with the shared ErrorCard component: where the code currently
checks errorOutput and renders the div with errorOutput.message and
errorOutput.error, instead render <ErrorCard error={errorOutput} /> (or pass the
appropriate props required by ErrorCard) so the shared UI/behavior is used;
ensure you remove the duplicated styling/markup and keep any existing logic that
decides when to show errors, and if this is a mutation error follow the
guideline to use a toast instead and call Sentry.captureException() for manual
exception reporting.

โ„น๏ธ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 556dcec and 27b2eba.

๐Ÿ“’ Files selected for processing (5)
  • autogpt_platform/backend/backend/copilot/service.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
  • autogpt_platform/frontend/src/app/api/openapi.json
๐Ÿšง Files skipped from review as they are similar to previous changes (1)
  • autogpt_platform/backend/backend/copilot/service.py
๐Ÿ“œ Review details
๐Ÿงฐ Additional context used
๐Ÿ““ Path-based instructions (16)
autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}: Use Node.js 21+ with pnpm package manager for frontend development
Always run 'pnpm format' for formatting and linting code in frontend development

autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}: Run pnpm format to auto-fix formatting issues before completing work
Run pnpm lint to check for lint errors and fix any that appear before completing work

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
autogpt_platform/frontend/**/*.{tsx,ts}

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{tsx,ts}: Use function declarations for components and handlers (not arrow functions) in React components
Only use arrow functions for small inline lambdas (map, filter, etc.) in React components
Use PascalCase for component names and camelCase with 'use' prefix for hook names in React
Use Tailwind CSS utilities only for styling in frontend components
Use design system components from 'src/components/' (atoms, molecules, organisms) in frontend development
Never use 'src/components/legacy/' in frontend code
Only use Phosphor Icons (@phosphor-icons/react) for icons in frontend components
Use generated API hooks from '@/app/api/generated/endpoints/' instead of deprecated 'BackendAPI' or 'src/lib/autogpt-server-api/
'
Use React Query for server state (via generated hooks) in frontend development
Default to client components ('use client') in Next.js; only use server components for SEO or extreme TTFB needs
Use '' component for rendering errors in frontend UI; use toast notifications for mutation errors; use 'Sentry.captureException()' for manual exceptions
Separate render logic from data/behavior in React components; keep comments minimal (code should be self-documenting)

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
autogpt_platform/frontend/**/*.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{ts,tsx}: No barrel files or 'index.ts' re-exports in frontend code
Regenerate API hooks with 'pnpm generate:api' after backend OpenAPI spec changes in frontend development

Run pnpm types to check for type errors and fix any that appear before completing work

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
autogpt_platform/frontend/**/*.{js,jsx,ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

autogpt_platform/frontend/**/*.{js,jsx,ts,tsx}: Format frontend code using pnpm format
Never use components from src/components/__legacy__/*

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
autogpt_platform/frontend/src/**/*.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

autogpt_platform/frontend/src/**/*.{ts,tsx}: Structure components as ComponentName/ComponentName.tsx + useComponentName.ts + helpers.ts and use design system components from src/components/ (atoms, molecules, organisms)
Use generated API hooks from @/app/api/__generated__/endpoints/ with pattern use{Method}{Version}{OperationName} and regenerate with pnpm generate:api
Use function declarations (not arrow functions) for components and handlers
Separate render logic from business logic with component.tsx + useComponent.ts + helpers.ts structure
Colocate state when possible, avoid creating large components, use sub-components in local /components folder
Avoid large hooks, abstract logic into helpers.ts files when sensible
Use arrow functions only for callbacks, not for component declarations
Avoid comments at all times unless the code is very complex
Do not use useCallback or useMemo unless asked to optimize a given function

autogpt_platform/frontend/src/**/*.{ts,tsx}: Use function declarations (not arrow functions) for components and handlers
Use type-safe generated API hooks via Orval + React Query for data fetching
Use React Query for server state management and co-locate UI state in components/hooks
Separate render logic (.tsx) from business logic (use*.ts hooks)
Use only shadcn/ui (Radix UI primitives) with Tailwind CSS for UI components
Use Phosphor Icons only for all icon implementations
Use ErrorCard component for render errors, toast for mutations, and Sentry for exceptions
Use design system components from src/components/ (atoms, molecules, organisms)
Never use src/components/__legacy__/* components
Use generated API hooks from @/app/api/__generated__/endpoints/ with pattern use{Method}{Version}{OperationName}
Use Tailwind CSS only for styling with design tokens
Do not use useCallback or useMemo unless asked to optimize a specific function
Never type with any unless a variable/attribute can actually be of any type

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
autogpt_platform/frontend/**/*.{js,jsx,ts,tsx,css}

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Use Tailwind CSS only for styling, use design tokens, and use Phosphor Icons only

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
autogpt_platform/frontend/src/**/*.tsx

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Component props should be interface Props { ... } (not exported) unless the interface needs to be used outside the component

Use type Props = { ... } (not exported) for component props unless used outside the component

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
autogpt_platform/**/*.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Never type with any, if no types available use unknown

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
autogpt_platform/frontend/src/app/(platform)/**/*.tsx

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

If adding protected frontend routes, update frontend/lib/supabase/middleware.ts

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
autogpt_platform/frontend/src/**/*.{ts,tsx,js,jsx}

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/frontend/CLAUDE.md)

Fully capitalize acronyms in symbols, e.g. graphID, useBackendAPI

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
autogpt_platform/frontend/src/**/components/**/*.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/frontend/CLAUDE.md)

Put sub-components in a local components/ folder within the feature directory

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
autogpt_platform/frontend/src/**/[A-Z]*/**/*.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/frontend/CLAUDE.md)

Structure components as ComponentName/ComponentName.tsx + useComponentName.ts + helpers.ts

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
autogpt_platform/backend/**/*.py

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/backend/**/*.py: Use Python 3.11 (required; managed by Poetry via pyproject.toml) for backend development
Always run 'poetry run format' (Black + isort) before linting in backend development
Always run 'poetry run lint' (ruff) after formatting in backend development

Files:

  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/**/*.{py,txt}

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)

Use poetry run prefix for all Python commands, including testing, linting, formatting, and migrations

Files:

  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/backend/**/*.py

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)

Use Prisma ORM for database operations in PostgreSQL with pgvector for embeddings

Files:

  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/**/*.py

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Format Python code with poetry run format

Files:

  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿง  Learnings (17)
๐Ÿ“š Learning: 2026-02-04T16:50:51.495Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-04T16:50:51.495Z
Learning: Applies to autogpt_platform/frontend/src/**/*.tsx : Component props should be `interface Props { ... }` (not exported) unless the interface needs to be used outside the component

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
๐Ÿ“š Learning: 2026-02-26T21:29:44.094Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-26T21:29:44.094Z
Learning: Applies to autogpt_platform/frontend/src/**/*.tsx : Use `type Props = { ... }` (not exported) for component props unless used outside the component

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
๐Ÿ“š Learning: 2026-02-26T21:29:44.094Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-26T21:29:44.094Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : Use ErrorCard component for render errors, toast for mutations, and Sentry for exceptions

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/frontend/**/*.{tsx,ts} : Use '<ErrorCard />' component for rendering errors in frontend UI; use toast notifications for mutation errors; use 'Sentry.captureException()' for manual exceptions

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-26T10:12:58.845Z
Learnt from: 0ubbe
Repo: Significant-Gravitas/AutoGPT PR: 12207
File: autogpt_platform/frontend/src/components/ai-elements/conversation.tsx:0-0
Timestamp: 2026-02-26T10:12:58.845Z
Learning: Guideline: Do not apply dark mode CSS classes (e.g., dark:text-*) to copilot UI components until dark mode support is implemented. Applies to all copilot-related components (paths containing /copilot/). When reviewing, search for dark:* class names within copilot components and refactor to use conditional class sets or feature-flag gates, ensuring no dark-mode styles are present in the code paths that render copilot UI unless dark mode support is officially enabled.

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-27T07:26:32.993Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx:23-24
Timestamp: 2026-02-27T07:26:32.993Z
Learning: In autogpt_platform/frontend/src/app/(platform)/copilot/tools/**/helpers.tsx files, inline TypeScript interfaces for tool response types (e.g., MCPToolsDiscoveredOutput, BlockDetailsResponse) are intentional for SSE stream payloads that don't appear in openapi.json. Only ResponseType enum values are generated. This pattern should not be flagged for replacement with generated types.

Applied to files:

  • autogpt_platform/frontend/src/app/api/openapi.json
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-01-19T07:20:23.494Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 11795
File: autogpt_platform/backend/backend/api/features/chat/tools/utils.py:92-111
Timestamp: 2026-01-19T07:20:23.494Z
Learning: In autogpt_platform/backend/backend/api/features/chat/tools/utils.py, the _serialize_missing_credential function uses next(iter(field_info.provider)) for provider selection. The PR author confirmed this non-deterministic provider selection is acceptable because the function returns both "type" (single, for backward compatibility) and "types" (full array), which achieves the primary goal of deterministic credential type presentation.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿ“š Learning: 2026-02-04T16:50:51.495Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-04T16:50:51.495Z
Learning: Applies to autogpt_platform/**/data/*.py : For changes touching `data/*.py`, validate user ID checks or explain why not needed

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿ“š Learning: 2026-02-26T17:02:22.448Z
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12211
File: .pre-commit-config.yaml:160-179
Timestamp: 2026-02-26T17:02:22.448Z
Learning: Keep the pre-commit hook pattern broad for autogpt_platform/backend to ensure OpenAPI schema changes are captured. Do not narrow to backend/api/ alone, since the generated schema depends on Pydantic models across multiple directories (backend/data/, backend/blocks/, backend/copilot/, backend/integrations/, backend/util/). Narrowing could miss schema changes and cause frontend type desynchronization.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿ“š Learning: 2026-02-26T21:29:44.094Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-26T21:29:44.094Z
Learning: Applies to autogpt_platform/frontend/**/*.{ts,tsx} : Run `pnpm types` to check for type errors and fix any that appear before completing work

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:50:51.495Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-04T16:50:51.495Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : Separate render logic from business logic with component.tsx + useComponent.ts + helpers.ts structure

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-26T21:29:44.094Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-26T21:29:44.094Z
Learning: Applies to autogpt_platform/frontend/**/*.{ts,tsx,js,jsx} : Run `pnpm lint` to check for lint errors and fix any that appear before completing work

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:50:51.495Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-04T16:50:51.495Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : Structure components as `ComponentName/ComponentName.tsx` + `useComponentName.ts` + `helpers.ts` and use design system components from `src/components/` (atoms, molecules, organisms)

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-26T21:29:44.094Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-26T21:29:44.094Z
Learning: Applies to autogpt_platform/frontend/src/**/[A-Z]*/**/*.{ts,tsx} : Structure components as ComponentName/ComponentName.tsx + useComponentName.ts + helpers.ts

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/frontend/src/components/**/*.{tsx,ts} : Structure React components as: ComponentName/ComponentName.tsx + useComponentName.ts + helpers.ts (exception: small 3-4 line components can be inline; render-only components can be direct files)

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-26T21:29:44.094Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-26T21:29:44.094Z
Learning: Applies to autogpt_platform/frontend/**/*.{ts,tsx,js,jsx} : Run `pnpm format` to auto-fix formatting issues before completing work

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿ“š Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/frontend/**/*.{stories.tsx,stories.ts} : Add/update Storybook stories for UI components in frontend development

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
๐Ÿงฌ Code graph analysis (3)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx (1)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunAgent/components/SetupRequirementsCard/SetupRequirementsCard.tsx (1)
  • SetupRequirementsCard (22-118)
autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py (6)
autogpt_platform/backend/backend/util/request.py (3)
  • json (295-301)
  • request (365-402)
  • text (303-313)
autogpt_platform/backend/backend/blocks/mcp/block.py (1)
  • _auto_lookup_credential (209-244)
autogpt_platform/backend/backend/blocks/mcp/client.py (5)
  • MCPClient (45-323)
  • MCPClientError (39-42)
  • initialize (259-277)
  • list_tools (279-298)
  • call_tool (300-323)
autogpt_platform/backend/backend/copilot/tools/utils.py (1)
  • build_missing_credentials_from_field_info (131-142)
autogpt_platform/backend/backend/copilot/tools/base.py (1)
  • BaseTool (16-119)
autogpt_platform/backend/backend/copilot/tools/models.py (8)
  • ErrorResponse (206-211)
  • MCPToolInfo (485-490)
  • MCPToolOutputResponse (501-508)
  • MCPToolsDiscoveredResponse (493-498)
  • SetupInfo (161-173)
  • SetupRequirementsResponse (176-182)
  • ToolResponseBase (57-62)
  • UserReadiness (153-158)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx (3)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx (8)
  • getAnimationText (147-178)
  • getRunMCPToolOutput (125-128)
  • isErrorOutput (88-94)
  • isSetupRequirementsOutput (79-86)
  • isMCPToolOutput (73-77)
  • MCPErrorOutput (50-55)
  • ToolIcon (180-202)
  • serverHost (139-145)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx (1)
  • SetupRequirementsCard (28-156)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx (1)
  • MCPToolOutputCard (26-51)
๐Ÿ”‡ Additional comments (3)
autogpt_platform/frontend/src/app/api/openapi.json (1)

11173-11175: Looks good โ€” ResponseType now covers MCP tool flow outputs.

Adding "mcp_tools_discovered" and "mcp_tool_output" in the enum is the correct OpenAPI surface for MCP response routing on the frontend.

Based on learnings: In autogpt_platform/frontend/src/app/(platform)/copilot/tools/**/helpers.tsx, inline TypeScript interfaces for SSE payloads are intentional, and only ResponseType enum values are generated from OpenAPI.

autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py (1)

115-123: SSRF guard is correctly placed before outbound MCP connection.

Good placement of URL validation before credential lookup/client initialization; this prevents unsafe network calls early.

autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx (1)

20-25: Nice extension point for setup messaging.

retryInstruction and credentialsLabel are integrated cleanly with sensible fallbacks, so existing flows remain stable while MCP gets context-specific copy.

Also applies to: 28-32, 94-94, 108-108

@majdyz majdyz marked this pull request as ready for review February 27, 2026 13:45
@majdyz majdyz requested a review from a team as a code owner February 27, 2026 13:45
@majdyz majdyz requested review from Bentlybro and kcze and removed request for a team February 27, 2026 13:45
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

๐Ÿค– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py`:
- Around line 151-171: The except blocks log the raw server_url which can expose
embedded credentials; update the code in run_mcp_tool.py to sanitize server_url
before logging or including it in ErrorResponse by introducing/using a helper
(e.g., sanitize_url or redact_credentials) that strips user:pass@ from the URL,
then replace direct uses of server_url in the logger.warning calls and in the
ErrorResponse message (and any other logging/error paths in this function,
including before calling _build_setup_requirements) with the sanitized value so
credentials are never written to logs.

In `@autogpt_platform/frontend/src/app/api/openapi.json`:
- Around line 9983-9995: Update the OpenAPI schema for the MCPToolInfo model so
that input_schema is listed in the model's required array: add "input_schema" to
the required properties for MCPToolInfo (the object that defines "name",
"description", and "input_schema") so generated frontend types treat
input_schema as non-optional; target the MCPToolInfo definition and modify its
"required" array to include "input_schema".

โ„น๏ธ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 27b2eba and a592161.

๐Ÿ“’ Files selected for processing (7)
  • autogpt_platform/backend/backend/api/features/chat/routes.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
  • autogpt_platform/frontend/src/app/api/openapi.json
๐Ÿšง Files skipped from review as they are similar to previous changes (1)
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
๐Ÿ“œ Review details
๐Ÿงฐ Additional context used
๐Ÿ““ Path-based instructions (20)
autogpt_platform/backend/**/*.py

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/backend/**/*.py: Use Python 3.11 (required; managed by Poetry via pyproject.toml) for backend development
Always run 'poetry run format' (Black + isort) before linting in backend development
Always run 'poetry run lint' (ruff) after formatting in backend development

Files:

  • autogpt_platform/backend/backend/api/features/chat/routes.py
  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/backend/api/features/**/*.py

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

Update routes in '/backend/backend/api/features/' and add/update Pydantic models in the same directory for API development

When modifying API routes, update corresponding Pydantic models in the same directory and write tests alongside the route file

Files:

  • autogpt_platform/backend/backend/api/features/chat/routes.py
autogpt_platform/backend/**/*.{py,txt}

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)

Use poetry run prefix for all Python commands, including testing, linting, formatting, and migrations

Files:

  • autogpt_platform/backend/backend/api/features/chat/routes.py
  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/backend/api/**/*.py

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)

autogpt_platform/backend/backend/api/**/*.py: Use FastAPI for building REST and WebSocket endpoints
Use JWT-based authentication with Supabase integration

Files:

  • autogpt_platform/backend/backend/api/features/chat/routes.py
autogpt_platform/backend/backend/**/*.py

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)

Use Prisma ORM for database operations in PostgreSQL with pgvector for embeddings

Files:

  • autogpt_platform/backend/backend/api/features/chat/routes.py
  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/**/*.py

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Format Python code with poetry run format

Files:

  • autogpt_platform/backend/backend/api/features/chat/routes.py
  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}: Use Node.js 21+ with pnpm package manager for frontend development
Always run 'pnpm format' for formatting and linting code in frontend development

autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}: Run pnpm format to auto-fix formatting issues before completing work
Run pnpm lint to check for lint errors and fix any that appear before completing work

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
autogpt_platform/frontend/**/*.{tsx,ts}

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{tsx,ts}: Use function declarations for components and handlers (not arrow functions) in React components
Only use arrow functions for small inline lambdas (map, filter, etc.) in React components
Use PascalCase for component names and camelCase with 'use' prefix for hook names in React
Use Tailwind CSS utilities only for styling in frontend components
Use design system components from 'src/components/' (atoms, molecules, organisms) in frontend development
Never use 'src/components/legacy/' in frontend code
Only use Phosphor Icons (@phosphor-icons/react) for icons in frontend components
Use generated API hooks from '@/app/api/generated/endpoints/' instead of deprecated 'BackendAPI' or 'src/lib/autogpt-server-api/
'
Use React Query for server state (via generated hooks) in frontend development
Default to client components ('use client') in Next.js; only use server components for SEO or extreme TTFB needs
Use '' component for rendering errors in frontend UI; use toast notifications for mutation errors; use 'Sentry.captureException()' for manual exceptions
Separate render logic from data/behavior in React components; keep comments minimal (code should be self-documenting)

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
autogpt_platform/frontend/**/*.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{ts,tsx}: No barrel files or 'index.ts' re-exports in frontend code
Regenerate API hooks with 'pnpm generate:api' after backend OpenAPI spec changes in frontend development

Run pnpm types to check for type errors and fix any that appear before completing work

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
autogpt_platform/frontend/**/*.{js,jsx,ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

autogpt_platform/frontend/**/*.{js,jsx,ts,tsx}: Format frontend code using pnpm format
Never use components from src/components/__legacy__/*

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
autogpt_platform/frontend/src/**/*.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

autogpt_platform/frontend/src/**/*.{ts,tsx}: Structure components as ComponentName/ComponentName.tsx + useComponentName.ts + helpers.ts and use design system components from src/components/ (atoms, molecules, organisms)
Use generated API hooks from @/app/api/__generated__/endpoints/ with pattern use{Method}{Version}{OperationName} and regenerate with pnpm generate:api
Use function declarations (not arrow functions) for components and handlers
Separate render logic from business logic with component.tsx + useComponent.ts + helpers.ts structure
Colocate state when possible, avoid creating large components, use sub-components in local /components folder
Avoid large hooks, abstract logic into helpers.ts files when sensible
Use arrow functions only for callbacks, not for component declarations
Avoid comments at all times unless the code is very complex
Do not use useCallback or useMemo unless asked to optimize a given function

autogpt_platform/frontend/src/**/*.{ts,tsx}: Use function declarations (not arrow functions) for components and handlers
Use type-safe generated API hooks via Orval + React Query for data fetching
Use React Query for server state management and co-locate UI state in components/hooks
Separate render logic (.tsx) from business logic (use*.ts hooks)
Use only shadcn/ui (Radix UI primitives) with Tailwind CSS for UI components
Use Phosphor Icons only for all icon implementations
Use ErrorCard component for render errors, toast for mutations, and Sentry for exceptions
Use design system components from src/components/ (atoms, molecules, organisms)
Never use src/components/__legacy__/* components
Use generated API hooks from @/app/api/__generated__/endpoints/ with pattern use{Method}{Version}{OperationName}
Use Tailwind CSS only for styling with design tokens
Do not use useCallback or useMemo unless asked to optimize a specific function
Never type with any unless a variable/attribute can actually be of any type

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
autogpt_platform/frontend/**/*.{js,jsx,ts,tsx,css}

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Use Tailwind CSS only for styling, use design tokens, and use Phosphor Icons only

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
autogpt_platform/frontend/src/**/*.tsx

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Component props should be interface Props { ... } (not exported) unless the interface needs to be used outside the component

Use type Props = { ... } (not exported) for component props unless used outside the component

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
autogpt_platform/**/*.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Never type with any, if no types available use unknown

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
autogpt_platform/frontend/src/app/(platform)/**/*.tsx

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

If adding protected frontend routes, update frontend/lib/supabase/middleware.ts

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
autogpt_platform/frontend/src/**/*.{ts,tsx,js,jsx}

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/frontend/CLAUDE.md)

Fully capitalize acronyms in symbols, e.g. graphID, useBackendAPI

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
autogpt_platform/frontend/src/**/components/**/*.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/frontend/CLAUDE.md)

Put sub-components in a local components/ folder within the feature directory

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
autogpt_platform/frontend/src/**/[A-Z]*/**/*.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/frontend/CLAUDE.md)

Structure components as ComponentName/ComponentName.tsx + useComponentName.ts + helpers.ts

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
autogpt_platform/backend/**/*test*.py

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Run poetry run test for backend testing (runs pytest with docker based postgres + prisma)

Files:

  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
autogpt_platform/frontend/**/*.{test,spec}.{ts,tsx}

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Run pnpm test or pnpm test-ui for frontend Playwright tests

Files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
๐Ÿง  Learnings (21)
๐Ÿ““ Common learnings
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx:23-24
Timestamp: 2026-02-27T10:45:49.499Z
Learning: As of PR `#12213`, MCP tool response types (MCPToolsDiscoveredResponse, MCPToolOutputResponse) are defined in openapi.json and frontend code in autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx uses the generated types from `@/app/api/__generated__/`. Other tools like RunBlock still use inline TypeScript interfaces (e.g., BlockDetailsResponse) for SSE stream payloads that are not included in openapi.json schemas. The pattern is tool-specific: use generated types when available in openapi.json, use inline types only when the payload schema is truly SSE-stream-only and not exposed via OpenAPI.
๐Ÿ“š Learning: 2026-02-27T10:45:49.499Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx:23-24
Timestamp: 2026-02-27T10:45:49.499Z
Learning: As of PR `#12213`, MCP tool response types (MCPToolsDiscoveredResponse, MCPToolOutputResponse) are defined in openapi.json and frontend code in autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx uses the generated types from `@/app/api/__generated__/`. Other tools like RunBlock still use inline TypeScript interfaces (e.g., BlockDetailsResponse) for SSE stream payloads that are not included in openapi.json schemas. The pattern is tool-specific: use generated types when available in openapi.json, use inline types only when the payload schema is truly SSE-stream-only and not exposed via OpenAPI.

Applied to files:

  • autogpt_platform/backend/backend/api/features/chat/routes.py
  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/frontend/src/app/api/openapi.json
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿ“š Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/backend/backend/api/features/**/*.py : Update routes in '/backend/backend/api/features/' and add/update Pydantic models in the same directory for API development

Applied to files:

  • autogpt_platform/backend/backend/api/features/chat/routes.py
๐Ÿ“š Learning: 2026-02-04T16:50:20.508Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/backend/CLAUDE.md:0-0
Timestamp: 2026-02-04T16:50:20.508Z
Learning: Applies to autogpt_platform/backend/backend/api/features/**/*.py : When modifying API routes, update corresponding Pydantic models in the same directory and write tests alongside the route file

Applied to files:

  • autogpt_platform/backend/backend/api/features/chat/routes.py
๐Ÿ“š Learning: 2026-02-26T17:02:22.448Z
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12211
File: .pre-commit-config.yaml:160-179
Timestamp: 2026-02-26T17:02:22.448Z
Learning: Keep the pre-commit hook pattern broad for autogpt_platform/backend to ensure OpenAPI schema changes are captured. Do not narrow to backend/api/ alone, since the generated schema depends on Pydantic models across multiple directories (backend/data/, backend/blocks/, backend/copilot/, backend/integrations/, backend/util/). Narrowing could miss schema changes and cause frontend type desynchronization.

Applied to files:

  • autogpt_platform/backend/backend/api/features/chat/routes.py
  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿ“š Learning: 2026-02-27T10:45:49.499Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx:23-24
Timestamp: 2026-02-27T10:45:49.499Z
Learning: Prefer using generated OpenAPI types from '@/app/api/__generated__/' for payloads defined in openapi.json (e.g., MCPToolsDiscoveredResponse, MCPToolOutputResponse). Use inline TypeScript interfaces only for payloads that are SSE-stream-only and not exposed via OpenAPI. Apply this pattern to frontend tool components (e.g., RunMCPTool) and related areas where similar SSE/openapi-discrepancies occur; avoid re-implementing types when a generated type is available.

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
๐Ÿ“š Learning: 2026-02-26T21:29:44.094Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-26T21:29:44.094Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : Use ErrorCard component for render errors, toast for mutations, and Sentry for exceptions

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
๐Ÿ“š Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/frontend/**/*.{tsx,ts} : Use '<ErrorCard />' component for rendering errors in frontend UI; use toast notifications for mutation errors; use 'Sentry.captureException()' for manual exceptions

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
๐Ÿ“š Learning: 2026-02-26T10:12:58.845Z
Learnt from: 0ubbe
Repo: Significant-Gravitas/AutoGPT PR: 12207
File: autogpt_platform/frontend/src/components/ai-elements/conversation.tsx:0-0
Timestamp: 2026-02-26T10:12:58.845Z
Learning: Guideline: Do not apply dark mode CSS classes (e.g., dark:text-*) to copilot UI components until dark mode support is implemented. Applies to all copilot-related components (paths containing /copilot/). When reviewing, search for dark:* class names within copilot components and refactor to use conditional class sets or feature-flag gates, ensuring no dark-mode styles are present in the code paths that render copilot UI unless dark mode support is officially enabled.

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
๐Ÿ“š Learning: 2026-01-28T18:29:34.362Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-01-28T18:29:34.362Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/*.test.{tsx,ts} : Use unit tests (Vitest + RTL) for testing pure utility functions and isolated components

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
๐Ÿ“š Learning: 2026-01-28T18:29:34.362Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-01-28T18:29:34.362Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/*.test.{tsx,ts} : Use unit tests (Vitest + RTL) for component state changes and custom hooks

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
๐Ÿ“š Learning: 2026-01-28T18:29:34.362Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-01-28T18:29:34.362Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/__tests__/main.test.tsx : Start integration tests at the page level with a `main.test.tsx` file and split into smaller files as it grows

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
๐Ÿ“š Learning: 2026-01-28T18:29:34.362Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-01-28T18:29:34.362Z
Learning: Applies to autogpt_platform/frontend/src/tests/src/tests/**/*.spec.ts : Place E2E tests (Playwright) in a centralized location for critical user journeys

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
๐Ÿ“š Learning: 2026-02-26T21:29:44.094Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-02-26T21:29:44.094Z
Learning: Applies to autogpt_platform/frontend/**/*.{ts,tsx} : Run `pnpm types` to check for type errors and fix any that appear before completing work

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
๐Ÿ“š Learning: 2026-01-28T18:29:34.362Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-01-28T18:29:34.362Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/*.test.{tsx,ts} : Place unit tests co-located with the source file: `Component.test.tsx` next to `Component.tsx`

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
๐Ÿ“š Learning: 2026-02-04T16:50:51.495Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-04T16:50:51.495Z
Learning: Applies to autogpt_platform/frontend/**/*.{test,spec}.{ts,tsx} : Run `pnpm test` or `pnpm test-ui` for frontend Playwright tests

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
๐Ÿ“š Learning: 2026-01-28T18:29:34.362Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-01-28T18:29:34.362Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/__tests__/*.test.{tsx,ts} : Use integration tests (Vitest + RTL) for user interactions that trigger API calls and feature flows within a single page

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
๐Ÿ“š Learning: 2026-01-28T18:29:34.362Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-01-28T18:29:34.362Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/__tests__/*.test.{tsx,ts} : Mock API requests in integration tests via MSW (Mock Service Worker)

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
๐Ÿ“š Learning: 2026-01-28T18:29:34.362Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-01-28T18:29:34.362Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/__tests__/*.test.{tsx,ts} : Use integration tests (Vitest + RTL) for page-level behavior with mocked API responses and components that fetch data

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx
๐Ÿ“š Learning: 2026-01-19T07:20:23.494Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 11795
File: autogpt_platform/backend/backend/api/features/chat/tools/utils.py:92-111
Timestamp: 2026-01-19T07:20:23.494Z
Learning: In autogpt_platform/backend/backend/api/features/chat/tools/utils.py, the _serialize_missing_credential function uses next(iter(field_info.provider)) for provider selection. The PR author confirmed this non-deterministic provider selection is acceptable because the function returns both "type" (single, for backward compatibility) and "types" (full array), which achieves the primary goal of deterministic credential type presentation.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿ“š Learning: 2026-02-04T16:50:51.495Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-04T16:50:51.495Z
Learning: Applies to autogpt_platform/**/data/*.py : For changes touching `data/*.py`, validate user ID checks or explain why not needed

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿงฌ Code graph analysis (2)
autogpt_platform/backend/backend/api/features/chat/routes.py (1)
autogpt_platform/backend/backend/copilot/tools/models.py (2)
  • MCPToolOutputResponse (501-508)
  • MCPToolsDiscoveredResponse (493-498)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx (1)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx (7)
  • MCPErrorOutput (30-35)
  • isDiscoveryOutput (47-51)
  • RunMCPToolOutput (37-41)
  • isMCPToolOutput (53-57)
  • isSetupRequirementsOutput (59-66)
  • getRunMCPToolOutput (105-108)
  • serverHost (119-125)
๐Ÿ”‡ Additional comments (9)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsx (1)

16-51: Clean output rendering path for both JSON and text.

formatResult plus the isJson branch keeps tool output readable while safely handling non-serializable values. Nice implementation.

autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsx (1)

70-294: Good coverage on parser/type-guard edge cases.

These tests exercise both strict and structural-fallback parsing paths, plus animation text state handling, which reduces regression risk in SSE payload handling.

Based on learnings: Prefer using generated OpenAPI types from @/app/api/__generated__/ for payloads defined in openapi.json (e.g., MCPToolsDiscoveredResponse, MCPToolOutputResponse).

autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py (2)

100-131: Input hardening path looks solid.

Early validation for tool_arguments, missing server_url, and SSRF protection is well placed before network calls.


318-327: _server_host now safely strips userinfo.

Good security-focused helper for display-safe host extraction.

autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py (1)

74-483: Strong async coverage for high-risk branches.

Great job covering auth-required behavior, SSRF-block flow, protocol errors, and non-leaking generic exception handling.

autogpt_platform/backend/backend/api/features/chat/routes.py (1)

43-44: Schema export wiring is correct for MCP responses.

Including both MCP response models in ToolResponseUnion ensures frontend codegen sees the new tool payloads.

As per coding guidelines: "When modifying API routes, update corresponding Pydantic models in the same directory and write tests alongside the route file."

Also applies to: 805-806

autogpt_platform/frontend/src/app/api/openapi.json (3)

989-993: Good update to include MCP response schemas in the dummy codegen export.

This ensures MCP tool responses are emitted in generated frontend API types.


10034-10056: MCPToolsDiscoveredResponse shape looks correct for discovery flow.

server_url and typed tools payload are correctly modeled for the tool-selection step.


11236-11238: ResponseType enum extension is correct.

Adding mcp_tools_discovered and mcp_tool_output keeps discriminated response handling aligned.

Copy link

@autogpt-reviewer autogpt-reviewer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #12213 โ€” feat(copilot): run_mcp_tool โ€” MCP server discovery and execution in Otto

Author: majdyz (Zamil Majdy) | Files: 14 (+1605/-5) | CI: โœ… All green


๐ŸŽฏ Verdict: APPROVE WITH CONDITIONS

What This PR Does

Enables Otto (the AutoGPT copilot) to connect to any MCP (Model Context Protocol) server, discover available tools, and execute them โ€” with the same credential/OAuth UI used in the graph builder. A dedicated run_mcp_tool copilot tool replaces the broken run_block + MCPToolBlock path (which lacked discovery mode and had a credential matching bug).


Specialist Findings

๐Ÿ›ก๏ธ Security โœ… โ€” Well-defended. SSRF protection via validate_url() with empty trusted origins + double-validation in MCPClient. DNS rebinding prevented by IP pinning. Exception messages sanitized. Credential lookup properly scoped by (user_id, server_url). Two advisory notes: MCPClientError messages from remote servers are passed verbatim (low risk, user chose the server), and discover_auth in client.py uses netloc (pre-existing, not in this diff).

๐Ÿ—๏ธ Architecture โš ๏ธ โ€” Approve with conditions. Clean BaseTool conformance, good registry integration. Should fix: (1) MCP result content-parsing logic duplicated between MCPToolBlock.run() and RunMCPToolTool._execute_tool() โ€” extract shared helper. (2) Direct coupling to MCPToolBlock._auto_lookup_credential (private method) โ€” promote to public or extract to shared util. Note: SetupInfo.agent_id overloaded with server_url โ€” fragile but works today.

โšก Performance โš ๏ธ โ€” Acceptable for per-user copilot actions but has improvement opportunities. Should fix (follow-up): (1) New aiohttp.ClientSession per JSON-RPC call (3 sessions per invocation = 3ร— TLS handshake overhead) โ€” reuse session within MCPClient. (2) No tool discovery caching between steps. (3) _auto_lookup_credential fetches all MCP credentials then filters in Python (O(n)). These are pre-existing patterns in MCPClient/MCPToolBlock, not regressions from this PR.

๐Ÿงช Testing โš ๏ธ โ€” Good coverage (504 lines backend, 294 lines frontend), all CI green. Should fix: (1) No tests for image/resource MCP content types despite dedicated code paths. (2) No tests for multi-item or empty content results. (3) _build_setup_requirements only tested via mock โ€” ~50 lines of credential wiring logic with zero direct coverage. (4) No render tests for RunMCPToolComponent. Nice to have: Empty tool list edge case, validate_url arg assertion.

๐Ÿ“– Quality โš ๏ธ โ€” Well-structured, follows codebase patterns. Should fix: (1) Frontend uses hardcoded string literals instead of ResponseType enum (diverges from RunBlock pattern). (2) Missing docstrings โ€” CodeRabbit flagged 42% coverage (threshold 80%). Nits: RunMCPToolTool class name stutters, isErrorOutput type guard has fragile structural check, accessing private _auto_lookup_credential cross-module.

๐Ÿ“ฆ Product โœ… โ€” Excellent UX design. Two-step discoveryโ†’execution is invisible to users. Credential reuse via existing SetupRequirementsCard is smart. Auto-retry after auth avoids frustrating extra confirmation. Suggestions: (1) Large MCP tool outputs have no truncation/pagination โ€” could overwhelm UI. (2) Image content types parsed but rendered as raw text/base64. (3) Discovery steps vanish after completion โ€” consider persistent audit trail.

๐Ÿ“ฌ Discussion โš ๏ธ โ€” CodeRabbit reviewed 3 times, author addressed most issues across 4 fix commits. 2 open CodeRabbit items: (1) Logger still uses raw server_url which may contain credentials (lines 155, 162, 170) โ€” should use _server_host(). (2) input_schema not in MCPToolInfo required array in OpenAPI spec. No human reviews yet โ€” Pwuts, kcze, ntindle suggested but none have reviewed. 2 confirmed merge conflicts (#12230, #12203).

๐Ÿ”Ž QA โœ… โ€” Full end-to-end flow verified live. Discovery animation, tool listing, execution, result rendering all work correctly. MCPToolOutputCard displays results properly. No console errors. Auth flow not testable without auth-required server but code inspection confirms correct wiring.

QA Screenshots:

  • landing
  • copilot-home
  • mcp-discovery
  • mcp-execution
  • mcp-accordion

Blockers (must fix before merge)

  1. run_mcp_tool.py:155,162,170 โ€” Logger uses raw server_url which may contain embedded credentials. Replace with _server_host(server_url) in all log/error paths.

Should Fix (follow-up OK)

  1. run_mcp_tool.py:218-242 โ€” Extract shared MCP content-parsing helper to avoid duplication with MCPToolBlock.run().
  2. run_mcp_tool.py:135 โ€” Promote _auto_lookup_credential to public API or extract to shared credentials utility.
  3. helpers.tsx:14-17 โ€” Use ResponseType enum instead of hardcoded string constants.
  4. test_run_mcp_tool.py โ€” Add tests for image/resource content types, multi-item results, and _build_setup_requirements credential wiring.
  5. openapi.json MCPToolInfo โ€” Add input_schema to required array.
  6. Docstrings โ€” Add to _discover_tools(), _execute_tool(), parseOutput(), getRunMCPToolOutput(), getAnimationText().

Nice to Have

  1. Storybook stories for RunMCPTool, MCPToolOutputCard
  2. Use <ErrorCard /> component instead of custom styled div for error rendering
  3. Consider truncation/pagination for large MCP tool outputs
  4. Image content type rendering in MCPToolOutputCard

Risk Assessment

Merge risk: LOW | Rollback: EASY

The PR is additive โ€” new tool, new components, new models. No existing functionality is modified beyond adding BlockType.MCP_TOOL to the exclusion list and adding tool-run_mcp_tool to the chat container switch. Rollback is a clean revert.


@ntindle Well-crafted MCP integration with solid security (SSRF protection, sanitized errors, scoped credentials). One blocker: raw URLs in log statements may leak credentials. Everything else is follow-up material. End-to-end flow verified live. Recommend approve after the logging fix.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

โ™ป๏ธ Duplicate comments (1)
autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py (1)

279-283: โš ๏ธ Potential issue | ๐ŸŸ  Major

Sanitize server URL in this remaining error log path.

Line 280 logs raw server_url; this can still leak embedded URL credentials into backend logs. Use _server_host(server_url) here as well.

๐Ÿงฏ Suggested fix
         if not missing_creds_dict:
             logger.error(
                 "No credential requirements found for MCP server %s โ€” "
                 "MCPToolBlock may not have credentials configured",
-                server_url,
+                _server_host(server_url),
             )
๐Ÿค– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py` around lines
279 - 283, The error log at logger.error currently prints the raw server_url
which may contain embedded credentials; update that call in run_mcp_tool.py to
pass the sanitized host by calling _server_host(server_url) instead of
server_url so logs never contain credentials (i.e., replace server_url with
_server_host(server_url) in the logger.error invocation).
๐Ÿค– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py`:
- Around line 112-131: Reject URLs containing userinfo (user:pass@) before any
processing or logging to avoid leaking credentials: in run_mcp_tool.py (within
the same function handling server_url/session_id and before calling validate_url
or creating ErrorResponse payloads), inspect server_url for URL userinfo (e.g.,
presence of '@' after a scheme or via parsing) and if found immediately return
an ErrorResponse with a short message like "Credential-bearing server_url not
allowed." Ensure this check runs before calling validate_url and before any use
of server_url, and apply the same reject logic to the other server_url handling
sites referenced (the blocks around lines 200-203, 250-254, 302-303).

---

Duplicate comments:
In `@autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py`:
- Around line 279-283: The error log at logger.error currently prints the raw
server_url which may contain embedded credentials; update that call in
run_mcp_tool.py to pass the sanitized host by calling _server_host(server_url)
instead of server_url so logs never contain credentials (i.e., replace
server_url with _server_host(server_url) in the logger.error invocation).

โ„น๏ธ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between a592161 and 518b72c.

๐Ÿ“’ Files selected for processing (3)
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
  • autogpt_platform/frontend/src/app/api/openapi.json
๐Ÿ“œ Review details
โฐ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: types
  • GitHub Check: Seer Code Review
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.12)
  • GitHub Check: end-to-end tests
  • GitHub Check: Check PR Status
  • GitHub Check: Analyze (python)
  • GitHub Check: conflicts
๐Ÿงฐ Additional context used
๐Ÿ““ Path-based instructions (4)
autogpt_platform/backend/**/*.py

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/backend/**/*.py: Use Python 3.11 (required; managed by Poetry via pyproject.toml) for backend development
Always run 'poetry run format' (Black + isort) before linting in backend development
Always run 'poetry run lint' (ruff) after formatting in backend development

Files:

  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/**/*.{py,txt}

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)

Use poetry run prefix for all Python commands, including testing, linting, formatting, and migrations

Files:

  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/backend/**/*.py

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)

Use Prisma ORM for database operations in PostgreSQL with pgvector for embeddings

Files:

  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/**/*.py

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Format Python code with poetry run format

Files:

  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿง  Learnings (5)
๐Ÿ““ Common learnings
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx:23-24
Timestamp: 2026-02-27T10:45:49.499Z
Learning: As of PR `#12213`, MCP tool response types (MCPToolsDiscoveredResponse, MCPToolOutputResponse) are defined in openapi.json and frontend code in autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx uses the generated types from `@/app/api/__generated__/`. Other tools like RunBlock still use inline TypeScript interfaces (e.g., BlockDetailsResponse) for SSE stream payloads that are not included in openapi.json schemas. The pattern is tool-specific: use generated types when available in openapi.json, use inline types only when the payload schema is truly SSE-stream-only and not exposed via OpenAPI.
๐Ÿ“š Learning: 2026-02-27T10:45:49.499Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx:23-24
Timestamp: 2026-02-27T10:45:49.499Z
Learning: As of PR `#12213`, MCP tool response types (MCPToolsDiscoveredResponse, MCPToolOutputResponse) are defined in openapi.json and frontend code in autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx uses the generated types from `@/app/api/__generated__/`. Other tools like RunBlock still use inline TypeScript interfaces (e.g., BlockDetailsResponse) for SSE stream payloads that are not included in openapi.json schemas. The pattern is tool-specific: use generated types when available in openapi.json, use inline types only when the payload schema is truly SSE-stream-only and not exposed via OpenAPI.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
  • autogpt_platform/frontend/src/app/api/openapi.json
๐Ÿ“š Learning: 2026-02-26T17:02:22.448Z
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12211
File: .pre-commit-config.yaml:160-179
Timestamp: 2026-02-26T17:02:22.448Z
Learning: Keep the pre-commit hook pattern broad for autogpt_platform/backend to ensure OpenAPI schema changes are captured. Do not narrow to backend/api/ alone, since the generated schema depends on Pydantic models across multiple directories (backend/data/, backend/blocks/, backend/copilot/, backend/integrations/, backend/util/). Narrowing could miss schema changes and cause frontend type desynchronization.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿ“š Learning: 2026-01-19T07:20:23.494Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 11795
File: autogpt_platform/backend/backend/api/features/chat/tools/utils.py:92-111
Timestamp: 2026-01-19T07:20:23.494Z
Learning: In autogpt_platform/backend/backend/api/features/chat/tools/utils.py, the _serialize_missing_credential function uses next(iter(field_info.provider)) for provider selection. The PR author confirmed this non-deterministic provider selection is acceptable because the function returns both "type" (single, for backward compatibility) and "types" (full array), which achieves the primary goal of deterministic credential type presentation.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿ“š Learning: 2026-02-04T16:50:51.495Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-04T16:50:51.495Z
Learning: Applies to autogpt_platform/**/data/*.py : For changes touching `data/*.py`, validate user ID checks or explain why not needed

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿงฌ Code graph analysis (1)
autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py (7)
autogpt_platform/backend/backend/util/request.py (4)
  • json (295-301)
  • request (365-402)
  • validate_url (147-215)
  • text (303-313)
autogpt_platform/backend/backend/blocks/mcp/block.py (1)
  • MCPToolBlock (54-300)
autogpt_platform/backend/backend/blocks/mcp/client.py (4)
  • MCPClient (45-323)
  • initialize (259-277)
  • list_tools (279-298)
  • call_tool (300-323)
autogpt_platform/backend/backend/copilot/tools/utils.py (1)
  • build_missing_credentials_from_field_info (131-142)
autogpt_platform/backend/backend/copilot/tools/base.py (1)
  • BaseTool (16-119)
autogpt_platform/backend/backend/copilot/tools/models.py (8)
  • ErrorResponse (206-211)
  • MCPToolInfo (485-490)
  • MCPToolOutputResponse (501-508)
  • MCPToolsDiscoveredResponse (493-498)
  • SetupInfo (161-173)
  • SetupRequirementsResponse (176-182)
  • ToolResponseBase (57-62)
  • UserReadiness (153-158)
autogpt_platform/backend/backend/copilot/tools/find_block.py (3)
  • name (49-50)
  • description (53-61)
  • requires_auth (80-81)
๐Ÿ”‡ Additional comments (9)
autogpt_platform/backend/backend/copilot/tools/models.py (2)

51-53: ResponseType extension is clean and consistent.

The new MCP response enum values fit the existing response-type contract and naming pattern.


484-507: MCP response models are well-scoped for discovery/execution flow.

The model split (MCPToolInfo, discovery response, execution response) is clear and maps well to the two-step tool workflow.

autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py (2)

320-329: Good credential-safe host extraction helper.

Using parsed.hostname instead of netloc is the right approach to avoid surfacing URL userinfo in UI/log-adjacent messages.


137-149: No MCPClient cleanup neededโ€”Requests manages session lifecycle automatically.

The Requests class already handles HTTP session cleanup properly using async with aiohttp.ClientSession() internally for each request. Since MCPClient doesn't hold persistent connections between calls and creates fresh Requests objects per operation, no explicit finally block or async with wrapper is required for this code.

autogpt_platform/frontend/src/app/api/openapi.json (5)

989-993: Good addition of MCP responses to the tool-response export union.

This keeps codegen-aware tool response coverage aligned with the new MCP flow.

Based on learnings: MCP tool response types should be sourced from openapi.json/generated types when available.


9983-9997: MCPToolInfo now correctly requires input_schema.

This resolves the optionality drift risk for generated frontend types.

Based on learnings: MCP tool response types in openapi.json should drive generated frontend types, with required fields reflected accurately.


9998-10018: MCPToolOutputResponse schema looks coherent and ready for typed consumption.

Fields and defaults are consistent with MCP execution-response modeling.


10034-10056: MCPToolsDiscoveredResponse is well-structured and correctly reuses MCPToolInfo.

This keeps discovery payload typing consistent across backend and frontend codegen.


11236-11238: ResponseType enum update is correct.

Including mcp_tools_discovered and mcp_tool_output ensures discriminator compatibility for MCP tool responses.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

โ™ป๏ธ Duplicate comments (1)
autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py (1)

289-293: โš ๏ธ Potential issue | ๐ŸŸ  Major

Redact URL before logging in setup-requirements fallback.

Line 292 logs raw server_url. This reopens URL leakage risk in logs (credentials/query secrets) in this branch and is inconsistent with your other hardened logger calls.

Proposed fix
         if not missing_creds_dict:
             logger.error(
                 "No credential requirements found for MCP server %s โ€” "
                 "MCPToolBlock may not have credentials configured",
-                server_url,
+                _server_host(server_url),
             )
๐Ÿค– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py` around lines
289 - 293, The fallback logger.error call in run_mcp_tool.py is outputting the
raw server_url (see logger.error and server_url in the setup-requirements
fallback), which risks leaking sensitive data; replace the logged server_url
with a redacted version (e.g., strip query, userinfo and any path or replace
with hostname-only or a constant like "<redacted_server_url>") by creating or
calling a small helper (e.g., redact_url(server_url) or similar) and pass that
redacted value to logger.error instead of the raw server_url so logs remain
hardened and consistent with other logger uses.
๐Ÿงน Nitpick comments (2)
autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py (2)

95-113: Lock the SSRF guard contract with an explicit assert.

This test verifies the blocked-path result, but it doesnโ€™t assert the exact validate_url invocation contract. Add an await assertion to prevent regressions in trusted_origins=[].

Suggested test tightening
-    with patch(
+    with patch(
         "backend.copilot.tools.run_mcp_tool.validate_url",
         new_callable=AsyncMock,
         side_effect=ValueError("blocked loopback"),
-    ):
+    ) as mock_validate:
         response = await tool._execute(
             user_id=_USER_ID, session=session, server_url="http://localhost/mcp"
         )
+    mock_validate.assert_awaited_once_with(
+        "http://localhost/mcp", trusted_origins=[]
+    )
๐Ÿค– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py` around
lines 95 - 113, The test should lock the SSRF guard contract by patching
validate_url as an AsyncMock (use "as mock_validate") and then asserting it was
awaited with the exact server_url and an explicit trusted_origins=[]; update
test_ssrf_blocked_url_returns_error to patch
"backend.copilot.tools.run_mcp_tool.validate_url" using new_callable=AsyncMock
as mock_validate, call tool._execute as before, and then add
mock_validate.assert_awaited_with("http://localhost/mcp", trusted_origins=[]) to
prevent regressions in trusted_origins handling in RunMCPToolTool.

116-129: Assert early rejection short-circuits validation and credential lookup.

Great coverage for credential-bearing URLs. Add explicit not awaited assertions so future refactors canโ€™t accidentally reintroduce DB/network work before rejection.

Suggested test hardening
 async def test_credential_bearing_url_returns_error():
     """URLs with embedded user:pass@ must be rejected before any network call."""
     tool = RunMCPToolTool()
     session = make_session(_USER_ID)
-    response = await tool._execute(
-        user_id=_USER_ID,
-        session=session,
-        server_url="https://user:secret@mcp.example.com/mcp",
-    )
+    with patch(
+        "backend.copilot.tools.run_mcp_tool.validate_url", new_callable=AsyncMock
+    ) as mock_validate:
+        with patch(
+            "backend.copilot.tools.run_mcp_tool.MCPToolBlock._auto_lookup_credential",
+            new_callable=AsyncMock,
+        ) as mock_lookup:
+            response = await tool._execute(
+                user_id=_USER_ID,
+                session=session,
+                server_url="https://user:secret@mcp.example.com/mcp",
+            )
+
+    mock_validate.assert_not_awaited()
+    mock_lookup.assert_not_awaited()
     assert isinstance(response, ErrorResponse)
     assert (
         "credential" in response.message.lower()
         or "do not include" in response.message.lower()
     )
๐Ÿค– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py` around
lines 116 - 129, The test should explicitly assert that no DB/network async
calls were awaited when rejecting credential-bearing URLs: in
test_credential_bearing_url_returns_error, replace or wrap external async
callables (e.g., make_session and the tool's credential lookup async function
such as RunMCPToolTool._get_credentials or whatever async client method the tool
uses) with unittest.mock.AsyncMock instances and after calling await
tool._execute(...) assert those AsyncMocks assert_not_awaited() to guarantee no
network/DB work occurred before rejection; keep the existing response assertions
intact.
๐Ÿค– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py`:
- Around line 289-293: The fallback logger.error call in run_mcp_tool.py is
outputting the raw server_url (see logger.error and server_url in the
setup-requirements fallback), which risks leaking sensitive data; replace the
logged server_url with a redacted version (e.g., strip query, userinfo and any
path or replace with hostname-only or a constant like "<redacted_server_url>")
by creating or calling a small helper (e.g., redact_url(server_url) or similar)
and pass that redacted value to logger.error instead of the raw server_url so
logs remain hardened and consistent with other logger uses.

---

Nitpick comments:
In `@autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py`:
- Around line 95-113: The test should lock the SSRF guard contract by patching
validate_url as an AsyncMock (use "as mock_validate") and then asserting it was
awaited with the exact server_url and an explicit trusted_origins=[]; update
test_ssrf_blocked_url_returns_error to patch
"backend.copilot.tools.run_mcp_tool.validate_url" using new_callable=AsyncMock
as mock_validate, call tool._execute as before, and then add
mock_validate.assert_awaited_with("http://localhost/mcp", trusted_origins=[]) to
prevent regressions in trusted_origins handling in RunMCPToolTool.
- Around line 116-129: The test should explicitly assert that no DB/network
async calls were awaited when rejecting credential-bearing URLs: in
test_credential_bearing_url_returns_error, replace or wrap external async
callables (e.g., make_session and the tool's credential lookup async function
such as RunMCPToolTool._get_credentials or whatever async client method the tool
uses) with unittest.mock.AsyncMock instances and after calling await
tool._execute(...) assert those AsyncMocks assert_not_awaited() to guarantee no
network/DB work occurred before rejection; keep the existing response assertions
intact.

โ„น๏ธ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 518b72c and d3eaceb.

๐Ÿ“’ Files selected for processing (2)
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
๐Ÿ“œ Review details
โฐ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: types
  • GitHub Check: Seer Code Review
  • GitHub Check: end-to-end tests
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.12)
  • GitHub Check: Analyze (python)
  • GitHub Check: Check PR Status
๐Ÿงฐ Additional context used
๐Ÿ““ Path-based instructions (5)
autogpt_platform/backend/**/*.py

๐Ÿ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/backend/**/*.py: Use Python 3.11 (required; managed by Poetry via pyproject.toml) for backend development
Always run 'poetry run format' (Black + isort) before linting in backend development
Always run 'poetry run lint' (ruff) after formatting in backend development

Files:

  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/**/*.{py,txt}

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)

Use poetry run prefix for all Python commands, including testing, linting, formatting, and migrations

Files:

  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/backend/**/*.py

๐Ÿ“„ CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)

Use Prisma ORM for database operations in PostgreSQL with pgvector for embeddings

Files:

  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/**/*.py

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Format Python code with poetry run format

Files:

  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/**/*test*.py

๐Ÿ“„ CodeRabbit inference engine (AGENTS.md)

Run poetry run test for backend testing (runs pytest with docker based postgres + prisma)

Files:

  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
๐Ÿง  Learnings (7)
๐Ÿ““ Common learnings
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx:23-24
Timestamp: 2026-02-27T10:45:49.499Z
Learning: As of PR `#12213`, MCP tool response types (MCPToolsDiscoveredResponse, MCPToolOutputResponse) are defined in openapi.json and frontend code in autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx uses the generated types from `@/app/api/__generated__/`. Other tools like RunBlock still use inline TypeScript interfaces (e.g., BlockDetailsResponse) for SSE stream payloads that are not included in openapi.json schemas. The pattern is tool-specific: use generated types when available in openapi.json, use inline types only when the payload schema is truly SSE-stream-only and not exposed via OpenAPI.
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/api/openapi.json:9983-9995
Timestamp: 2026-02-27T15:58:44.424Z
Learning: Repo: Significant-Gravitas/AutoGPT PR: 12213 โ€” Backend/frontend OpenAPI codegen
Learning: For MCP schema models, required OpenAPI fields must have no defaults in Pydantic. Specifically, MCPToolInfo.input_schema must be required (no Field(default_factory=dict)) so openapi.json emits it in "required", ensuring generated TS types treat input_schema as non-optional.
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/api/openapi.json:9983-9995
Timestamp: 2026-02-27T15:58:44.424Z
Learning: Repo: Significant-Gravitas/AutoGPT PR: 12213 โ€” OpenAPI/codegen
Learning: Ensuring a field is required in generated TS types needs two sides: (1) no default value on the Pydantic field, and (2) the OpenAPI model's "required" array must list it. For MCPToolInfo, making input_schema required in OpenAPI and removing Field(default_factory=dict) in the backend prevents optional typing drift.
๐Ÿ“š Learning: 2026-02-27T10:45:49.499Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx:23-24
Timestamp: 2026-02-27T10:45:49.499Z
Learning: As of PR `#12213`, MCP tool response types (MCPToolsDiscoveredResponse, MCPToolOutputResponse) are defined in openapi.json and frontend code in autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx uses the generated types from `@/app/api/__generated__/`. Other tools like RunBlock still use inline TypeScript interfaces (e.g., BlockDetailsResponse) for SSE stream payloads that are not included in openapi.json schemas. The pattern is tool-specific: use generated types when available in openapi.json, use inline types only when the payload schema is truly SSE-stream-only and not exposed via OpenAPI.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿ“š Learning: 2026-02-27T15:58:44.424Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/api/openapi.json:9983-9995
Timestamp: 2026-02-27T15:58:44.424Z
Learning: Repo: Significant-Gravitas/AutoGPT PR: 12213 โ€” Backend/frontend OpenAPI codegen
Learning: For MCP schema models, required OpenAPI fields must have no defaults in Pydantic. Specifically, MCPToolInfo.input_schema must be required (no Field(default_factory=dict)) so openapi.json emits it in "required", ensuring generated TS types treat input_schema as non-optional.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿ“š Learning: 2026-02-27T15:58:44.424Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/api/openapi.json:9983-9995
Timestamp: 2026-02-27T15:58:44.424Z
Learning: Repo: Significant-Gravitas/AutoGPT PR: 12213 โ€” OpenAPI/codegen
Learning: Ensuring a field is required in generated TS types needs two sides: (1) no default value on the Pydantic field, and (2) the OpenAPI model's "required" array must list it. For MCPToolInfo, making input_schema required in OpenAPI and removing Field(default_factory=dict) in the backend prevents optional typing drift.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿ“š Learning: 2026-02-26T17:02:22.448Z
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12211
File: .pre-commit-config.yaml:160-179
Timestamp: 2026-02-26T17:02:22.448Z
Learning: Keep the pre-commit hook pattern broad for autogpt_platform/backend to ensure OpenAPI schema changes are captured. Do not narrow to backend/api/ alone, since the generated schema depends on Pydantic models across multiple directories (backend/data/, backend/blocks/, backend/copilot/, backend/integrations/, backend/util/). Narrowing could miss schema changes and cause frontend type desynchronization.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py
  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿ“š Learning: 2026-01-19T07:20:23.494Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 11795
File: autogpt_platform/backend/backend/api/features/chat/tools/utils.py:92-111
Timestamp: 2026-01-19T07:20:23.494Z
Learning: In autogpt_platform/backend/backend/api/features/chat/tools/utils.py, the _serialize_missing_credential function uses next(iter(field_info.provider)) for provider selection. The PR author confirmed this non-deterministic provider selection is acceptable because the function returns both "type" (single, for backward compatibility) and "types" (full array), which achieves the primary goal of deterministic credential type presentation.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿ“š Learning: 2026-02-04T16:50:51.495Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-02-04T16:50:51.495Z
Learning: Applies to autogpt_platform/**/data/*.py : For changes touching `data/*.py`, validate user ID checks or explain why not needed

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
๐Ÿงฌ Code graph analysis (1)
autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py (4)
autogpt_platform/backend/backend/copilot/tools/_test_data.py (1)
  • make_session (22-32)
autogpt_platform/backend/backend/copilot/tools/models.py (1)
  • SetupRequirementsResponse (176-182)
autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py (3)
  • _server_host (330-340)
  • name (44-45)
  • description (48-56)
autogpt_platform/backend/backend/blocks/mcp/client.py (2)
  • list_tools (279-298)
  • call_tool (300-323)
๐Ÿ”‡ Additional comments (2)
autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.py (1)

354-499: Auth/error-path coverage here is solid.

The 401 setup-card path, 403-with-creds path, protocol error mapping, and generic-exception sanitization are all well covered.

autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py (1)

118-141: Good defensive ordering on URL handling.

Early rejection of credential-bearing URLs before validate_url, credential lookup, and MCP client creation is exactly the right flow.

Copy link

@autogpt-reviewer autogpt-reviewer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐Ÿ“‹ PR #12213 โ€” feat(copilot): run_mcp_tool โ€” MCP server discovery and execution in Otto (Re-review)

Author: majdyz | Commits reviewed: a592161 โ†’ d3eaceb | CI: โœ… All checks pass
Files: run_mcp_tool.py (+340), models.py (+45), test_run_mcp_tool.py (+521), RunMCPTool.tsx (+120), helpers.tsx (+95), MCPToolOutputCard.tsx (+55), helpers.test.tsx (+294), plus registry/route/openapi updates


๐ŸŽฏ Verdict: APPROVE WITH CONDITIONS

The previous blocker (raw server_url credential leakage in logs) is RESOLVED. The author added _server_host() helper using urlparse().hostname, credential-bearing URL rejection, and made input_schema required. The code is well-tested (521 backend + 294 frontend test lines), CI is fully green, and the full MCP discoveryโ†’execution flow works end-to-end in live testing.

Conditions for merge: Fix the one remaining raw server_url in logger (line 292) โ€” trivial one-line fix.


What This PR Does

Adds MCP (Model Context Protocol) server integration to Otto copilot. Users can ask Otto to discover tools on any MCP server URL, then execute those tools โ€” all through the chat interface. Includes a two-stage flow (discover โ†’ execute), OAuth/credential handling via SetupRequirementsCard reuse, SSRF protection, and comprehensive error handling.


Specialist Findings

๐Ÿ›ก๏ธ Security โœ… โ€” Previous blocker (credential leak in logs) RESOLVED. All exception-path loggers now use _server_host(). New controls added: credential-bearing URL rejection before network calls, validate_url with empty trusted_origins blocks SSRF. Credential scoping by (user_id, server_url) is correct. One nit: run_mcp_tool.py:292 still logs raw server_url in _build_setup_requirements() โ€” unreachable with credential-bearing URLs due to early rejection, but inconsistent.

๐Ÿ—๏ธ Architecture โœ… โ€” BaseTool conformance correct, registry integration clean, BlockType.MCP_TOOL properly excluded from find_block. Two should-fix items: (1) cross-module coupling to MCPToolBlock._auto_lookup_credential (private method) โ€” should be promoted to public API or extracted to shared credential utils, (2) MCP content-parsing duplicated between RunMCPToolTool._execute_tool and MCPToolBlock.run() โ€” should extract shared helper.

โšก Performance โš ๏ธ โ€” One notable issue: new aiohttp.ClientSession created per JSON-RPC call (2-3 per MCP interaction = 200-600ms unnecessary TLS overhead). Should reuse session within a single _execute() invocation. Also: _auto_lookup_credential fetches all MCP credentials then filters in Python (O(n)), and no caching of discovery results. Acceptable for initial launch but should be addressed for scale.

๐Ÿงช Testing โš ๏ธ โ€” Good overall: 20 backend tests, 30 frontend tests covering validation, discovery, execution, auth flows, type guards, output parsing. Gaps: (1) no tests for image or resource MCP content types (only text tested), (2) no multi-item or empty content result tests, (3) _build_setup_requirements only tested via mock โ€” actual credential field wiring never exercised, (4) no RunMCPToolComponent render tests.

๐Ÿ“– Quality โš ๏ธ โ€” Previous blocker fixed. Should-fix: (1) frontend uses hardcoded string literals instead of generated ResponseType enum (inconsistent with RunBlock), (2) isErrorOutput type guard fragile โ€” false positives on any object with error field, (3) missing docstrings on _discover_tools and _execute_tool (43% vs 80% threshold), (4) content-parsing duplication with MCPToolBlock.

๐Ÿ“ฆ Product โœ… โ€” Two-step UX flow is well-designed. Credential reuse via SetupRequirementsCard is clean. Should-fix: (1) image content rendered as raw base64 text instead of <img> tag โ€” unusable, (2) no truncation/pagination for large MCP outputs โ€” could freeze browser, (3) discovery results invisible to users (consumed silently by LLM).

๐Ÿ“ฌ Discussion โœ… โ€” 10/12 CodeRabbit issues resolved across 6 fix commits. One still open: run_mcp_tool.py:292 logs raw server_url (flagged in Reviews 4 and 5, author hasn't responded). One partial: error detail uses custom div instead of shared <ErrorCard />. No human reviewers yet โ€” Pwuts, kcze suggested. CI fully green.

๐Ÿ”Ž QA โœ… โ€” Full end-to-end validation PASSED. Frontend loads, signup works, MCP discovery flow renders correctly (orbit loader โ†’ tool list), execution flow completes (fetch tool on remote.mcpservers.org โ†’ HTML output rendered). MCPToolOutputCard accordion expands with formatted results. Zero console errors. 30/30 frontend unit tests pass. No Storybook stories for new components (minor gap). Screenshots: landing | dashboard | discovery | execution | output card | full flow


Blockers (must fix before merge)

  1. run_mcp_tool.py:292 โ€” logger.error("No credential requirements found for MCP server %s", server_url) should use _server_host(server_url) for consistency with all other log statements. Trivial fix, but flagged twice by CodeRabbit without response.

Should Fix (follow-up OK)

  1. run_mcp_tool.py / block.py โ€” Extract shared parse_mcp_content() helper to deduplicate content parsing (flagged by Architect + Quality)
  2. block.py:222 โ€” Promote _auto_lookup_credential to public API or extract to shared credential utils (flagged by Architect + Quality)
  3. MCPToolOutputCard.tsx โ€” Render image content type as <img> tag instead of raw base64 (flagged by Product)
  4. MCPToolOutputCard.tsx โ€” Add max-height/truncation for large outputs to prevent browser freeze (flagged by Product)
  5. helpers.tsx โ€” Use generated ResponseType enum instead of hardcoded string constants (flagged by Quality)
  6. helpers.tsx:70 โ€” Tighten isErrorOutput type guard to avoid false positives (flagged by Quality)
  7. run_mcp_tool.py / request.py โ€” Reuse aiohttp.ClientSession across JSON-RPC calls within a single MCP interaction (flagged by Performance โ€” 200-600ms unnecessary TLS overhead)
  8. Tests โ€” Add coverage for image/resource content types, multi-item results, empty results, and _build_setup_requirements integration (flagged by Testing)

Risk Assessment

Merge risk: LOW โ€” Feature is additive (new tool registration), no changes to existing flows. SSRF protection, auth, and credential scoping are solid. CI fully green including e2e.
Rollback: EASY โ€” Remove tool registration from __init__.py and the feature is disabled. No schema migrations.


@ntindle Previous security blocker resolved. One trivial logging fix remains at line 292 โ€” approve with that condition. Feature works end-to-end with good test coverage.

majdyz added 4 commits March 3, 2026 20:45
The discover_tools tests were mocking routes.creds_manager but the
endpoint now delegates to auto_lookup_mcp_credential from helpers.
Patch the helper function directly in the routes module.
- Change > to >= in auto_lookup_mcp_credential so that the last
  matching credential wins when multiple have the same (or None)
  expiry โ€” ensures the most recently created token is preferred
  after a failed old-credential cleanup
- Fix CodeQL py/polynomial-redos in parse_url(): require scheme to
  start with a letter per RFC 3986 ยง3.1, eliminating the ambiguous
  repetition that caused catastrophic backtracking
โ€ฆeDoS

Drop the regex scheme detection in parse_url() entirely and use a
simple '://' substring check instead. The regex triggered CodeQL
py/polynomial-redos due to overlapping character classes on
user-controlled input. urlparse() and the downstream ALLOWED_SCHEMES
check handle full scheme validation.
Replace strict `!== 200` checks with `>= 200 && < 300` for the OAuth
login and callback responses, consistent with the token storage check.
@majdyz majdyz force-pushed the feat/mcp-copilot branch from 2cdbfd6 to 2fd34c5 Compare March 3, 2026 13:45
@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Mar 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Conflicts have been resolved! ๐ŸŽ‰ A maintainer will review the pull request shortly.

@majdyz
Copy link
Contributor Author

majdyz commented Mar 3, 2026

Re [sentry#10951016]: valid observation โ€” when existing credentials fail with 401/403, the current code returns a generic error rather than a re-auth prompt. The not creds guard was intentional to avoid re-prompting on permission issues (e.g. server 403s on scope mismatch), but for stale/revoked tokens it does degrade UX. Tracking as a follow-up; out of scope for this PR.

Copy link

@autogpt-reviewer autogpt-reviewer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #12213 โ€” feat(copilot): run_mcp_tool โ€” MCP server discovery and execution in Otto (Re-review #7)
Author: majdyz | HEAD: 2fd34c5 | Delta: 2cdbfd6 โ†’ 2fd34c5 (19 commits, conflict resolution + refinements) | Files: 17 changed (+913/-630)

๐ŸŽฏ Verdict: APPROVE

What Changed (This Delta)

Conflict resolution with base branch plus several refinements:

  1. SSE timeout 30โ†’10s (routes.py) โ€” faster error detection on dead streams
  2. Heartbeat interval 10โ†’3s (service.py) โ€” more frequent keepalives through proxies/LBs
  3. Marker prefix hardening โ€” [COPILOT_ERROR] โ†’ [__COPILOT_ERROR_f7a1__] with hex suffixes to prevent LLM false-positive generation
  4. Frontend refactoring โ€” ChatMessagesContainer (345โ†’15 lines) decomposed into MessagePartRenderer, ThinkingIndicator, helpers.ts; useCopilotPage.ts split into useCopilotStream.ts (367 lines)
  5. Prisma connection resilience โ€” _ensure_db_connected() in test helpers for Python 3.11 stale-loop fix
  6. Clean conflict resolution โ€” all CI green on new HEAD

Specialist Findings

๐Ÿ›ก๏ธ Security โœ… โ€” All previous fixes verified intact (SSRF on all MCP routes, server_host() logging, SecretStr tokens, query/fragment rejection, credential-bearing URL rejection). Marker prefix hardening is a good anti-injection improvement. Minor should-fix: consider allowlisting image MIME types in parse_mcp_content() to prevent non-image data URIs from <img> tags. No blockers.

๐Ÿ—๏ธ Architecture โœ… โ€” Clean component decomposition on both backend (shared helpers.py) and frontend (MessagePartRenderer, ThinkingIndicator, useCopilotStream). Dependency direction correct โ€” no circular references between copilot/blocks/API layers. SetupRequirementsCard made reusable via props. API surface additions are backward-compatible. Minor: run_mcp_tool.py coupling to MCPToolBlock for credential schema metadata is acceptable.

โšก Performance โœ… โ€” SSE timeout reduction is net positive. Heartbeat 10โ†’3s increases Redis PEXPIRE calls 3.3ร— (should-fix: 5s would be sufficient). Carried forward from prior reviews: new aiohttp session per JSON-RPC call (~300-600ms avoidable latency), no discovery caching, credential fetch-all-then-filter. All are follow-up items, not blocking.

๐Ÿงช Testing โœ… โ€” Excellent coverage: 1,974 lines of tests across 6 test files (1.1:1 test-to-production ratio). Backend: 22+ tests for run_mcp_tool, 12 tests for helpers, 6 new SSRF/token route tests. Frontend: 30+ helper tests, MCPSetupCard (3 tests), MCPToolOutputCard (5 tests). useCopilotStream.ts (367 lines) has no tests but is a pure mechanical extraction โ€” acceptable. All CI green (3.11/3.12/3.13, lint, types, integration, e2e).

๐Ÿ“– Quality โœ… โ€” Significant quality improvement via DRY consolidation. Credential lookup logic unified from 3 locations into single auto_lookup_mcp_credential. Good docstrings on all new public functions. Consistent %s logging. Minor nits: IntegrationCredentialsManager instantiated per call (could accept optional param), duplicate server_host tests across two files.

๐Ÿ“ฆ Product โœ… โ€” No user-visible regressions. SSE timeout/heartbeat changes improve reliability. Marker hardening prevents LLM-generated false error cards. Manual token fallback flow works correctly with accessible inputs. SetupRequirementsCard now sends MCP-specific retry instructions for better LLM resume behavior.

๐Ÿ“ฌ Discussion โœ… โ€” All CI checks green on new HEAD. Conflict resolution was clean (~2hr turnaround). Author acknowledged Sentry stale-token observation as follow-up. Zero unresolved threads. Zero new CodeRabbit items since last review. โš ๏ธ Still zero human reviewers โ€” PR blocked on REVIEW_REQUIRED.

๐Ÿ”Ž QA โœ… โ€” Full end-to-end validated:

  • Frontend loads, signup works โœ…
  • MCP discovery: mcp.deepwiki.com โ†’ 3 tools (read_wiki_structure, read_wiki_contents, ask_question) โœ…
  • MCP execution: read_wiki_structure for facebook/react โ†’ full wiki structure โœ…
  • Error handling: invalid URL โ†’ graceful "Hostname not found" message โœ…
  • ThinkingIndicator renders correctly after refactoring โœ…
  • MessagePartRenderer renders all tool cards correctly โœ…
  • SSE streaming works with reduced timeout/heartbeat โœ…
  • No JS console errors โœ…

Screenshots: landing | copilot | discovery | execution | error | tool-card

Blockers

None.

Should Fix (Follow-up OK)

  1. service.py:145 โ€” Heartbeat interval 3s is aggressive โ€” 5s would survive the 10s SSE timeout with margin while reducing Redis PEXPIRE ops by 40%. (Performance โ€” LOW)

  2. helpers.py:90 โ€” IntegrationCredentialsManager() instantiated per call โ€” Consider accepting optional mgr parameter or lazy singleton to avoid redundant instantiation when called from routes (which already has a module-level singleton). (Quality โ€” LOW)

  3. MCPToolOutputCard.tsx:69 โ€” Allowlist image MIME types โ€” The mimeType from MCP server response is untrusted. While browsers reject non-image MIME types in <img> data URIs, a whitelist of image/png|jpeg|gif|webp|svg+xml would be defense-in-depth. (Security โ€” LOW)

  4. routes.py โ€” Validate authorize_url, token_url, revoke_url from OAuth metadata โ€” These URLs from server metadata aren't validated with validate_url(). A malicious MCP server could set token_endpoint to an internal IP. The auth_server_url validation covers the common case. (Security โ€” MEDIUM follow-up)

  5. client.py โ€” Reuse aiohttp session across JSON-RPC calls โ€” Currently creates new session per call (3-4 TLS handshakes per invocation, ~300-600ms avoidable latency). (Performance โ€” MEDIUM follow-up)

Nice to Have

  • Discovery caching per (server_url, session_id) with short TTL
  • Credential lookup with DB-level filter instead of fetch-all-then-filter
  • Tests for useCopilotStream.ts
  • Remove duplicate server_host tests from test_run_mcp_tool.py (canonical location is test_helpers.py)

Risk Assessment

Merge risk: LOW | Rollback: EASY (feature-gated behind run_mcp_tool tool registration)

@ntindle Delta resolves conflict cleanly and adds reliability improvements (SSE timing, marker hardening, frontend decomposition). All 8 specialists approve with no blockers. CI fully green. QA validated end-to-end with screenshots. This PR is ready for human approval โ€” it has been blocked on REVIEW_REQUIRED across all 7 review iterations.

ntindle
ntindle previously approved these changes Mar 3, 2026
@github-project-automation github-project-automation bot moved this from ๐Ÿ†• Needs initial review to ๐Ÿ‘๐Ÿผ Mergeable in AutoGPT development kanban Mar 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Mar 3, 2026
@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Mar 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Conflicts have been resolved! ๐ŸŽ‰ A maintainer will review the pull request shortly.

@Otto-AGPT
Copy link
Contributor

@ntindle All CI checks are passing โœ… โ€” could you re-approve when you get a chance?

@majdyz majdyz added this pull request to the merge queue Mar 4, 2026
Merged via the queue into dev with commit 7fd26d3 Mar 4, 2026
29 checks passed
@majdyz majdyz deleted the feat/mcp-copilot branch March 4, 2026 05:47
@github-project-automation github-project-automation bot moved this to Done in Frontend Mar 4, 2026
@github-project-automation github-project-automation bot moved this from ๐Ÿ‘๐Ÿผ Mergeable to โœ… Done in AutoGPT development kanban Mar 4, 2026
@sentry
Copy link

sentry bot commented Mar 5, 2026

Issues attributed to commits in this pull request

This pull request was merged and Sentry observed the following issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/backend AutoGPT Platform - Back end platform/blocks platform/frontend AutoGPT Platform - Front end size/xl

Projects

Status: โœ… Done
Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants