-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(mcp): support read config from database (MySQL, etc.) #2368
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: main
Are you sure you want to change the base?
Conversation
…/src/main/java/com/alibaba/cloud/ai/autoconfigure/mcp/router/FileMcpRouterAutoConfiguration.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
...uter/src/main/java/com/alibaba/cloud/ai/mcp/router/core/discovery/DbMcpServiceDiscovery.java
Show resolved
Hide resolved
...rc/main/java/com/alibaba/cloud/ai/autoconfigure/mcp/router/DbMcpRouterAutoConfiguration.java
Outdated
Show resolved
Hide resolved
...rc/main/java/com/alibaba/cloud/ai/autoconfigure/mcp/router/DbMcpRouterAutoConfiguration.java
Outdated
Show resolved
Hide resolved
.../main/java/com/alibaba/cloud/ai/autoconfigure/mcp/router/FileMcpRouterAutoConfiguration.java
Outdated
Show resolved
Hide resolved
另外记得,每一个文件都末尾记得留一个空白行 |
...n/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
Outdated
Show resolved
Hide resolved
...rc/main/java/com/alibaba/cloud/ai/autoconfigure/mcp/router/DbMcpRouterAutoConfiguration.java
Outdated
Show resolved
Hide resolved
hi. fix ci pls |
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 database support for MCP (Model Context Protocol) service configuration, allowing services to be read from databases like MySQL instead of being limited to file-based configuration.
- Introduces database-based service discovery via
DbMcpServiceDiscovery
with configurable SQL queries - Adds file-based service discovery as an alternative to the existing Nacos-based approach
- Implements auto-configuration classes to support multiple discovery types (nacos, file, database)
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
DbMcpServiceDiscovery.java | New service discovery implementation that queries database for MCP service configurations |
FileConfigMcpServiceDiscovery.java | New file-based service discovery implementation for local configuration |
DbMcpProperties.java | Configuration properties for database connection and query settings |
McpRouterProperties.java | Enhanced to support multiple discovery types and service configurations |
pom.xml | Added HikariCP dependency for database connection pooling |
FileMcpRouterAutoConfiguration.java | Auto-configuration for file-based service discovery |
DbMcpRouterAutoConfiguration.java | Auto-configuration for database-based service discovery |
org.springframework.boot.autoconfigure.AutoConfiguration.imports | Registered new auto-configuration classes |
DashScopeMultiModalChatTests.java | Updated comment to reference correct environment variable name |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Describe what this PR does / why we need it
This PR read config of MCP services from a database(MySQL, etc.).
Used in the module spring-ai-alibaba-mcp-router currently.
Does this pull request fix one issue?
Describe how you did it
在配置类DbMcpProperties中配置数据库信息,通过类DbMcpServiceDiscovery从数据库获取MCP服务信息(SQL查询)。
Describe how to verify it
example仓库:spring-ai-alibaba-mcp-example/spring-ai-alibaba-mcp-config-example(示例程序已提交PR,可能尚未合并)给出了测试方法。简单来说,配置连接信息,在数据库中创建示例数据;运行测试程序、发送HTTP GET请求即可查询到服务信息。
Special notes for reviews