Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
@SpringBootApplication
@EnableAspectJAutoProxy
@MapperScan({"com.tinyengine.it.mapper","com.tinyengine.it.dynamic.dao"})
@MapperScan({"com.tinyengine.it.mapper","com.tinyengine.it.dynamic.dao","com.tinyengine.it.mcp"})
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 高风险: pom.xml 引入 spring-ai-starter-mcp-server-webmvc:1.1.4,但项目父 POM 仍是 Spring Boot 3.1.9,这是官方未支持的版本组合,存在直接编译/启动失败风险。
    文件: pom.xml(新增 spring-ai.version 和 MCP starter 的 hunk)
    影响: Spring AI 1.1.x 官方文档写明支持的是 Spring Boot 3.4.x3.5.x。当前 PR 没有同步升级 Boot,也没有引入 Spring AI BOM 做版本对齐,部署时很可能在依赖解析、自动配置或运行期出现不兼容。
    依据: https://docs.spring.io/spring-ai/reference/getting-started.html

  2. 高风险: 导入流程实际上没有事务边界,失败后会留下部分已写入的数据。
    文件: base/src/main/java/com/tinyengine/it/mcp/tools/GitFileReaderService.java:58, :111, :321, :352
    影响: readFileFromRepo() 先更新/创建组件库,再在同类内部调用 parseBundle()bulkCreate()。后两者虽然标了 @Transactional,但属于 Spring 自调用,事务代理不会生效;入口方法本身也没有事务。只要中途某次 createComponent / createMaterialComponent / createMaterialHistoryComponent 失败,就会留下半导入状态,后续需要人工清库修复。

  3. 中风险: 新导入的组件被硬编码关联到 material_id=1material_history_id=1,会把任意 bundle 的结果写进默认物料记录。
    文件: base/src/main/java/com/tinyengine/it/mcp/tools/GitFileReaderService.java:386-396
    影响: 这会把工具的行为绑定到固定主键,既不跟随导入上下文,也不校验目标物料是否存在。只要环境里不是“永远只有默认物料 1”,就会产生错误关联,污染既有数据。

public class TinyEngineApplication {
/**
* The entry point of application.
Expand Down
17 changes: 16 additions & 1 deletion app/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,21 @@ spring:
min-evictable-idle-time-millis: 300000 # 连接在池中保持空闲的最小时间(单位:毫秒)。如果空闲时间超过这个值,连接将被回收,默认值为 1800000。
pool-prepared-statements: true # 是否缓存 PreparedStatement 对象,默认值为 true。
max-open-prepared-statements: 20 # 最大缓存的 PreparedStatement 数量,默认值为 -1,表示无限制。如果 `pool-prepared-statements` 设置为 true,设置此值以限制缓存数量。

ai:
mcp:
server:
enabled: true
protocol: STREAMABLE
version: 1.0.0
tool-change-notification: true
type: SYNC
annotation-scanner:
enabled: false
capabilities:
tool: true
streamable-http:
mcp-endpoint: /tiny-engine/mcp
name: tiny-engine-mcp
# 清空任务配置
cleanup:
enabled: false
Expand Down Expand Up @@ -110,3 +124,4 @@ ai:
- api.tiangong.cn
- localhost
- 127.0.0.1
- raw.githubusercontent.com
91 changes: 87 additions & 4 deletions app/src/main/resources/sql/h2/init_data_for_test_v1.0.0.sql

Large diffs are not rendered by default.

91 changes: 87 additions & 4 deletions app/src/main/resources/sql/mysql/init_data_for_test_v1.0.0.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.tinyengine.it.mcp.config;


import com.tinyengine.it.mcp.tools.GitFileReaderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.ai.tool.method.MethodToolCallbackProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
public class McpToolsConfig {
private static final Logger log = LoggerFactory.getLogger(McpToolsConfig.class);


/**
* 方式一:通过 ToolCallbackProvider 批量注册工具
*/
@Bean
@Primary
public ToolCallbackProvider toolCallbackProvider(GitFileReaderService gitFileReaderService) {


MethodToolCallbackProvider provider = MethodToolCallbackProvider.builder()
.toolObjects(gitFileReaderService)
.build();
// 立即验证
log.info("Tool count from provider: " + provider.getToolCallbacks().length);
return provider;
}
}
Loading
Loading