agent-zero/extensions/python/system_prompt/_12_mcp_prompt.py
Alessandro 521172b489
Some checks are pending
Build And Publish Docker Images / plan (push) Waiting to run
Build And Publish Docker Images / build (push) Blocked by required conditions
Revamp MCP server configuration
Add project-scoped MCP server configuration with global/project merge semantics, a richer settings UI, and chat composer access. Introduce MCP config scanning plus project-aware status/detail/log/apply APIs while preserving the raw JSON editor. Strengthen MCP runtime handling for dotted tool names, timeouts, status accuracy, and project-aware tool execution, with focused regression coverage.
2026-06-09 17:29:25 +02:00

33 lines
860 B
Python

from typing import Any
from helpers.extension import Extension, extensible
from helpers.mcp_handler import MCPConfig
from agent import Agent, LoopData
class MCPToolsPrompt(Extension):
async def execute(
self,
system_prompt: list[str] = [],
loop_data: LoopData = LoopData(),
**kwargs: Any,
):
if not self.agent:
return
prompt = await build_prompt(self.agent)
if prompt:
system_prompt.append(prompt)
@extensible
async def build_prompt(agent: Agent) -> str:
mcp_config = MCPConfig.get_for_agent(agent)
if not mcp_config.servers:
return ""
pre_progress = agent.context.log.progress
agent.context.log.set_progress("Collecting MCP tools")
tools = mcp_config.get_tools_prompt()
agent.context.log.set_progress(pre_progress)
return tools