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>
|
<artifactId>spring-ai-starter-mcp-server-webflux</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- <dependency>-->
|
<dependency>
|
||||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
<groupId>org.springframework.boot</groupId>
|
||||||
<!-- <artifactId>spring-boot-starter-jdbc</artifactId>-->
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
<!-- </dependency>-->
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<version>8.3.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|||||||
@ -2,15 +2,21 @@ package cn.louisxiv.mcp.dbconnect.tool;
|
|||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.ai.tool.annotation.Tool;
|
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;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class DbConnectTool {
|
public class DbConnectTool {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
@Tool(description = "获取表结构定义,参数是表名")
|
@Tool(description = "获取表结构定义,参数是表名")
|
||||||
public String getTableDefinition(String tableName) {
|
public String getTableDefinition(String tableName) {
|
||||||
log.info("get table definition: {}", 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