Save current state before cleaning up duplicate MCP server files

This commit is contained in:
Ra
2025-09-03 00:01:02 -07:00
parent 37f76e060e
commit 074c4473ca
35 changed files with 2369 additions and 1187 deletions

View File

@@ -1,5 +1,6 @@
defmodule AgentCoordinator.DynamicToolDiscoveryTest do
use ExUnit.Case, async: false # Changed to false since we're using shared resources
# Changed to false since we're using shared resources
use ExUnit.Case, async: false
describe "Dynamic tool discovery" do
test "tools are discovered from external MCP servers via tools/list" do
@@ -9,23 +10,32 @@ defmodule AgentCoordinator.DynamicToolDiscoveryTest do
initial_tools = AgentCoordinator.MCPServerManager.get_unified_tools()
# Should have at least the coordinator native tools
coordinator_tool_names = ["register_agent", "create_task", "get_next_task", "complete_task", "get_task_board", "heartbeat"]
coordinator_tool_names = [
"register_agent",
"create_task",
"get_next_task",
"complete_task",
"get_task_board",
"heartbeat"
]
Enum.each(coordinator_tool_names, fn tool_name ->
assert Enum.any?(initial_tools, fn tool -> tool["name"] == tool_name end),
"Coordinator tool #{tool_name} should be available"
"Coordinator tool #{tool_name} should be available"
end)
# Verify VS Code tools are conditionally included
vscode_tools = Enum.filter(initial_tools, fn tool ->
String.starts_with?(tool["name"], "vscode_")
end)
vscode_tools =
Enum.filter(initial_tools, fn tool ->
String.starts_with?(tool["name"], "vscode_")
end)
# Should have VS Code tools if the module is available
if Code.ensure_loaded?(AgentCoordinator.VSCodeToolProvider) do
assert length(vscode_tools) > 0, "VS Code tools should be available when module is loaded"
else
assert length(vscode_tools) == 0, "VS Code tools should not be available when module is not loaded"
assert length(vscode_tools) == 0,
"VS Code tools should not be available when module is not loaded"
end
# Test tool refresh functionality
@@ -39,21 +49,23 @@ defmodule AgentCoordinator.DynamicToolDiscoveryTest do
# Use the shared MCP server manager
# Test routing for coordinator tools
result = AgentCoordinator.MCPServerManager.route_tool_call(
"register_agent",
%{"name" => "TestAgent", "capabilities" => ["testing"]},
%{agent_id: "test_#{:rand.uniform(1000)}"}
)
result =
AgentCoordinator.MCPServerManager.route_tool_call(
"register_agent",
%{"name" => "TestAgent", "capabilities" => ["testing"]},
%{agent_id: "test_#{:rand.uniform(1000)}"}
)
# Should succeed (returns :ok for register_agent)
assert result == :ok or (is_map(result) and not Map.has_key?(result, "error"))
# Test routing for non-existent tool
error_result = AgentCoordinator.MCPServerManager.route_tool_call(
"nonexistent_tool",
%{},
%{agent_id: "test"}
)
error_result =
AgentCoordinator.MCPServerManager.route_tool_call(
"nonexistent_tool",
%{},
%{agent_id: "test"}
)
assert error_result["error"]["code"] == -32601
assert String.contains?(error_result["error"]["message"], "Tool not found")
@@ -72,11 +84,20 @@ defmodule AgentCoordinator.DynamicToolDiscoveryTest do
assert tool_count >= 0
# Verify we have external tools (context7, filesystem, etc.)
external_tools = Enum.filter(tools, fn tool ->
name = tool["name"]
not String.starts_with?(name, "vscode_") and
name not in ["register_agent", "create_task", "get_next_task", "complete_task", "get_task_board", "heartbeat"]
end)
external_tools =
Enum.filter(tools, fn tool ->
name = tool["name"]
not String.starts_with?(name, "vscode_") and
name not in [
"register_agent",
"create_task",
"get_next_task",
"complete_task",
"get_task_board",
"heartbeat"
]
end)
# Should have some external tools from the configured MCP servers
assert length(external_tools) > 0, "Should have external MCP server tools available"
@@ -84,4 +105,4 @@ defmodule AgentCoordinator.DynamicToolDiscoveryTest do
# No cleanup needed - using shared instance
end
end
end
end