Skip to content

fix(agent): ignore empty advanced MCP bindings - #7397

Merged
TheodoreSpeaks merged 1 commit into
stagingfrom
fix/mcp-advanced-empty-server
Sep 2, 2026
Merged

fix(agent): ignore empty advanced MCP bindings#7397
TheodoreSpeaks merged 1 commit into
stagingfrom
fix/mcp-advanced-empty-server

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • treat blank MCP Server (Advanced) bindings as inactive
  • avoid MCP discovery and tool creation until a server ID is configured
  • preserve fail-fast behavior for malformed non-string bindings

Type of Change

  • Bug fix

Testing

  • 163 focused MCP and Agent tests passed
  • lint and all 45 repository audits passed

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)

@vercel

vercel Bot commented Sep 2, 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 2, 2026 9:28am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR treats blank advanced MCP server bindings as inactive while retaining validation errors for missing or non-string server IDs.

  • Skips blank bindings before Agent MCP discovery and tool creation.
  • Omits blank bindings from Mothership MCP request expansion.
  • Aligns shared validation with the inactive-binding behavior.
  • Adds focused tests for Agent, Mothership, and shared validation paths.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness, security, or repository-rule issues identified.

Blank string bindings are consistently removed before MCP discovery in both execution paths, while missing and non-string server IDs continue to fail validation and valid sibling bindings remain unaffected.

Important Files Changed

Filename Overview
apps/sim/executor/handlers/agent/agent-handler.ts Filters blank advanced MCP server IDs during tool partitioning so they never reach discovery or provider tool creation.
apps/sim/executor/handlers/mothership/mothership-handler.ts Skips each blank advanced binding within the flat-map expansion while preserving valid sibling bindings and malformed-value errors.
apps/sim/lib/mcp/shared.ts Treats blank string IDs as inactive while continuing to reject missing and non-string IDs and validate active-binding conflicts.
apps/sim/executor/handlers/agent/agent-handler.test.ts Verifies a blank advanced binding causes neither MCP discovery nor provider tool creation.
apps/sim/executor/handlers/mothership/mothership-handler.test.ts Verifies a blank advanced binding is not discovered or forwarded in the Mothership request.
apps/sim/lib/mcp/shared.test.ts Covers blank and whitespace-only inactive bindings while retaining fail-fast coverage for malformed active bindings.

Reviews (1): Last reviewed commit: "fix(agent): ignore empty advanced MCP bi..." | Re-trigger Greptile

@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.

1 issue found across 6 files

Confidence score: 3/5

  • In apps/sim/lib/mcp/shared.ts, validateToolPermissions rejects a blank advanced binding before formatTools can ignore it, so workspaces with MCP tools disabled may be unable to run agents; align validation with the inactive-binding behavior and add a regression test.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/sim/lib/mcp/shared.ts">

<violation number="1" location="apps/sim/lib/mcp/shared.ts:55">
P2: When MCP tools are disabled for a workspace, a blank advanced binding now blocks the agent run even though it is intended to be inactive: `validateToolPermissions` sees the advanced entry before `formatTools` ignores it. Filter blank advanced bindings before the permission check, or make the permission check consider only active MCP bindings.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

if (typeof serverId !== 'string') {
throw new Error('MCP Server (Advanced) requires params.serverId')
}
if (!serverId.trim()) continue

@cubic-dev-ai cubic-dev-ai Bot Sep 2, 2026

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.

P2: When MCP tools are disabled for a workspace, a blank advanced binding now blocks the agent run even though it is intended to be inactive: validateToolPermissions sees the advanced entry before formatTools ignores it. Filter blank advanced bindings before the permission check, or make the permission check consider only active MCP bindings.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/sim/lib/mcp/shared.ts, line 55:

<comment>When MCP tools are disabled for a workspace, a blank advanced binding now blocks the agent run even though it is intended to be inactive: `validateToolPermissions` sees the advanced entry before `formatTools` ignores it. Filter blank advanced bindings before the permission check, or make the permission check consider only active MCP bindings.</comment>

<file context>
@@ -49,9 +49,10 @@ export function assertValidMcpServerToolBindings(value: unknown): void {
+    if (typeof serverId !== 'string') {
       throw new Error('MCP Server (Advanced) requires params.serverId')
     }
+    if (!serverId.trim()) continue
     if (advancedServerIds.has(serverId)) {
       throw new Error(`Duplicate MCP Server (Advanced) binding for ${serverId}`)
</file context>
Fix with cubic

@TheodoreSpeaks
TheodoreSpeaks merged commit ee5414e into staging Sep 2, 2026
29 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the fix/mcp-advanced-empty-server branch September 2, 2026 09:33
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