Skip to content

feat: add Spring AI MCP tool adapter - #3645

Open
zgzyq wants to merge 1 commit into
alibaba:1.8from
zgzyq:feat/spring-ai-mcp-adapter-3581
Open

feat: add Spring AI MCP tool adapter#3645
zgzyq wants to merge 1 commit into
alibaba:1.8from
zgzyq:feat/spring-ai-mcp-adapter-3581

Conversation

@zgzyq

@zgzyq zgzyq commented Sep 3, 2026

Copy link
Copy Markdown

Describe what this PR does / why we need it

Adds a transport-independent Spring AI MCP adapter that protects individual
tool calls with Sentinel. MCP transports share fixed endpoints, so URL-level
WebMVC/WebFlux interception cannot distinguish tools. Decorating tool
specifications creates stable resources such as mcp:tool:echo.

Does this pull request fix one issue?

Fixes #3581

Describe how you did it

  • add a Java 17 adapter module based on Spring AI 2.0.1 and MCP Java SDK 2.0.0
  • decorate stateful and stateless synchronous/asynchronous tool specifications
  • create inbound COMMON_RPC entries per tool and trace execution errors
  • keep async entries open until completion, error, or cancellation
  • guarantee every entered resource exits exactly once

Describe how to verify it

mvn -pl sentinel-adapter/sentinel-spring-ai-mcp-adapter -am test

The tests cover success, blocking, exception tracing, async completion,
cancellation, stateless tool specifications, and actual Sentinel flow rules.

Special notes for reviews

This intentionally leaves HTTP/SSE/WebMVC/WebFlux adapters unchanged. The
protection point is the MCP tool handler, so resource naming remains consistent
across transports.

@CLAassistant

CLAassistant commented Sep 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@oss-sentinel-ai

Copy link
Copy Markdown

CLA Not Signed

The Contributor License Agreement (CLA) check is currently pending on this PR (license/cla: Contributor License Agreement is not signed yet.). This PR cannot be merged until the CLA is signed.

@zgzyq please sign the CLA via the CLA assistant badge in the comment above, or visit https://cla-assistant.io/alibaba/Sentinel. Once signed, the license/cla status will turn green.


Automated check by github-manager-bot

@oss-sentinel-ai oss-sentinel-ai left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

This PR adds a decorator for synchronous and reactive Spring AI MCP tool specifications, creating inbound COMMON_RPC Sentinel resources named mcp:tool:<tool-name>, tracing thrown failures, and retaining async entries through completion, error, or cancellation. Its lifecycle pairing and BlockException handling align with the existing Reactor adapter, and its Java 17 and local version conventions match existing optional adapter modules.

LGTM — code changes look good, but this PR cannot be approved/merged until the contributor signs the CLA (see the CLA reminder comment above). Once the CLA is signed, feel free to @mention me for a re-review.


Automated review by github-manager-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.

Will Sentinel support SpringAI MCP adapter

3 participants