From de35fb6a2c076e851269b28e588f9d8288396cfc Mon Sep 17 00:00:00 2001 From: Quinlan Jager Date: Tue, 6 May 2025 11:40:28 -0700 Subject: [PATCH] Add MCP tool prompt support to system prompts - Add tool_prompt to CoderPrompts class - Modify fmt_system_prompt to include tool prompt when MCP tools are available - This enables better handling of tool-based interactions when using MCP servers --- aider/coders/base_coder.py | 3 +++ aider/coders/base_prompts.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 24f320bcd..ac1fc3485 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -1155,6 +1155,9 @@ class Coder: def fmt_system_prompt(self, prompt): final_reminders = [] + if self.mcp_tools and len(self.mcp_tools) > 0: + final_reminders.append(self.gpt_prompts.tool_prompt) + if self.main_model.lazy: final_reminders.append(self.gpt_prompts.lazy_prompt) if self.main_model.overeager: diff --git a/aider/coders/base_prompts.py b/aider/coders/base_prompts.py index 36f991f1e..b5b252a0b 100644 --- a/aider/coders/base_prompts.py +++ b/aider/coders/base_prompts.py @@ -56,5 +56,16 @@ Do not edit these files! no_shell_cmd_prompt = "" no_shell_cmd_reminder = "" + tool_prompt = """Answer the user's request using the relevant tool(s), if they are available. +Check that all the required parameters for each tool call are provided or can reasonably be +inferred from context. IF there are no relevant tools or there are missing values for required +parameters, ask the user to supply these values; otherwise proceed with the tool calls. If the +user provides a specific value for a parameter (for example provided in quotes), make sure to +use that value EXACTLY. +DO NOT make up values for or ask about optional parameters. Carefully analyze descriptive terms in +the request as they may indicate required parameter values that should be included even if not +explicitly quoted. +""" + rename_with_shell = "" go_ahead_tip = ""