feature: implement business data source query MCP tool on the console module#8032
feature: implement business data source query MCP tool on the console module#8032Xb2555 wants to merge 48 commits into
Conversation
…e factory and requesting header data source configuration
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.x #8032 +/- ##
============================================
+ Coverage 72.92% 72.99% +0.06%
Complexity 883 883
============================================
Files 1327 1327
Lines 50769 50769
Branches 6058 6058
============================================
+ Hits 37025 37058 +33
+ Misses 10735 10705 -30
+ Partials 3009 3006 -3
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds a new business-data-source MCP tool to the console module so that natural-language MCP clients can list resource ids, list tables, inspect table schemas, and run read-only SQL against external business databases. Data sources can be defined statically under seata.businessDataSources in the namingserver application.yml, or registered dynamically per request via the X-DB-Config HTTP header. Three connection-pool implementations (Druid, HikariCP, DBCP) are provided. The runtime configuration and an explicit MySQL 8 driver dependency are wired into the namingserver app, which already depends on seata-console.
Changes:
- New MCP package under
console/.../mcp/containingBusinessDataSourcesProperties,DataSourceFactory,{Druid,Hikari,Dbcp}DataSourceProvider,AbstractMCPDataSourceProvider,SqlExecutionTemplate,BusinessDataSourceService(Impl), andBusinessDataSourceTools. - New
MCPBusinessDataSourceFilterregistered inWebSecurityConfigto translate theX-DB-Configheader into runtime data-source registrations. - Build/runtime wiring: pool dependencies added to
console/pom.xml, MySQL 8 driver added tonamingserver/pom.xml, and exampleseata.businessDataSources+seata.mcpblocks added tonamingserver/src/main/resources/application.yml.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| console/pom.xml | Adds Druid/DBCP/HikariCP pool dependencies. |
| namingserver/pom.xml | Adds explicit mysql-connector-java 8.0.27 dependency. |
| namingserver/src/main/resources/application.yml | Adds MCP and businessDataSources example config; relocates the misplaced mcp block. |
| common/.../core/constants/DBType.java | Reintroduces a comprehensive DBType enum used by validation queries. |
| console/.../console/config/WebSecurityConfig.java | Wires in the new MCPBusinessDataSourceFilter before the JWT filter. |
| console/.../console/filter/MCPBusinessDataSourceFilter.java | Per-request filter that registers data sources from X-DB-Config. |
| console/.../mcp/core/constant/SqlConstant.java | MySQL INFORMATION_SCHEMA queries for table/column metadata. |
| console/.../mcp/core/props/BusinessDataSourcesProperties.java | Static + dynamic data-source property store; YAML scanning + JSON registration. |
| console/.../mcp/service/BusinessDataSourceService(.java/Impl) | Service layer over SqlExecutionTemplate for table/schema/run-sql. |
| console/.../mcp/store/SqlExecutionTemplate.java | Read-only SELECT executor with naive WHERE/parameter checks. |
| console/.../mcp/store/DataSourceFactory.java | Static registry caching DataSources; chooses pool by config. |
| console/.../mcp/store/{Druid,Hikari,Dbcp}DataSourceProvider.java | Pool-specific DataSource builders. |
| console/.../mcp/store/db/AbstractMCPDataSourceProvider.java | Shared driver/classloader logic and property accessors. |
| console/.../mcp/tools/BusinessDataSourceTools.java | New @McpTool entry points: getResourceIds, getTableNames, getTableSchema, runSql. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <!-- for jdbc driver when package --> | ||
| <mysql5.version>${mysql.version}</mysql5.version> | ||
| <mysql8.version>8.0.27</mysql8.version> | ||
| <mysql8.version>8.0.33</mysql8.version> |
There was a problem hiding this comment.
Why upgrade to this version?
|
This PR has quite a bit of content. Has it already passed code review? When the release is planned? |
Ⅰ. Describe what this PR did
Ⅱ. 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