-
Notifications
You must be signed in to change notification settings - Fork 8.9k
feature: add global and branch session and lock management MCP tools #7893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.x
Are you sure you want to change the base?
Conversation
…o get token easily
…on and structuring
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.x #7893 +/- ##
============================================
- Coverage 71.20% 70.85% -0.35%
Complexity 797 797
============================================
Files 1300 1300
Lines 49620 49620
Branches 5874 5874
============================================
- Hits 35331 35158 -173
- Misses 11371 11548 +177
+ Partials 2918 2914 -4
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds MCP (Model Context Protocol) tools to enable LLM-based management of Seata's global transactions, branch sessions, and distributed locks. It implements namespace discovery, session management operations, lock management, and a user confirmation mechanism for destructive operations.
Key Changes:
- Introduced MCP tool classes for querying and managing global/branch sessions and locks with user confirmation workflow
- Added RPC service layer for communicating with TC nodes via REST APIs with JWT authentication
- Enhanced JWT token handling to support async dispatches and preserve credentials for MCP operations
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 21 comments.
Show a summary per file
| File | Description |
|---|---|
| NameSpaceTools.java | Provides tool to discover registered TC node namespaces and clusters |
| ModifyConfirmTools.java | Implements user confirmation mechanism before destructive operations |
| GlobalSessionTools.java | MCP tools for querying, deleting, and managing global transaction sessions |
| BranchSessionTools.java | MCP tools for managing branch transaction lifecycle operations |
| GlobalLockTools.java | MCP tools for querying, checking, and deleting distributed locks |
| ModifyConfirmServiceImpl.java | Service implementation for generating and validating time-limited modification keys |
| MCPRPCServiceImpl.java | RPC service for making authenticated HTTP calls to TC nodes |
| GlobalSessionVO.java | Value object for global session data serialization |
| GlobalLockVO.java | Value object for global lock data serialization |
| BranchSessionVO.java | Value object for branch session data serialization |
| GlobalSessionParamDto.java | DTO for global session query parameters with time range support |
| GlobalLockParamDto.java | DTO for global lock query parameters |
| GlobalSessionParam.java | Internal parameter object for global session queries |
| GlobalLockParam.java | Internal parameter object for global lock queries |
| GlobalLockDeleteParam.java | Parameter object for lock deletion operations |
| GlobalAbnormalSessionParam.java | Parameter object for querying abnormal transaction sessions |
| DateUtils.java | Utility class for date/time conversions and validations |
| TimestampToStringDeserializer.java | Jackson deserializer for converting timestamps to formatted strings |
| NameSpaceDetail.java | Configuration object for specifying TC node namespace details |
| RPCConstant.java | Constants for REST API endpoint paths |
| JwtTokenUtils.java | Updated to preserve JWT token in authentication credentials |
| JwtAuthenticationTokenFilter.java | Enhanced to support async request dispatching |
| pom.xml | Added seata-core dependency for MCP tools |
| changes/zh-cn/2.x.md | Chinese changelog entry |
| changes/en-us/2.x.md | English changelog entry |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
console/src/main/java/org/apache/seata/mcp/tools/GlobalSessionTools.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/service/impl/ConsoleRemoteServiceImpl.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/core/utils/DateUtils.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/service/impl/MCPRPCServiceImpl.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/service/impl/MCPRPCServiceImpl.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/service/impl/MCPRPCServiceImpl.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/core/props/NameSpaceDetail.java
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/service/impl/MCPRPCServiceImpl.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/service/impl/MCPRPCServiceImpl.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/service/impl/ConsoleRemoteServiceImpl.java
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/service/impl/ConsoleRemoteServiceImpl.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 30 out of 36 changed files in this pull request and generated 17 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
console/src/main/java/org/apache/seata/mcp/service/impl/ConsoleRemoteServiceImpl.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/entity/dto/McpGlobalSessionParamDto.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/tools/GlobalSessionTools.java
Outdated
Show resolved
Hide resolved
| if (!userInputStr.contains("确认") && !userInputStr.contains("confirm")) { | ||
| throw new IllegalArgumentException( | ||
| "Confirmation string must explicitly contain '确认' or 'confirm' and repeat the modification content. This must come from the user."); | ||
| } |
Copilot
AI
Dec 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation logic for user confirmation is weak and could be bypassed with minimal effort. The check only verifies that the input contains "确认" or "confirm" but doesn't validate that the user actually understood what they're confirming. A malicious actor or automated tool could easily provide a string that contains these words. Consider implementing a more robust confirmation mechanism, such as requiring the user to type the specific XID or operation details they're confirming.
namingserver/src/main/java/org/apache/seata/namingserver/service/ConsoleLocalServiceImpl.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/tools/GlobalLockTools.java
Outdated
Show resolved
Hide resolved
namingserver/src/main/java/org/apache/seata/namingserver/service/ConsoleLocalServiceImpl.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/service/impl/ModifyConfirmServiceImpl.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/service/impl/ModifyConfirmServiceImpl.java
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/entity/vo/McpGlobalSessionVO.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 30 out of 36 changed files in this pull request and generated 13 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
console/src/main/java/org/apache/seata/mcp/entity/vo/McpGlobalLockVO.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/service/impl/ConsoleRemoteServiceImpl.java
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/core/utils/DateUtils.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/service/impl/ConsoleRemoteServiceImpl.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/service/impl/ConsoleRemoteServiceImpl.java
Outdated
Show resolved
Hide resolved
namingserver/src/main/java/org/apache/seata/namingserver/service/ConsoleLocalServiceImpl.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/tools/GlobalSessionTools.java
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/tools/GlobalLockTools.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/tools/GlobalLockTools.java
Outdated
Show resolved
Hide resolved
namingserver/src/main/java/org/apache/seata/namingserver/service/ConsoleLocalServiceImpl.java
Show resolved
Hide resolved
…y the requesting TC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 34 out of 40 changed files in this pull request and generated 13 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Ⅰ. Describe what this PR did
tool for obtaining namespace information of registered TC nodes has been implemented
Management tools for global and branch session have been implemented
The function of remotely invoking the TC interface has been realized
A global lock management tool has been implemented
Ⅱ. Does this pull request fix one issue?
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews