Skip to content

feature: implement business data source query MCP tool on the console module#8032

Open
Xb2555 wants to merge 47 commits into
apache:2.xfrom
Xb2555:feat-dataSource
Open

feature: implement business data source query MCP tool on the console module#8032
Xb2555 wants to merge 47 commits into
apache:2.xfrom
Xb2555:feat-dataSource

Conversation

@Xb2555
Copy link
Copy Markdown
Contributor

@Xb2555 Xb2555 commented Mar 30, 2026

Ⅰ. Describe what this PR did

  1. Implemented the creation of DataSource instances for three types of connection pools
  2. The MCP tool that enables natural language queries
  3. Achieved the function of dynamically configuring by including business data source configuration parameters in the request headers during connection.

Ⅱ. 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

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.01%. Comparing base (a741d4b) to head (69a9aa4).
⚠️ Report is 1 commits behind head on 2.x.

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #8032      +/-   ##
============================================
+ Coverage     72.79%   73.01%   +0.22%     
  Complexity      883      883              
============================================
  Files          1327     1327              
  Lines         50719    50719              
  Branches       6049     6049              
============================================
+ Hits          36919    37034     +115     
+ Misses        10803    10686     -117     
- Partials       2997     2999       +2     
Files with missing lines Coverage Δ
...n/java/org/apache/seata/core/constants/DBType.java 100.00% <ø> (ø)

... and 12 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 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/ containing BusinessDataSourcesProperties, DataSourceFactory, {Druid,Hikari,Dbcp}DataSourceProvider, AbstractMCPDataSourceProvider, SqlExecutionTemplate, BusinessDataSourceService(Impl), and BusinessDataSourceTools.
  • New MCPBusinessDataSourceFilter registered in WebSecurityConfig to translate the X-DB-Config header into runtime data-source registrations.
  • Build/runtime wiring: pool dependencies added to console/pom.xml, MySQL 8 driver added to namingserver/pom.xml, and example seata.businessDataSources + seata.mcp blocks added to namingserver/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.

Comment thread console/src/main/java/org/apache/seata/console/config/WebSecurityConfig.java Outdated
Comment thread console/src/main/java/org/apache/seata/mcp/store/SqlExecutionTemplate.java Outdated
Comment thread namingserver/src/main/resources/application.yml Outdated
Comment thread console/src/main/java/org/apache/seata/mcp/tools/BusinessDataSourceTools.java Outdated
Comment thread namingserver/pom.xml
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.

3 participants