-
Notifications
You must be signed in to change notification settings - Fork 8.9k
feature: add MCP custom configuration and authentication code #7876
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.x #7876 +/- ##
============================================
+ Coverage 71.11% 71.12% +0.01%
Complexity 797 797
============================================
Files 1300 1300
Lines 49601 49601
Branches 5875 5875
============================================
+ Hits 35274 35281 +7
+ Misses 11406 11403 -3
+ Partials 2921 2917 -4 🚀 New features to boost your workflow:
|
|
Has the previous MCP-related content been merged, or should we merge this one first? |
| @Bean | ||
| public WebSecurityCustomizer webSecurityCustomizer() { | ||
| RequestMatcher[] ignoredMatchers = buildAntMatchers(env.getProperty("seata.security.ignore.urls", "/**")); | ||
| StringBuilder ignoreURLs = new StringBuilder(env.getProperty("seata.security.ignore.urls", "/**")); |
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.
maybe we can use string joiner
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.
I tried before. The path that needs to be ignored directly passed in as a string cannot be configured correctly. It needs to be converted to the RequestMatcher array (it might be a problem with the new version of security).
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 Model Context Protocol (MCP) server support to the Seata console by introducing custom configuration properties and authentication mechanisms for MCP endpoints.
Key Changes:
- Added MCP server configuration properties in
application.ymlincluding protocol type, endpoints, query duration limits, and authentication settings - Implemented
MCPPropertiesclass to manage MCP configuration with support for both SSE and streamable HTTP protocols - Created
MCPAuthenticationFilterto handle username/password authentication via custom HTTP headers for MCP endpoints
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| namingserver/src/main/resources/application.yml | Adds MCP server configuration including protocol settings, endpoints, query duration limit, and authentication toggle |
| console/src/main/java/org/apache/seata/mcp/core/props/MCPProperties.java | New properties class that loads and manages MCP configuration from environment, supporting both SSE and streamable protocols |
| console/src/main/java/org/apache/seata/console/filter/MCPAuthenticationFilter.java | New authentication filter that extracts credentials from custom headers and validates them using Spring Security |
| console/src/main/java/org/apache/seata/console/config/WebSecurityConfig.java | Updates security configuration to add MCP endpoints to ignore and CSRF ignore lists |
| console/src/main/java/org/apache/seata/console/config/MCPFiltersConfig.java | Registers the MCP authentication filter and conditionally enables it based on configuration |
| changes/zh-cn/2.x.md | Documents the feature addition in Chinese changelog |
| changes/en-us/2.x.md | Documents the feature addition in English changelog |
Comments suppressed due to low confidence (1)
console/src/main/java/org/apache/seata/console/config/WebSecurityConfig.java:117
- The MCP endpoints are being added to both the ignore URLs and CSRF ignore URLs. However, there's a logical conflict: if endpoints are in the ignore URLs list (which bypasses all security), they won't reach the MCPAuthenticationFilter that's registered in MCPFiltersConfig. This means authentication will never be enforced for MCP endpoints, even when seata.mcp.auth.enabled is true. Either remove MCP endpoints from the ignore list or reconsider the authentication strategy.
StringBuilder ignoreURLs = new StringBuilder(env.getProperty("seata.security.ignore.urls", "/**"));
List<String> mcpEndpoints = mcpProperties.getEndpoints();
for (String endpoint : mcpEndpoints) {
ignoreURLs.append(",").append(endpoint);
}
RequestMatcher[] ignoredMatchers =
buildAntMatchers(ignoreURLs.toString().trim());
return web -> {
if (ignoredMatchers.length > 0) {
web.ignoring().requestMatchers(ignoredMatchers);
}
};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
console/src/main/java/org/apache/seata/mcp/core/props/MCPProperties.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/console/filter/MCPAuthenticationFilter.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/console/filter/MCPAuthenticationFilter.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/console/filter/MCPAuthenticationFilter.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/console/filter/MCPAuthenticationFilter.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/core/props/MCPProperties.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/core/props/MCPProperties.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/core/props/MCPProperties.java
Outdated
Show resolved
Hide resolved
Previously, only the dependencies related to MCP were introduced. Now, this PR introduces the MCP security configuration and custom parameter configuration. It can be directly merged in without any impact. |
xjlgod
left a comment
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.
LGTM
console/src/main/java/org/apache/seata/console/config/WebSecurityConfig.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/console/filter/MCPAuthenticationFilter.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/console/filter/MCPAuthenticationFilter.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/core/props/MCPProperties.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 7 out of 7 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
console/src/main/java/org/apache/seata/console/filter/MCPAuthenticationFilter.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/core/props/MCPProperties.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/console/config/MCPFiltersConfig.java
Outdated
Show resolved
Hide resolved
| StringBuilder ignoreURLsBuilder = new StringBuilder(ignoreURLs); | ||
| List<String> mcpEndpoints = mcpProperties.getEndpoints(); | ||
| for (String endpoint : mcpEndpoints) { | ||
| ignoreURLsBuilder.append(",").append(endpoint); | ||
| } | ||
| RequestMatcher[] ignoredMatchers = | ||
| buildAntMatchers(ignoreURLsBuilder.toString().trim()); |
Copilot
AI
Dec 23, 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 MCP endpoints are being added to the security ignore list, which means Spring Security will completely bypass authentication for these endpoints. This conflicts with the purpose of MCPAuthenticationFilter which is meant to authenticate MCP requests. When endpoints are in the ignore list, they never reach any security filters. The MCPAuthenticationFilter registered in MCPFiltersConfig will not be invoked for these URLs. Remove the code that adds MCP endpoints to the ignore list if authentication is required for these endpoints.
| StringBuilder ignoreURLsBuilder = new StringBuilder(ignoreURLs); | |
| List<String> mcpEndpoints = mcpProperties.getEndpoints(); | |
| for (String endpoint : mcpEndpoints) { | |
| ignoreURLsBuilder.append(",").append(endpoint); | |
| } | |
| RequestMatcher[] ignoredMatchers = | |
| buildAntMatchers(ignoreURLsBuilder.toString().trim()); | |
| RequestMatcher[] ignoredMatchers = | |
| buildAntMatchers(ignoreURLs.trim()); |
console/src/main/java/org/apache/seata/console/config/MCPFiltersConfig.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/console/filter/MCPAuthenticationFilter.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/console/filter/MCPAuthenticationFilter.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 5 out of 5 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
console/src/main/java/org/apache/seata/console/config/WebSecurityConfig.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/console/config/WebSecurityConfig.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/core/props/MCPProperties.java
Outdated
Show resolved
Hide resolved
console/src/main/java/org/apache/seata/mcp/core/props/MCPProperties.java
Show resolved
Hide resolved
funky-eyes
left a comment
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.
LGTM
Ⅰ. Describe what this PR did
Add configuration file attributes related to MCP
Implement authentication for request paths related to MCP
Ⅱ. 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