Skip to content

Treat missing MCP API-key servers as pending credentials during install - #219

Open
Minitour wants to merge 1 commit into
developfrom
cursor/skip-unresolved-mcp-validation-5337
Open

Treat missing MCP API-key servers as pending credentials during install#219
Minitour wants to merge 1 commit into
developfrom
cursor/skip-unresolved-mcp-validation-5337

Conversation

@Minitour

@Minitour Minitour commented Sep 7, 2026

Copy link
Copy Markdown
Member

Summary

Unattended capa install (including Cursor Cloud Agent environment builds) was exiting 1 because ShareCube MCP tools failed validation when ${ShareCubeApiKey} was not set. OAuth2 servers were already treated as pending; API-key servers were not.

What changed

  • Classify MCP servers whose defs still reference missing ${vars} or unresolved secret sources as pending credentials
  • Remap those tools to pendingAuth the same way disconnected OAuth2 servers already are
  • CLI copy now says "pending credentials" instead of "pending OAuth2"

Screenshots / logs

Environment build bld-20260907-5fbb6124-f160-432c-a739-b0ac8a5e782a failed with:

15 of 32 tool(s) failed validation:
  • sharecube.list_projects
  …
  Available tools: (none)
✗ Install completed with 15 failure(s).
[INSTALL] Exit code: 1

Slack/Atlassian on the same run were pending OAuth2 and did not fail the install.

Published capa 2.1.2 already treats install validation errors as warnings (exit 0). This PR is the remaining UX fix so missing API-key MCP servers show as pending credentials instead of 15 failed tools.

Test plan

  • Unit tests for mcpServerIdsPendingCredentials (missing var, present var, secret-source object)
  • bun test — 1837 pass
  • bunx tsc --noEmit
  • CI: tests (Linux/macOS/Windows), lint, CodeQL, dependency review, Code Smells — all green
  • Draft Cloud Agent environment build bld-20260907-277b47e2-5485-4492-824e-fd50cdf66050 succeeded with capa 2.1.2 (capa --headless install --yes, exit 0). Recurring builds still need the dashboard install command saved until this ships in a release.

Checklist

  • Tests added or updated
  • bunx tsc --noEmit passes
  • bun run smells clean vs base (or CI Qlty Smells job green)
  • Docs updated (if user-facing) — CLI status string only; no schema change

capa install was failing unattended environment builds because ShareCube
tools validated against an empty Bearer ${ShareCubeApiKey} and were
counted as hard failures. OAuth2 servers were already remapped to
pendingAuth; apply the same skip to servers whose defs still reference
missing ${vars} or unresolved secret sources.
@Minitour
Minitour marked this pull request as ready for review September 7, 2026 21:38
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Treat missing MCP credentials as pending during install

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Detect MCP servers with missing variables or unresolved secret credentials during installation.
• Remap their validation failures to pending authentication alongside disconnected OAuth2 servers.
• Generalize install status messaging from pending OAuth2 to pending credentials.
Diagram

graph TD
  A["MCP Definitions"] --> B["Missing Variables"] --> C["Credential Classifier"] --> D["Pending Servers"] --> F["Validation Remap"] --> G["pendingAuth Results"] --> H["Install Status"]
  E["OAuth Connections"] --> D
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Skip pending servers before validation
  • ➕ Avoids unnecessary connection attempts for servers known to lack credentials.
  • ➕ Reduces validation latency and expected authentication errors in lower-level logs.
  • ➖ Requires changing validation inputs or synthesizing per-tool results.
  • ➖ May lose the complete tool-level records currently used by install reporting.
  • ➖ Diverges from the established OAuth2 post-validation remapping behavior.

Recommendation: Keep the PR's post-validation remapping approach for this focused fix. It unifies API-key and OAuth2 handling, preserves complete tool-level reporting, and minimizes changes to the validation pipeline; pre-filtering is only worthwhile if futile connection attempts become a measurable performance concern.

