Global and Project level MCP Server + ability to toggle individual MCP tools#879
Open
TerminallyLazy wants to merge 2 commits intoagent0ai:developmentfrom
Open
Global and Project level MCP Server + ability to toggle individual MCP tools#879TerminallyLazy wants to merge 2 commits intoagent0ai:developmentfrom
TerminallyLazy wants to merge 2 commits intoagent0ai:developmentfrom
Conversation
- Updated SystemPrompt to include project-specific tool management. - Enhanced MCPConfig to support loading and saving project-specific disabled tools. - Added new functions in projects.py for managing MCP tools associated with projects. - Improved UI components for displaying and toggling tool status in project settings. - Refactored mcp-servers-store.js to handle tool toggling and state management more effectively.
- Updated McpServerGetDetail to support project-specific server details. - Removed ProjectMcpTools as its functionality is now integrated into the new project management system. - Improved MCPConfig to handle project-specific server loading and management. - Refactored UI components for better project-specific server configuration and tool management. - Enhanced projects-store.js to manage MCP server states and configurations effectively.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Problem
When working within a project context, Agent Zero was incorrectly reporting global MCP tools (even when toggled OFF at the project level) instead of the project-specific MCP tools that were actually configured and enabled.
The UI clearly states: "Configure MCP servers for this project. These are separate from global MCP servers." However, the backend was not honoring this separation.
Root Cause
The
MCPConfigclass inmcp_handler.pywas designed to merge global and project servers rather than treat them as separate:OLD (broken) behavior
This affected four critical methods:
get_tools_prompt()- Builds the MCP tools section for agent promptsget_server_detail()- Returns server informationhas_tool()- Checks tool availabilitycall_tool()- Executes MCP toolsSolution
Changed the logic to use exclusive project servers when a project context is active:
NEW (fixed) behavior
Behavior After Fix
Commits
Commit 1: 06e4c09 - Refactor MCP tool management and enhance project integration
project_nameparameter toget_tools_prompt()for project-aware prompt generationdisabled_toolsfield toMCPServerRemoteandMCPServerLocalmodelsload_project_mcp_tools()python/api/project_mcp_tools.pyfor API endpoint handlingproject-edit-mcp-tools.htmlfor project MCP configurationmcp-servers-store.jswith tool toggling and state managementCommit 2: caaaf39 - Enhance MCP server management and project integration
project_serversdict toMCPConfigfor storing project-specific server instancesload_project_servers()andunload_project_servers()methodsget_server_detail()to respect project isolationget_tools_prompt()to use ONLY project servers when project is activehas_tool()to check ONLY project servers when project is activecall_tool()to execute ONLY project server tools when project is activeMCPTool.execute()to pass project contextget_tool()to pass project context tohas_tool()has_serverscheck inget_mcp_tools_prompt()to properly detect project vs global availabilityProjectMcpToolsAPI (functionality integrated into new system)projects-store.jsfor better MCP server state managementFiles Changed
Backend
python/helpers/mcp_handler.pypython/extensions/system_prompt/_10_system_prompt.pyhas_serverscheck for project-aware detectionpython/helpers/projects.pyimport_global_mcp_server_to_project()python/api/project_mcp_servers.pypython/api/mcp_server_get_detail.pyproject_nameparameter supportpython/helpers/mcp_server.pyFrontend
webui/components/projects/project-edit-mcp-tools.htmlwebui/components/projects/projects-store.jswebui/components/settings/mcp/client/mcp-server-tools.htmlwebui/components/settings/mcp/client/mcp-servers-store.jsTesting
To verify the fix:
Additional Test Cases
Breaking Changes
None. This is a bugfix that aligns backend behavior with the documented UI design. Projects that were relying on the (incorrect) merge behavior will now see only their explicitly configured servers.
Related Issues
Fixes the issue where global MCP servers configured at the system level were incorrectly appearing in project contexts where they had been explicitly disabled or not imported.