init
This commit is contained in:
parent
ec87ec934b
commit
06d1cb2ebe
14
pom.xml
14
pom.xml
@ -36,10 +36,16 @@
|
||||
<artifactId>spring-ai-starter-mcp-server-webflux</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-jdbc</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>8.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@ -2,15 +2,21 @@ package cn.louisxiv.mcp.dbconnect.tool;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.ai.tool.annotation.Tool;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DbConnectTool {
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Tool(description = "获取表结构定义,参数是表名")
|
||||
public String getTableDefinition(String tableName) {
|
||||
log.info("get table definition: {}", tableName);
|
||||
return "create " + tableName;
|
||||
String sql = "SHOW CREATE TABLE " + tableName;
|
||||
return jdbcTemplate.queryForObject(sql, (rs, rowNum) -> rs.getString("Create Table"));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user