Files changed (5) +106 / -14

Bug fix (3) +47 / -13
configure-tools.tsGeneralize pending-authentication install messaging +2/-2

Generalize pending-authentication install messaging

• Changes tool configuration summaries and task titles from “pending OAuth2” to “pending credentials,” covering both OAuth2 and API-key authentication.

src/cli/commands/install-tasks/configure-tools.ts

configure-routes.tsReclassify missing-credential validation results as pending +18/-11

Reclassify missing-credential validation results as pending

• Combines disconnected OAuth2 servers with MCP servers that have unresolved credentials. Their validation results are marked successful with 'pendingAuth', excluded from hard failures, and reported through generalized pending-credential logging.

src/server/configure-routes.ts

secret-value.tsIdentify MCP servers awaiting credentials +27/-0

Identify MCP servers awaiting credentials

• Adds 'mcpServerIdsPendingCredentials' to find server definitions referencing known missing variables or unresolved secret sources in environment and header values.

src/shared/secret-value.ts

Tests (1) +58 / -0
secret-value.test.tsCover MCP pending-credential classification +58/-0

Cover MCP pending-credential classification

• Adds unit tests for missing placeholders, available variables, and unresolved secret-source objects in MCP headers.

src/shared/tests/secret-value.test.ts

Documentation (1) +1 / -1
mcp-validate-tools.tsClarify pendingAuth credential scope +1/-1

Clarify pendingAuth credential scope

• Updates the 'pendingAuth' field documentation to include pending API keys as well as OAuth2 authentication.

src/server/mcp-validate-tools.ts

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Valid credentials hide broken tools 🐞 Bug ≡ Correctness
Description
mcpServerIdsPendingCredentials treats every secret-source object in env or headers as
unresolved without checking whether its environment variable, file, or command can resolve. When the
source is available but a configured remote tool does not exist, validation finds the real mismatch
and then runProjectConfigure overwrites that failure as pending authentication and removes its
error.
Code

src/shared/secret-value.ts[R249-250]

+			hasUnresolvedSecretSources(server.def.env) ||
+			hasUnresolvedSecretSources(server.def.headers)
Evidence
External secret objects are supported references that can resolve successfully, and validation
resolves them before listing remote tools. The validator separately records missing-tool failures,
but the new pending-server remapping converts every result for a syntactically referenced secret
source to success and deletes the diagnostic.

src/shared/secret-value.ts[79-130]
src/server/mcp-proxy.ts[306-328]
src/server/mcp-validate-tools.ts[105-145]
src/server/configure-routes.ts[367-375]
src/types/capabilities.ts[334-342]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Secret-source objects are classified as pending merely because they remain objects in the authored definition, even when they resolve successfully during validation. This masks real validation errors such as nonexistent remote tools.

## Issue Context
`resolveMcpServerDef` resolves supported external sources before connecting, while the pending classifier currently inspects only their syntax. Preserve genuine validation results whenever credential resolution succeeds.

## Fix Focus Areas
- src/shared/secret-value.ts[237-255]
- src/server/configure-routes.ts[354-375]
- src/server/mcp-proxy.ts[306-328]
- src/server/mcp-validate-tools.ts[105-145]
- src/shared/__tests__/secret-value.test.ts[158-173]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Plugin tools still fail during install 🐞 Bug ≡ Correctness
Description
runProjectConfigure passes missingVars extracted from authored capabilities into the pending
classifier even though it validates servers from plugin-merged capabilitiesToUse. When a plugin
server definition contains a missing placeholder, the outer plugin marker excludes that variable
from missingVars, so its tools remain failed and no credential setup is offered for it.
Code

src/server/configure-routes.ts[R354-356]

