Skip to content

MCP-714 Use SDK native filtering for HTTP tool discovery - #727

Draft
nquinquenel wants to merge 1 commit into
masterfrom
feat/nquinquenel/MCP-714-nativeToolFiltering
Draft

nquinquenel wants to merge 1 commit into
masterfrom
feat/nquinquenel/MCP-714-nativeToolFiltering

Conversation

@nquinquenel

Copy link
Copy Markdown
Member

MCP-714 https://sonarsource.atlassian.net/browse/MCP-714

Human description

HTTP tool discovery now uses the MCP SDK native filter. Request toolsets, read-only settings, OAuth scopes and tool enablement continue to narrow server permissions. Direct calls retain their authorization checks and OAuth challenges. Organization-specific schemas remain supported.

Agent description

The SDK 2.1.0 dependency is already present. The filter uses request transport context and the server-enabled tool registry. The response wrapper adjusts organization schemas while preserving SDK cursors, metadata and errors. Unsupported-method handling and stdio behavior stay unchanged. No performance gain is assumed.

Acceptance coverage: regression tests use a real SDK delegate for discovery, cover concurrent request isolation and hidden-tool call rejection, and retain OAuth, schema and direct-call coverage.

Vortex: repository project SonarSource_sonarqube-mcp-server is bound and both entitlements are enabled. Java guidance covered authentication, concurrency, tests and API design. The implementation keeps request state local and call authorization independent of discovery. DEEP analysis fixed one record-pattern finding. One finding remains on an untouched line: src/main/java/org/sonarsource/sonarqube/mcp/SonarQubeMcpServer.java:220, java:S106, “Replace this use of System.out by a logger.” Changed-file secrets scan passed. Dependency analysis reported eight existing LOW risks; dependencies did not change.

Independent review: clean, round 1, gpt-6.1-sol, zero blocking findings.

Validation gaps: Docker integration tests could not run because the local Docker daemon is unavailable; CI must cover the HTTP, STDIO and proxy integration suites. The independent reviewer could not execute Gradle because its isolated environment lacked the cached distribution and cannot reach the download host. Host preparation was not validated because repository guidance supplies no preparation plan. Host unit tests and spotlessCheck passed.

Repository guidance: root AGENTS.md was read. There is no ADR directory; this bounded transport change needs no decision record. Attachments used: none. Rollback: revert the implementation commit. No migration is required.

Usage: 7634684 tokens; gpt-6.1-sol. Review usage: 698662 tokens, one session.

This PR is opened as a draft by autonomous Fabrik. It may become ready only after its mechanical gates pass. Human approval and merge are required.


🤖 Co-authored by Fabrik

Co-Authored-By: Fabrik <fabrik@sonar.ai>
@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

MCP-714

@gitar-bot

gitar-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk 1 closed / 1 findings

Moving OAuth- and request-restriction checks into SDK discovery filtering could expose restricted tool schemas if request context is misapplied; direct-call checks remain.

Switches HTTP tool discovery to the MCP SDK native filter, using request transport context and the server-enabled tool registry while preserving request toolsets, read-only settings, OAuth scopes, and organization-specific schemas. The previously raised concern about tool-list loss once PR #681 lands was resolved by confirming the current head uses a consistent enabledTools list, with the rebase note to retain this filter when #681 merges. No open findings remain.

✅ 1 closed
✅ Cross-PR: HTTP tool filter loses its tool list once #681 lands

📄 src/main/java/org/sonarsource/sonarqube/mcp/SonarQubeMcpServer.java:260-267 📄 src/main/java/org/sonarsource/sonarqube/mcp/transport/PerRequestToolFilteringHandler.java:130-139
Breaks when this PR and #681 both merge, in either order. The PR that merges second fails to compile, or its rebase builds the SDK tool filter from a list other than the one passed to .tools(...).

How

  1. This PR registers .addToolFilter(PerRequestToolFilteringHandler.toolFilter(enabledTools)) at SonarQubeMcpServer.java:266. enabledTools comes from filterForEnabledTools(supportedTools) at line 260.
  2. MCP-713 Declare tool availability and centralize registration #681 removes supportedTools and filterForEnabledTools. It rewrites start() so that getFilteringTransport(...) and .tools(...) both use the registeredTools field (SonarQubeMcpServer.java:253,257).
  3. toolFilter looks up each listed definition by name and returns false when the name is missing (PerRequestToolFilteringHandler.java:133-135). If the filter's list does not match the registered list, tools/list hides registered tools while tools/call still runs them.

Fix

Compared 1cea4d0 with #681 at 3b5b324

Verification Rules 2/2 met Knowledge ✅ 2 PRs 2 inspected

Functional validation No results

Rules 2 passed 2 not applicable

✅ Internal artifact registries
✅ Repository license compliance

Knowledge ✅ 2 expectations met

Expectation met Architecture tools are Cloud-only and opt-in expectation met
Expectation met Architecture tools remain Cloud-only expectation met

Broader impact PRs 2 inspected
Cross-PR 2 PRs inspected 0 open impacts

PR 681: MCP-713 Declare tool availability and centralize registration Inspected
PR 726: MCP-742 Stabilize tool input schema serialization Inspected

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqubecloud

Copy link
Copy Markdown

@nquinquenel
nquinquenel marked this pull request as ready for review November 11, 2026 14:08
@nquinquenel
nquinquenel requested a review from a team as a code owner November 11, 2026 14:08
@nquinquenel
nquinquenel marked this pull request as draft November 12, 2026 13:05
@nquinquenel
nquinquenel removed the request for review from damien-urruty-sonarsource November 12, 2026 13:05

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant