agentscope-ai / agentscope-ai/agentscope-java

[Bug]:自定义mcpServer,如果ToolsConfig里没有allow mcpserver里的工具,mcpserver里的工具将不可用

Đang mở
#2,405 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
area/build area/docs area/harness bug
Ngôn ngữ chính
Java
Star
5.6k
Fork
1.3k
Merge trung bình
4 ngày 12 giờ
Pull request đã merge (30 ngày)
77

Mô tả

**Describe the bug**
注册自定义的mcpServer,里面的工具并没有像[文档](https://java.agentscope.io/v2/zh/docs/building-blocks/tool.html#mcp)描述的那样被重命名为mcp__{server_name}__{tool_name}。如果io.agentscope.harness.agent.tools.ToolsConfig里的allow没有包含mcpServer里的工具的名称,mcpServer里的工具将不可用

**To Reproduce**
Steps to reproduce the behavior:
```
static void main() {
ToolsConfig toolsConfig = new ToolsConfig();
toolsConfig.setAllow(List.of());
toolsConfig.setMcpServers(JsonUtil.fromJson("""
{"test":{
"transport":"streamable-http",
"url":"http://localhost:8089/query",
"enableTools":["getTime","listHoliday","getCourseOutline","searchCourseByName","searchEmp","queryDriver","queryMenu","getCourseDetail"]
}}
""", new TypeReference>() {
}));
t(toolsConfig);

toolsConfig.setAllow(List.of("list_files"));
t(toolsConfig);

toolsConfig.setAllow(List.of("list_files", "searchCourseByName"));
t(toolsConfig);
}

private static void t(ToolsConfig toolsConfig) {
HarnessAgent agent =
HarnessAgent.builder()
.name("HttpMcpAgent")
.sysPrompt("You are a helpful assistant with access to tools via MCP over HTTP.")
.model(DashScopeChatModel.builder()
.apiKey("kkk")
.modelName("qwen-max")
.stream(true)
.build())
.toolsConfig(toolsConfig)
.build();
System.out.println(agent.getToolkit().getToolNames());
}
```
输出:[agent_send, getTime, memory_search, queryDriver, queryMenu, task_cancel, grep_files, memory_get, edit_file, write_file, getCourseOutline, agent_list, task_list, read_file, session_search, list_files, getCourseDetail, searchCourseByName, task_output, memory_save, glob_files, agent_spawn, execute, wait_async_results, session_list, listHoliday, searchEmp, session_history]
[list_files]
[list_files, searchCourseByName]

**Expected behavior**
按照文档所述对工具重命名,且该mcpServer允许的工具列表按io.agentscope.harness.agent.tools.McpServerConfig#enableTools的配置来

**Environment (please complete the following information):**
- AgentScope-Java Version: 2.0
- Java Version: 25
- OS: windows

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.