Files
linuztx 5918463f0e Add MCP server instructions to the agent system prompt
MCP servers can return usage instructions in their initialize result,
such as which tool to call first or what an argument means. Agent Zero
discarded them. Capture them when a server connects and add them to the
MCP part of the system prompt, the way reference clients do.

- Capture InitializeResult.instructions on the update_tools (re)connect
  path and cache them with the tools. A failed reconnect clears them, and
  tool calls never change them.
- Render one "MCP Server Instructions" section after the MCP tools, with
  a part for each server that offers at least one allowed tool. The
  framing tells the model that the instructions are context, not
  capabilities, and that tool names in them are the server's own.
- Contain each server's text. Cap it at 4096 characters, demote its
  headings (including --- and === underlined ones) below its part, close
  open code fences, drop control characters and neutralize template
  syntax.
- Build the section inside get_tools_prompt. The Responses transport
  rebuilds the MCP section from that method, so it keeps the section.
- Report has_instructions in the server status API, mark such servers in
  the server list, and show the text in the server detail modal. Pass
  the instructions to the MCP scanner's AI review.
- Document the behavior, note it in the agent's self-knowledge, and add
  tests.
2026-11-26 04:33:05 +00:00
..