Skip to content

fix(mcp): classify unresolvable and egress-refused server URLs in discovery - #9341

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/mcp-discovery-dns-unavailable
Oct 23, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/mcp-discovery-dns-unavailable

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • An MCP server whose hostname no longer resolves (e.g. an expired tunnel URL) made /api/mcp/tools/discover answer 500 and log at error: McpDnsResolutionError from the SSRF pre-check fell through isMcpServerUnavailableError and categorizeError
  • isMcpServerUnavailableError now treats it as server-unavailable: discover answers 422 + warn, v2 GET /api/v2/mcp-servers/{id}/tools answers its documented 503
  • categorizeError maps it to 502 (Server hostname could not be resolved) and McpSsrfError / McpDomainNotAllowedError to 403, matching test-connection and server lifecycle; reaches discover refresh, servers/[id]/refresh, and MCP tool execution
  • Messages stay generic constants; no hostname or address reaches the caller. Failure status, negative cache, and the discovery retry predicate are unchanged (they never keyed on these helpers)

Type of Change

  • Bug fix

Testing

  • Regression cases in discover/route.test.ts (DNS → 422, SSRF and domain refusal → 403) and v2/mcp-servers/[mcpServerId]/tools/route.test.ts (DNS → 503); all four fail on the pre-fix code (500) and pass with the fix
  • Targeted vitest: app/api/mcp/tools, app/api/mcp/servers/[id]/refresh, app/api/v2/mcp-servers, lib/internal/mcp, lib/mcp/utils.test.ts
  • biome, check:api-validation:strict, check:comment-hygiene, check:test-patterns; full suite, type-check, and audits run in CI

Checklist

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

…covery

An MCP server whose hostname no longer resolves made tool discovery answer 500 and log at error. McpDnsResolutionError is now a server-unavailable condition (discover 422, v2 503), and categorizeError maps it to 502 and egress/domain refusals to 403, matching test-connection and server lifecycle.
@vercel

vercel Bot commented Oct 23, 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 Oct 23, 2026 7:58pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Heads up: you’re close to your flex budget. Increase your flex budget so reviews don’t pause.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

Classifies MCP DNS failures and blocked server URLs without returning their raw error messages.

  • MCP hostname and egress errors get distinct responses.

No actionable issues found. Tests were inspected but not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  DNS[McpDnsResolutionError] --> Unavailable[isMcpServerUnavailableError]
  Unavailable --> Discover[Discovery GET: 422]
  Unavailable --> V2[V2 tool listing: 503]
  DNS --> Categorize[categorizeError]
  Blocked[McpSsrfError or McpDomainNotAllowedError] --> Categorize
  Categorize --> DNSResponse[DNS: 502 with generic message]
  Categorize --> PolicyResponse[Egress refusal: 403 with generic message]
Loading

Reviews (1) · Last reviewed commit: "fix(mcp): classify unresolvable and egre..." · Reviewed by Greptile

@waleedlatif1
waleedlatif1 merged commit 4d26987 into staging Oct 23, 2026
67 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/mcp-discovery-dns-unavailable branch October 23, 2026 20:14

This branch was previously deployed

1 inactive deployment
Preview — 9d4550f1 Deployed Oct 23, 2026 by vercel[bot]
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