Skip to content

fix: handle MCP tool setup failures - #2653

Open
erichare wants to merge 1 commit into
fix/mcp-request-context-cleanupfrom
fix/mcp-setup-errors
Open

erichare wants to merge 1 commit into
fix/mcp-request-context-cleanupfrom
fix/mcp-setup-errors

Conversation

@erichare

@erichare erichare commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does:

Defers MCP context setup and handles request, schema, and provider setup failures at one shared boundary. Known non-security Data API errors keep their codes and messages, while unexpected setup failures return a generic error. HTTP authentication, protocol, cancellation, and processor failures keep their existing handling. A token the database rejects after HTTP authentication returns UNAUTHENTICATED_REQUEST as a tool error, as collection commands already did on main.

Tool results keep empty text content, so the tests check structuredContent and _meta.

Which issue(s) this PR fixes:

Fixes #2628. OAuth admission remains in #2642.

Verification

40 focused tests passed with 0 failures, 0 errors, and 0 skips at e06f92466, this PR's commit in the rebuilt stack. The format check found 0 non-complying files out of 1,204. The new integration test, rejectedTokenReturnsAnApplicationErrorThenAValidCallSucceeds, did not run locally: the amd64 DSE container ran out of memory under emulation on this arm64 machine. Both CI integration jobs run McpSetupErrorsIntegrationTest on this push. CI also runs the unit suite.

JAVA_HOME=/Library/Java/JavaVirtualMachines/graalvm-21.jdk/Contents/Home ./mvnw -B -ntp clean com.spotify.fmt:fmt-maven-plugin:check test -DskipITs -Dxml-format.skip=true -Dsurefire.failIfNoSpecifiedTests=false -Dquarkus.http.test-port=19089 '-Dtest=McpSetupErrorsTest,McpResourceTest,CommandResultToToolResponseTest'

Manual client checks were not run.

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CLA Signed: DataStax CLA

MCP stack

Merges bottom up; row 1 is the bottom of the stack.

# PR Change Issue
1 #2651 Show accepted update syntax in tool schemas Fixes #2631
2 #2658 Describe every tool argument Part of #2604
3 #2645 Close the command context after each call Part of #2629
4 #2653 Return useful errors when setup fails Fixes #2628
5 #2648 Keep payloads and credentials out of logs Fixes #2635
6 #2649 Describe side effects and retry behavior Fixes #2636
7 #2655 Validate commands like the HTTP API Fixes #2632
8 #2656 Test request isolation, document tracing Refs #2629
9 #2657 Reject unapproved browser origins Part of #2630
10 #2659 Serve only protocol 2026-07-28 Part of #2625, #2626
11 #2669 Add opt-in OAuth authentication Refs #2642, #2643

@erichare
erichare requested a review from a team as a code owner October 22, 2026 17:14
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

📈 Unit Test Coverage Delta vs Main Branch

Metric Value
Main Branch 56.74%
This PR 57.31%
Delta 🟢 +0.57%
✅ Coverage improved!

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Unit Test Coverage Report

Overall Project 57.31% -0.04% 🍏
Files changed 86.17% 🍏

File Coverage
McpResource.java 90.03% -9.97% 🍏

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

📈 Integration Test Coverage Delta vs Main Branch (dse69-it)

Metric Value
Main Branch 72.98%
This PR 72.99%
Delta 🟢 +0.01%
✅ Coverage improved!

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Integration Test Coverage Report (dse69-it)

Overall Project 72.99% -0.05% 🍏
Files changed 81.56% 🍏

File Coverage
McpResource.java 85.03% -13.2% 🍏

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

📈 Integration Test Coverage Delta vs Main Branch (hcd-it)

Metric Value
Main Branch 74.33%
This PR 74.33%
Delta 🟢 +0.00%
✅ Coverage improved!

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Integration Test Coverage Report (hcd-it)

Overall Project 74.33% -0.05% 🍏
Files changed 81.56% 🍏

File Coverage
McpResource.java 85.03% -13.2% 🍏

@erichare
erichare added this pull request to stack #2660 October 23, 2026 22:14
@erichare
erichare force-pushed the fix/mcp-setup-errors branch from 71765e2 to 81ed051 Compare October 27, 2026 23:08
@erichare
erichare removed this pull request from stack #2660 October 27, 2026 23:11
@erichare
erichare changed the base branch from fix/mcp-readable-results to fix/mcp-request-context-cleanup October 27, 2026 23:11
@erichare
erichare added this pull request to stack #2667 October 27, 2026 23:12
@erichare erichare mentioned this pull request Oct 28, 2026
3 of 4 tasks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant