Skip to main content

build_system_prompt_content

function build_system_prompt_content

Builds the final system prompt string using a template, tool descriptions, and optional additional instructions.
from mcp_use.agents.prompts.system_prompt_builder import build_system_prompt_content
Parameters
template
str
required
The system prompt template string (must contain '').
tool_description_lines
list[str]
required
A list of formatted tool description strings.
additional_instructions
str | None
default:"None"
Optional extra instructions to append.
Returns
returns
str
The fully formatted system prompt content string.
Signature
def build_system_prompt_content(
template: str,
    tool_description_lines: list[str],
    additional_instructions: str | None = None
):

create_system_message

function create_system_message

Creates the final SystemMessage object for the agent.Handles selecting the correct template, generating tool descriptions, and incorporating user overrides and additional instructions.
from mcp_use.agents.prompts.system_prompt_builder import create_system_message
Parameters
tools
list[langchain_core.tools.base.BaseTool]
required
List of available tools.
system_prompt_template
str
required
The default system prompt template.
server_manager_template
str
required
The template to use when server manager is active.
use_server_manager
bool
required
Flag indicating if server manager mode is enabled.
disallowed_tools
list[str] | None
default:"None"
List of tool names to exclude.
user_provided_prompt
str | None
default:"None"
A complete system prompt provided by the user, overriding templates.
additional_instructions
str | None
default:"None"
Extra instructions to append to the template-based prompt.
Returns
returns
langchain_core.messages.system.SystemMessage
A SystemMessage object containing the final prompt content.
Signature
def create_system_message(
tools: list[langchain_core.tools.base.BaseTool],
    system_prompt_template: str,
    server_manager_template: str,
    use_server_manager: bool,
    disallowed_tools: list[str] | None = None,
    user_provided_prompt: str | None = None,
    additional_instructions: str | None = None
):

generate_tool_descriptions

function generate_tool_descriptions

Generates a list of formatted tool descriptions, excluding disallowed tools.
from mcp_use.agents.prompts.system_prompt_builder import generate_tool_descriptions
Parameters
tools
list[langchain_core.tools.base.BaseTool]
required
The list of available BaseTool objects.
disallowed_tools
list[str] | None
default:"None"
A list of tool names to exclude.
Returns
returns
list[str]
A list of strings, each describing a tool in the format ”- tool_name: description”.
Signature
def generate_tool_descriptions(
tools: list[langchain_core.tools.base.BaseTool],
    disallowed_tools: list[str] | None = None
):
I