+		for (const id of mcpServerIdsPendingCredentials(
+			capabilitiesToUse.servers ?? [],
+			missingVars,
Evidence
Effective capabilities replace the authored object when plugins are present, and merged MCP servers
carry sourcePlugin on their outer server object. The required-variable scan uses the authored
capabilities and skips plugin-sourced objects, while the new helper can classify an effective server
placeholder only if its name is already present in that incomplete missing-variable list.

src/server/configure-routes.ts[207-221]
src/server/configure-routes.ts[318-329]
src/cli/commands/plugin-install.ts[544-570]
src/shared/variable-resolver.ts[116-133]
src/shared/secret-value.ts[237-252]
src/server/configure-routes.ts[406-430]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Pending classification checks effective plugin server definitions against a missing-variable list built only from authored capabilities. Missing placeholders in plugin-contributed MCP servers therefore cannot match that list.

## Issue Context
Variable extraction intentionally skips outer objects carrying `sourcePlugin` to avoid treating plugin prose as credentials. Inspect effective MCP server definitions individually and query their required values without scanning unrelated plugin content.

## Fix Focus Areas
- src/server/configure-routes.ts[318-329]
- src/server/configure-routes.ts[354-359]
- src/shared/secret-value.ts[237-255]
- src/shared/variable-resolver.ts[116-133]
- src/shared/__tests__/secret-value.test.ts[119-173]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
Review mode: ⚖️ Balanced: This changes install-time MCP validation and credential classification across server configuration and shared secret-resolution logic, creating meaningful behavioral and compatibility risk despite the focused scope.

Grey Divider

Tip of the day
💡 Did you know, you can copy the agent prompt from any finding and feed it to your IDE agent

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines +249 to +250
hasUnresolvedSecretSources(server.def.env) ||
hasUnresolvedSecretSources(server.def.headers)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Valid credentials hide broken tools 🐞 Bug ≡ Correctness

mcpServerIdsPendingCredentials treats every secret-source object in env or headers as
unresolved without checking whether its environment variable, file, or command can resolve. When the
source is available but a configured remote tool does not exist, validation finds the real mismatch
and then runProjectConfigure overwrites that failure as pending authentication and removes its
error.
Agent Prompt
## Issue description
Secret-source objects are classified as pending merely because they remain objects in the authored definition, even when they resolve successfully during validation. This masks real validation errors such as nonexistent remote tools.

## Issue Context
`resolveMcpServerDef` resolves supported external sources before connecting, while the pending classifier currently inspects only their syntax. Preserve genuine validation results whenever credential resolution succeeds.

## Fix Focus Areas
- src/shared/secret-value.ts[237-255]
- src/server/configure-routes.ts[354-375]
- src/server/mcp-proxy.ts[306-328]
- src/server/mcp-validate-tools.ts[105-145]
- src/shared/__tests__/secret-value.test.ts[158-173]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +354 to +356
for (const id of mcpServerIdsPendingCredentials(
capabilitiesToUse.servers ?? [],
missingVars,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

2. Plugin tools still fail during install 🐞 Bug ≡ Correctness

runProjectConfigure passes missingVars extracted from authored capabilities into the pending
classifier even though it validates servers from plugin-merged capabilitiesToUse. When a plugin
server definition contains a missing placeholder, the outer plugin marker excludes that variable
from missingVars, so its tools remain failed and no credential setup is offered for it.
Agent Prompt
## Issue description
Pending classification checks effective plugin server definitions against a missing-variable list built only from authored capabilities. Missing placeholders in plugin-contributed MCP servers therefore cannot match that list.

## Issue Context
Variable extraction intentionally skips outer objects carrying `sourcePlugin` to avoid treating plugin prose as credentials. Inspect effective MCP server definitions individually and query their required values without scanning unrelated plugin content.

## Fix Focus Areas
- src/server/configure-routes.ts[318-329]
- src/server/configure-routes.ts[354-359]
- src/shared/secret-value.ts[237-255]
- src/shared/variable-resolver.ts[116-133]
- src/shared/__tests__/secret-value.test.ts[119-173]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@Minitour
Minitour changed the base branch from main to develop September 7, 2026 22:04
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.

2 participants