feat: implement dynamic MCP tool discovery with shared server architecture

- Replace hardcoded tool lists with dynamic discovery via MCP tools/list
- Move MCPServerManager to application supervision tree for resource sharing
- Eliminate duplicate MCP server instances (one shared instance per server type)
- Add automatic tool refresh when servers restart
- Implement conditional VS Code tool loading based on module availability
- Add comprehensive test suite for dynamic discovery
- Update documentation with architecture improvements

Benefits:
- Full MCP protocol compliance
- Massive resource savings (shared servers vs per-agent instances)
- Zero maintenance overhead for tool list synchronization
- Automatic adaptation to server changes
- Improved reliability and performance

Closes: Dynamic tool discovery implementation
Fixes: Multiple MCP server instance resource waste
This commit is contained in:
Ra
2025-08-23 15:47:12 -07:00
parent 3416716f3f
commit 62319b87db
10 changed files with 584 additions and 82 deletions

View File

@@ -26,13 +26,7 @@ exec mix run --no-halt -e "
# Ensure all applications are started
{:ok, _} = Application.ensure_all_started(:agent_coordinator)
# Start services that are NOT in the application supervisor
# TaskRegistry is already started by the application supervisor, so we skip it
case AgentCoordinator.MCPServerManager.start_link([config_file: \"mcp_servers.json\"]) do
{:ok, _} -> :ok
{:error, {:already_started, _}} -> :ok
{:error, reason} -> raise \"Failed to start MCPServerManager: #{inspect(reason)}\"
end
# MCPServerManager is now started by the application supervisor automatically
case AgentCoordinator.UnifiedMCPServer.start_link() do
{:ok, _} -> :ok