-
Notifications
You must be signed in to change notification settings - Fork 8.9k
feature: implement business data source query MCP tool on the console module #8032
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
Open
Xb2555
wants to merge
47
commits into
apache:2.x
Choose a base branch
from
Xb2555:feat-dataSource
base: 2.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
252b00e
optimize: move DBTYPE from core to common
Xb2555 261303c
feat: initialize business data source configuration instance
Xb2555 6116630
feat: Implement multiple types of connection pool instances
Xb2555 6de412d
feat: Implement the functions of initializing the business data sourc…
Xb2555 fd5a402
feat: Implement the underlying SQL statement execution function
Xb2555 29d6d7f
feat: Implement the business data source query function
Xb2555 db15f47
optimize: spotless check
Xb2555 a940624
optimize: Add data source configuration parameters
Xb2555 41f4659
Merge branch 'apache:2.x' into feat-dataSource
Xb2555 d54b641
Merge branch 'apache:2.x' into feat-dataSource
Xb2555 0691fbb
feature: introduce MySQL dependencies in NamingServer
Xb2555 aec66ae
optimize: spotless check
Xb2555 8a6f384
Merge branch '2.x' into feat-dataSource
Xb2555 bfe9fa6
Merge branch '2.x' into feat-dataSource
Xb2555 356a4b0
fix: secure MCP data source filter
fefaaba
fix: stop MCP filter after invalid config
aed31d8
fix: bound dynamic MCP data sources
1547c2b
fix: validate business data source pool sizes
9f34fd4
fix: allow SELECT queries with where clauses
777a9c9
fix: remove sample business datasource passwords
0b4d32f
fix: validate MCP datasource driver before generation
6d63cda
fix: include resource id in datasource error
2857e73
fix: close MCP data sources on shutdown
7e53522
fix: lookup MCP datasource properties dynamically
7d11e87
fix: clarify business datasource tool descriptions
8b8f356
fix: use managed MySQL connector dependency
8e6e173
style: format MCP datasource changes
b154354
test: add MCP datasource core behavior tests
c82eafc
feat: secure mysql mcp datasource tools
86b837e
refactor: simplify datasource mcp tool names
dbb8a16
build: compile console with java 25
9adfdd8
refactor: scope datasource tools to url database
b14eab4
refactor: remove plaintext password from datasource registration
2e5cb05
docs: describe datasource registration mcp params
3b7dd43
style: spotless check
5034459
refactor: move datasource registration to console api
7a0a8a3
feat: encrypt console datasource password input
ddb9799
refactor: use console secret key for datasource password cipher
b82db7d
feat: simplify datasource password handling
c2bd887
feat: add business datasource console page
a637eb3
fix: validate dynamic datasource hosts
c280a47
style: spotless check
c440c8c
fix: avoid tainted datasource jdbc urls
f3e60c8
style: fix mcp checkstyle violations
55201d7
fix: report datasource test validation errors
25a8982
fix: return sanitized datasource test errors
69a9aa4
fix: select database before datasource test query
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
console/src/main/java/org/apache/seata/console/filter/MCPBusinessDataSourceFilter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.seata.console.filter; | ||
|
|
||
| import jakarta.servlet.FilterChain; | ||
| import jakarta.servlet.ServletException; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import jakarta.servlet.http.HttpServletResponse; | ||
| import org.apache.seata.mcp.core.props.BusinessDataSourcesProperties; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.web.filter.OncePerRequestFilter; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Set; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
|
|
||
| public class MCPBusinessDataSourceFilter extends OncePerRequestFilter { | ||
|
|
||
| private final BusinessDataSourcesProperties businessDataSourcesProperties; | ||
|
|
||
| private final Set<String> processedConfigs = ConcurrentHashMap.newKeySet(); | ||
|
|
||
| public MCPBusinessDataSourceFilter(BusinessDataSourcesProperties properties) { | ||
| this.businessDataSourcesProperties = properties; | ||
| } | ||
|
|
||
| @Override | ||
| protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) | ||
| throws ServletException, IOException { | ||
| String combinedHeader = request.getHeader("X-DB-Config"); | ||
| if (combinedHeader != null && !combinedHeader.isEmpty()) { | ||
| String[] jsonConfigs = combinedHeader.split(";"); | ||
| for (String jsonDBConfig : jsonConfigs) { | ||
| if (processedConfigs.contains(jsonDBConfig.trim())) { | ||
| continue; | ||
| } | ||
| try { | ||
| businessDataSourcesProperties.registerDataSourceFromJson(jsonDBConfig.trim()); | ||
| processedConfigs.add(jsonDBConfig.trim()); | ||
|
Xb2555 marked this conversation as resolved.
Outdated
|
||
| } catch (Exception e) { | ||
| if (!response.isCommitted()) { | ||
| response.sendError( | ||
| HttpStatus.BAD_REQUEST.value(), | ||
| "The business database parameter in the request header is incorrect: " | ||
| + e.getMessage()); | ||
| return; | ||
| } | ||
| } | ||
| } | ||
|
Xb2555 marked this conversation as resolved.
Outdated
|
||
| } | ||
| filterChain.doFilter(request, response); | ||
| } | ||
| } | ||
27 changes: 27 additions & 0 deletions
27
console/src/main/java/org/apache/seata/mcp/core/constant/SqlConstant.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.seata.mcp.core.constant; | ||
|
|
||
| public class SqlConstant { | ||
|
|
||
| public static final String GET_TABLE_NAME_SQL = | ||
| "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ? "; | ||
|
|
||
| public static final String GET_SCHEMA_SQL = | ||
| "SELECT COLUMN_NAME, DATA_TYPE, COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS " | ||
| + "WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?"; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.