Feat/add server tool #9
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces a powerful new capability for the
MCPAgent: dynamic server management. The agent can now be equipped with a tool that allows it to add and connect to new MCP servers at runtime, based on the user's prompt. This significantly enhances the agent's autonomy and flexibility, as it can now dynamically expand its own toolset as required by the task at hand.The core of this change is the new
AddMCPServerTool, which is now provided and managed by theServerManager. When used, this tool:MCPClient.ServerManagerand sets the new server as the active one.The
ServerManagerhas been enhanced to be aware of the "active" server, and it now dynamically includes the active server's tools in the list it provides to the agent. This ensures that once a server is added, the agent immediately has access to its capabilities for the next step.Additionally, this PR includes several improvements:
logStatemethod was added to theServerManagerwhich, when the log level is set to 'debug', prints a detailed table of all configured servers, their connection status, tool count, and active status. This provides excellent visibility into the manager's state at each step of an agent's run.logger.warningtologger.warnand fixed an incorrect import path forzod.src/managers/tools/directory for better project structure.Type of change
Checklist