feat(copilot): run_mcp_tool โ MCP server discovery and execution in Otto#12213
feat(copilot): run_mcp_tool โ MCP server discovery and execution in Otto#12213
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds 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
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
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)
Estimated code review effort๐ฏ 4 (Complex) | โฑ๏ธ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
๐ฅ Pre-merge checks | โ 2 | โ 1โ Failed checks (1 warning)
โ Passed checks (2 passed)
โ๏ธ Tip: You can configure your own custom pre-merge checks in the settings. โจ Finishing Touches๐งช Generate unit tests (beta)
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. Comment |
๐ PR Overlap DetectionThis check compares your PR against all other open PRs targeting the same branch to detect potential merge conflicts early. ๐ด Merge Conflicts DetectedThe following PRs have been tested and will have merge conflicts if merged after this PR. Consider coordinating with the authors.
๐ข Low Risk โ File Overlap OnlyThese 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: |
|
@coderabbitai review |
โ Actions performedReview triggered.
|
There was a problem hiding this comment.
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.
๐ Files selected for processing (9)
autogpt_platform/backend/backend/copilot/service.pyautogpt_platform/backend/backend/copilot/tools/__init__.pyautogpt_platform/backend/backend/copilot/tools/find_block.pyautogpt_platform/backend/backend/copilot/tools/models.pyautogpt_platform/backend/backend/copilot/tools/run_mcp_tool.pyautogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsxautogpt_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.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsxautogpt_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.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsxautogpt_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.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsxautogpt_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*.tshooks)
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 fromsrc/components/(atoms, molecules, organisms)
Never usesrc/components/__legacy__/*components
Use generated API hooks from@/app/api/__generated__/endpoints/with patternuse{Method}{Version}{OperationName}
Use Tailwind CSS only for styling, with design tokens
Do not useuseCallbackoruseMemounless asked to optimize a given function
Never type withanyunless a variable/attribute can ACTUALLY be of any type
autogpt_platform/frontend/src/**/*.{ts,tsx}: Structure components asComponentName/ComponentName.tsx+useComponentName.ts+helpers.tsand use design system components fromsrc/components/(atoms, molecules, organisms)
Use generated API hooks from@/app/api/__generated__/endpoints/with patternuse{Method}{Version}{OperationName}and regenerate withpnpm 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/componentsfolder
Avoid large hooks, abstract logic intohelpers.tsfiles 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 useuseCallbackoruseMemounless asked to optimize a given function
Files:
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsxautogpt_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.tsxautogpt_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 componentComponent 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.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsxautogpt_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 usingpnpm format
Never use components fromsrc/components/__legacy__/*
Files:
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsxautogpt_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.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsxautogpt_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 useunknown
Files:
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsxautogpt_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.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsxautogpt_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.pyautogpt_platform/backend/backend/copilot/tools/find_block.pyautogpt_platform/backend/backend/copilot/tools/__init__.pyautogpt_platform/backend/backend/copilot/tools/models.pyautogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/**/*.{py,txt}
๐ CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)
Use
poetry runprefix for all Python commands, including testing, linting, formatting, and migrations
Files:
autogpt_platform/backend/backend/copilot/service.pyautogpt_platform/backend/backend/copilot/tools/find_block.pyautogpt_platform/backend/backend/copilot/tools/__init__.pyautogpt_platform/backend/backend/copilot/tools/models.pyautogpt_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.pyautogpt_platform/backend/backend/copilot/tools/find_block.pyautogpt_platform/backend/backend/copilot/tools/__init__.pyautogpt_platform/backend/backend/copilot/tools/models.pyautogpt_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.pyautogpt_platform/backend/backend/copilot/tools/find_block.pyautogpt_platform/backend/backend/copilot/tools/__init__.pyautogpt_platform/backend/backend/copilot/tools/models.pyautogpt_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.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsxautogpt_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_REGISTRYentry follow the existing pattern, and the tool will be automatically exposed viatoolsgeneration.Also applies to: 49-49
autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatMessagesContainer/ChatMessagesContainer.tsx (1)
26-26:tool-run_mcp_toolrouting 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: ExcludingBlockType.MCP_TOOLhere is the right safeguard.This keeps
find_blockaligned 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.
formatResultand the conditionalContentCodeBlock/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
Requestsobject 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.
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx
Outdated
Show resolved
Hide resolved
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx
Show resolved
Hide resolved
|
Addressing CodeRabbit review (commit 2a3efca): [SSRF โ run_mcp_tool.py:123] โ
Fixed โ added [Raw exception exposure โ run_mcp_tool.py:156] โ
Fixed โ generic [Shared state mutation โ run_mcp_tool.py:253] โ
Safe โ [Inline interfaces instead of generated types โ helpers.tsx:24] โ Not applicable โ [Error card โ RunMCPTool.tsx:50] โ
Fixed โ added an error detail card that renders |
|
@coderabbitai review |
โ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
โป๏ธ Duplicate comments (1)
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsx (1)
68-77:โ ๏ธ Potential issue | ๐ MajorUse
<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.
๐ Files selected for processing (5)
autogpt_platform/backend/backend/copilot/service.pyautogpt_platform/backend/backend/copilot/tools/run_mcp_tool.pyautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/RunMCPTool.tsxautogpt_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}: Runpnpm formatto auto-fix formatting issues before completing work
Runpnpm lintto 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.tsxautogpt_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.tsxautogpt_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 developmentRun
pnpm typesto 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.tsxautogpt_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 usingpnpm format
Never use components fromsrc/components/__legacy__/*
Files:
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsxautogpt_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 asComponentName/ComponentName.tsx+useComponentName.ts+helpers.tsand use design system components fromsrc/components/(atoms, molecules, organisms)
Use generated API hooks from@/app/api/__generated__/endpoints/with patternuse{Method}{Version}{OperationName}and regenerate withpnpm 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/componentsfolder
Avoid large hooks, abstract logic intohelpers.tsfiles 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 useuseCallbackoruseMemounless 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*.tshooks)
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 fromsrc/components/(atoms, molecules, organisms)
Never usesrc/components/__legacy__/*components
Use generated API hooks from@/app/api/__generated__/endpoints/with patternuse{Method}{Version}{OperationName}
Use Tailwind CSS only for styling with design tokens
Do not useuseCallbackoruseMemounless asked to optimize a specific function
Never type withanyunless a variable/attribute can actually be of any type
Files:
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsxautogpt_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.tsxautogpt_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 componentUse
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.tsxautogpt_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 useunknown
Files:
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsxautogpt_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.tsxautogpt_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.tsxautogpt_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.tsxautogpt_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 runprefix 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.tsxautogpt_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.tsxautogpt_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.tsxautogpt_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.jsonautogpt_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 โResponseTypenow 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 onlyResponseTypeenum 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.
retryInstructionandcredentialsLabelare 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
There was a problem hiding this comment.
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.
๐ Files selected for processing (7)
autogpt_platform/backend/backend/api/features/chat/routes.pyautogpt_platform/backend/backend/copilot/tools/run_mcp_tool.pyautogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.pyautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/__tests__/helpers.test.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsxautogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsxautogpt_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.pyautogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.pyautogpt_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 runprefix for all Python commands, including testing, linting, formatting, and migrations
Files:
autogpt_platform/backend/backend/api/features/chat/routes.pyautogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.pyautogpt_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.pyautogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.pyautogpt_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.pyautogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.pyautogpt_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}: Runpnpm formatto auto-fix formatting issues before completing work
Runpnpm lintto 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.tsxautogpt_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.tsxautogpt_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 developmentRun
pnpm typesto 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.tsxautogpt_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 usingpnpm format
Never use components fromsrc/components/__legacy__/*
Files:
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsxautogpt_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 asComponentName/ComponentName.tsx+useComponentName.ts+helpers.tsand use design system components fromsrc/components/(atoms, molecules, organisms)
Use generated API hooks from@/app/api/__generated__/endpoints/with patternuse{Method}{Version}{OperationName}and regenerate withpnpm 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/componentsfolder
Avoid large hooks, abstract logic intohelpers.tsfiles 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 useuseCallbackoruseMemounless 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*.tshooks)
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 fromsrc/components/(atoms, molecules, organisms)
Never usesrc/components/__legacy__/*components
Use generated API hooks from@/app/api/__generated__/endpoints/with patternuse{Method}{Version}{OperationName}
Use Tailwind CSS only for styling with design tokens
Do not useuseCallbackoruseMemounless asked to optimize a specific function
Never type withanyunless a variable/attribute can actually be of any type
Files:
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsxautogpt_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.tsxautogpt_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 componentUse
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.tsxautogpt_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 useunknown
Files:
autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/components/MCPToolOutputCard/MCPToolOutputCard.tsxautogpt_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.tsxautogpt_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.tsxautogpt_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.tsxautogpt_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 testfor 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 testorpnpm test-uifor 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.pyautogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.pyautogpt_platform/frontend/src/app/api/openapi.jsonautogpt_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.pyautogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.pyautogpt_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.tsxautogpt_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.tsxautogpt_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.
formatResultplus theisJsonbranch 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 inopenapi.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, missingserver_url, and SSRF protection is well placed before network calls.
318-327:_server_hostnow 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
ToolResponseUnionensures 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:MCPToolsDiscoveredResponseshape looks correct for discovery flow.
server_urland typedtoolspayload are correctly modeled for the tool-selection step.
11236-11238:ResponseTypeenum extension is correct.Adding
mcp_tools_discoveredandmcp_tool_outputkeeps discriminated response handling aligned.
autogpt-reviewer
left a comment
There was a problem hiding this comment.
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 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 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 _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 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 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:
Blockers (must fix before merge)
run_mcp_tool.py:155,162,170โ Logger uses rawserver_urlwhich may contain embedded credentials. Replace with_server_host(server_url)in all log/error paths.
Should Fix (follow-up OK)
run_mcp_tool.py:218-242โ Extract shared MCP content-parsing helper to avoid duplication withMCPToolBlock.run().run_mcp_tool.py:135โ Promote_auto_lookup_credentialto public API or extract to shared credentials utility.helpers.tsx:14-17โ UseResponseTypeenum instead of hardcoded string constants.test_run_mcp_tool.pyโ Add tests for image/resource content types, multi-item results, and_build_setup_requirementscredential wiring.openapi.jsonMCPToolInfo โ Addinput_schemato required array.- Docstrings โ Add to
_discover_tools(),_execute_tool(),parseOutput(),getRunMCPToolOutput(),getAnimationText().
Nice to Have
- Storybook stories for
RunMCPTool,MCPToolOutputCard - Use
<ErrorCard />component instead of custom styled div for error rendering - Consider truncation/pagination for large MCP tool outputs
- 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.
There was a problem hiding this comment.
Actionable comments posted: 1
โป๏ธ Duplicate comments (1)
autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py (1)
279-283:โ ๏ธ Potential issue | ๐ MajorSanitize 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.
๐ Files selected for processing (3)
autogpt_platform/backend/backend/copilot/tools/models.pyautogpt_platform/backend/backend/copilot/tools/run_mcp_tool.pyautogpt_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.pyautogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/**/*.{py,txt}
๐ CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)
Use
poetry runprefix for all Python commands, including testing, linting, formatting, and migrations
Files:
autogpt_platform/backend/backend/copilot/tools/models.pyautogpt_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.pyautogpt_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.pyautogpt_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.pyautogpt_platform/backend/backend/copilot/tools/run_mcp_tool.pyautogpt_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.pyautogpt_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.hostnameinstead ofnetlocis 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
Requestsclass already handles HTTP session cleanup properly usingasync with aiohttp.ClientSession()internally for each request. SinceMCPClientdoesn't hold persistent connections between calls and creates freshRequestsobjects per operation, no explicitfinallyblock orasync withwrapper 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:MCPToolInfonow correctly requiresinput_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:MCPToolOutputResponseschema looks coherent and ready for typed consumption.Fields and defaults are consistent with MCP execution-response modeling.
10034-10056:MCPToolsDiscoveredResponseis well-structured and correctly reusesMCPToolInfo.This keeps discovery payload typing consistent across backend and frontend codegen.
11236-11238:ResponseTypeenum update is correct.Including
mcp_tools_discoveredandmcp_tool_outputensures discriminator compatibility for MCP tool responses.
There was a problem hiding this comment.
โป๏ธ Duplicate comments (1)
autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py (1)
289-293:โ ๏ธ Potential issue | ๐ MajorRedact 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_urlinvocation contract. Add an await assertion to prevent regressions intrusted_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 awaitedassertions 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.
๐ Files selected for processing (2)
autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.pyautogpt_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.pyautogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/**/*.{py,txt}
๐ CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)
Use
poetry runprefix for all Python commands, including testing, linting, formatting, and migrations
Files:
autogpt_platform/backend/backend/copilot/tools/test_run_mcp_tool.pyautogpt_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.pyautogpt_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.pyautogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py
autogpt_platform/backend/**/*test*.py
๐ CodeRabbit inference engine (AGENTS.md)
Run
poetry run testfor 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.pyautogpt_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.pyautogpt_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.pyautogpt_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.pyautogpt_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.
autogpt-reviewer
left a comment
There was a problem hiding this comment.
๐ 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 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 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 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)
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)
run_mcp_tool.py/block.pyโ Extract sharedparse_mcp_content()helper to deduplicate content parsing (flagged by Architect + Quality)block.py:222โ Promote_auto_lookup_credentialto public API or extract to shared credential utils (flagged by Architect + Quality)MCPToolOutputCard.tsxโ Renderimagecontent type as<img>tag instead of raw base64 (flagged by Product)MCPToolOutputCard.tsxโ Add max-height/truncation for large outputs to prevent browser freeze (flagged by Product)helpers.tsxโ Use generatedResponseTypeenum instead of hardcoded string constants (flagged by Quality)helpers.tsx:70โ TightenisErrorOutputtype guard to avoid false positives (flagged by Quality)run_mcp_tool.py/request.pyโ Reuseaiohttp.ClientSessionacross JSON-RPC calls within a single MCP interaction (flagged by Performance โ 200-600ms unnecessary TLS overhead)- Tests โ Add coverage for image/resource content types, multi-item results, empty results, and
_build_setup_requirementsintegration (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.
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.
|
Conflicts have been resolved! ๐ A maintainer will review the pull request shortly. |
|
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 |
autogpt-reviewer
left a comment
There was a problem hiding this comment.
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:
- SSE timeout 30โ10s (
routes.py) โ faster error detection on dead streams - Heartbeat interval 10โ3s (
service.py) โ more frequent keepalives through proxies/LBs - Marker prefix hardening โ
[COPILOT_ERROR]โ[__COPILOT_ERROR_f7a1__]with hex suffixes to prevent LLM false-positive generation - Frontend refactoring โ ChatMessagesContainer (345โ15 lines) decomposed into MessagePartRenderer, ThinkingIndicator, helpers.ts; useCopilotPage.ts split into useCopilotStream.ts (367 lines)
- Prisma connection resilience โ
_ensure_db_connected()in test helpers for Python 3.11 stale-loop fix - 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. 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_structurefor 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)
-
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) -
helpers.py:90โIntegrationCredentialsManager()instantiated per call โ Consider accepting optionalmgrparameter or lazy singleton to avoid redundant instantiation when called from routes (which already has a module-level singleton). (Quality โ LOW) -
MCPToolOutputCard.tsx:69โ Allowlist image MIME types โ ThemimeTypefrom MCP server response is untrusted. While browsers reject non-image MIME types in<img>data URIs, a whitelist ofimage/png|jpeg|gif|webp|svg+xmlwould be defense-in-depth. (Security โ LOW) -
routes.pyโ Validateauthorize_url,token_url,revoke_urlfrom OAuth metadata โ These URLs from server metadata aren't validated withvalidate_url(). A malicious MCP server could settoken_endpointto an internal IP. Theauth_server_urlvalidation covers the common case. (Security โ MEDIUM follow-up) -
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_hosttests fromtest_run_mcp_tool.py(canonical location istest_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.
|
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
|
Conflicts have been resolved! ๐ A maintainer will review the pull request shortly. |
|
@ntindle All CI checks are passing โ โ could you re-approve when you get a chance? |
Issues attributed to commits in this pull requestThis pull request was merged and Sentry observed the following issues:
|





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_toolinstead of reusingrun_block+ MCPToolBlock?Two blockers make
run_blockunworkable for MCP:MCPToolBlockerrors with "No tool selected" whenselected_toolis empty; the agent can't learn what tools exist before picking one.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
run_mcp_toolcopilot tool (run_mcp_tool.py) โ two-stage flow:run_mcp_tool(server_url)โ discovers available tools viaMCPClient.list_tools()run_mcp_tool(server_url, tool_name, tool_arguments)โ executes viaMCPClient.call_tool()MCPToolBlock._auto_lookup_credential); on HTTP 401/403 with no stored creds, returnsSetupRequirementsResponseso the frontend renders the existing CredentialsGroupedView OAuth login cardmodels.py:MCPToolsDiscoveredResponse,MCPToolOutputResponse,MCPToolInfofind_block/run_block(COPILOT_EXCLUDED_BLOCK_TYPES)input_schemaguidance, auth-wait instruction, and registry URL (registry.modelcontextprotocol.io)Frontend
RunMCPToolComponentโ routes between credential prompt (reusesSetupRequirementsCardfrom 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 texthelpers.tsxโ type guards (isMCPToolOutput,isSetupRequirementsOutput,isErrorOutput), output parsing, animation texttool-run_mcp_toolcase inChatMessagesContainerTest plan
run_mcp_tool(server_url)with a public MCP server โ see discovery animation, agent gets tool listrun_mcp_tool(server_url, tool_name, tool_arguments)โ seeMCPToolOutputCardwith resultSetupRequirementsCardrenders with MCP OAuth buttonfind_block("MCP")returns no results (MCPToolBlock excluded)MCPClientfor discovery + execution + auth error paths