Skip to content

fix(mcp): always guard the MCP transport and validate on every managed connect - #7802

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/mcp-transport-egress-guard
Sep 13, 2026
Merged

fix(mcp): always guard the MCP transport and validate on every managed connect#7802
waleedlatif1 merged 1 commit into
stagingfrom
fix/mcp-transport-egress-guard

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • McpClient always runs the transport on the SSRF-guarded fetch; it no longer falls back to the global fetch when no validated address is passed. A validated private address still pins, as before
  • McpConnectionManager.connect validates the destination (validateMcpDomain + validateMcpServerSsrf) on every dial, reconnects included, instead of taking a caller-supplied resolvedIP
  • Discovery only resolves env vars before handing off to the manager, so already-connected servers skip the DNS lookup
  • Corrected the resolvedIP TSDoc and the client guard comment

Type of Change

  • Bug fix

Testing

  • New tests: client uses the guard with no address and pins a private one; manager validates before building a client, refuses without constructing one, and re-validates on reconnect. Confirmed they fail with the fix reverted
  • lib/mcp + app/api/mcp suites pass (681), type-check, lint, check:audits, docs-manifest:check pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…d connect

McpClient no longer falls back to the global fetch when no validated address is supplied;
it always uses the SSRF-guarded transport, pinning only a validated private address.
McpConnectionManager.connect validates the destination itself on every dial, reconnects
included, instead of trusting a caller-supplied address.
@vercel

vercel Bot commented Sep 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 13, 2026 3:09am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the changed paths consistently validate managed destinations and keep transport requests behind the SSRF guard.

Summary

  • Validates domains and resolved destinations before constructing managed clients, including reconnects.
  • Uses an SSRF-guarded transport by default and pins validated private addresses where policy permits.
  • Separates environment-variable resolution from per-dial destination validation.
  • Adds focused coverage for guarded transport selection, refused destinations, cleanup, and reconnect revalidation.

Diagram

sequenceDiagram
  participant S as MCP Service
  participant M as Connection Manager
  participant V as Domain/SSRF Validator
  participant C as MCP Client
  participant T as Guarded Transport
  participant R as MCP Server

  S->>S: Resolve URL/header environment variables
  S->>M: connect(resolvedConfig, userId, workspaceId)
  M->>V: validateMcpDomain(url)
  M->>V: validateMcpServerSsrf(url)
  V-->>M: Validated address
  M->>C: Construct with validated address
  C->>T: Create guarded or pinned fetch
  C->>R: Connect through guarded transport
  R-->>C: Connection / notifications
  R--xC: Transport closes
  C-->>M: onClose
  M->>M: Schedule reconnect
  M->>V: Revalidate destination
  V-->>M: Fresh validated address
  M->>C: Construct replacement client
Loading

Reviews (1) · Last reviewed commit: "fix(mcp): always guard the MCP transport..."

@waleedlatif1
waleedlatif1 merged commit f75f55a into staging Sep 13, 2026
33 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/mcp-transport-egress-guard branch September 13, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant