> ## Documentation Index
> Fetch the complete documentation index at: https://mcp-use.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://mcp-use.com/docs/feedback

```json
{
  "path": "/python/api-reference/mcp_use_agents_prompts_system_prompt_builder",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# System Prompt Builder

> System Prompt Builder API Documentation

export const RandomGradientBackground = ({className, color, children, grayscaled = false}) => {
  const saturation = useMemo(() => {
    if (color) {
      const values = color.split("(")[1].split(")")[0].trim().split(/\s+/);
      return parseFloat(values[1] || "0");
    }
    return grayscaled ? 0 : 0.2;
  }, [color, grayscaled]);
  const lightness = useMemo(() => {
    if (color) {
      const values = color.split("(")[1].split(")")[0].trim().split(/\s+/);
      return parseFloat(values[0] || "0.5");
    }
    return grayscaled ? 0.3 : 0.4;
  }, [color, grayscaled]);
  const randomHue = useMemo(() => {
    if (color) {
      const values = color.split("(")[1].split(")")[0].trim().split(/\s+/);
      return parseFloat(values[2] || "0");
    }
    return Math.floor(Math.random() * 360);
  }, [color]);
  const randomColor = useMemo(() => {
    if (color) {
      return color;
    }
    return `oklch(${Math.min(lightness, 1)} ${saturation} ${randomHue})`;
  }, [randomHue, saturation, lightness]);
  const lightColor = useMemo(() => {
    return `oklch(${Math.min(lightness * 2, 1)} ${saturation} ${randomHue})`;
  }, [randomHue, saturation, lightness, color]);
  const direction = useMemo(() => {
    return Math.floor(Math.random() * 360);
  }, [randomHue]);
  const brightnessFilter = useMemo(() => {
    return "1000%";
  }, []);
  return <div className={`relative overflow-hidden ${className || ""}`} style={{
    background: `${lightColor}`,
    minHeight: '100%',
    width: '100%'
  }}>
      <div className="absolute inset-0 w-full h-full" style={{
    background: `linear-gradient(${direction}deg, ${randomColor}, transparent), url(https://grainy-gradients.vercel.app/noise.svg)`,
    filter: `contrast(120%) brightness(${brightnessFilter})`,
    backgroundSize: 'cover',
    backgroundRepeat: 'no-repeat'
  }} />
      {children && <div className="relative z-10 w-full h-full">{children}</div>}
    </div>;
};

<Callout type="info" title="Source Code">
  View the source code for this module on GitHub: <a href="https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/agents/prompts/system_prompt_builder.py" target="_blank" rel="noopener noreferrer">[https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp\_use/agents/prompts/system\_prompt\_builder.py](https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/agents/prompts/system_prompt_builder.py)</a>
</Callout>

## build\_system\_prompt\_content

<Card type="info">
  ### `function` build\_system\_prompt\_content

  Builds the final system prompt string using a template, tool descriptions,
  and optional additional instructions.

  ```python theme={null}
  from mcp_use.agents.prompts.system_prompt_builder import build_system_prompt_content
  ```

  **Parameters**

  > <ParamField body="template" type="str" required="True">   The system prompt template string (must contain '{tool_descriptions}'). </ParamField>
  > <ParamField body="tool_description_lines" type="list[str]" required="True">   A list of formatted tool description strings. </ParamField>
  > <ParamField body="additional_instructions" type="str | None" default="None">   Optional extra instructions to append. </ParamField>

  **Returns**

  > <ResponseField name="returns" type="str">The fully formatted system prompt content string.</ResponseField>

  **Signature**

  ```python wrap theme={null}
  def build_system_prompt_content(
  template: str,
      tool_description_lines: list[str],
      additional_instructions: str | None = None
  ):
  ```
</Card>

## create\_system\_message

<Card type="info">
  ### `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.

  ```python theme={null}
  from mcp_use.agents.prompts.system_prompt_builder import create_system_message
  ```

  **Parameters**

  > <ParamField body="tools" type="list[langchain_core.tools.base.BaseTool]" required="True">   List of available tools. </ParamField>
  > <ParamField body="system_prompt_template" type="str" required="True">   The default system prompt template. </ParamField>
  > <ParamField body="server_manager_template" type="str" required="True">   The template to use when server manager is active. </ParamField>
  > <ParamField body="use_server_manager" type="bool" required="True">   Flag indicating if server manager mode is enabled. </ParamField>
  > <ParamField body="disallowed_tools" type="list[str] | None" default="None">   List of tool names to exclude. </ParamField>
  > <ParamField body="user_provided_prompt" type="str | None" default="None">   A complete system prompt provided by the user, overriding templates. </ParamField>
  > <ParamField body="additional_instructions" type="str | None" default="None">   Extra instructions to append to the template-based prompt. </ParamField>

  **Returns**

  > <ResponseField name="returns" type="langchain_core.messages.system.SystemMessage">A SystemMessage object containing the final prompt content.</ResponseField>

  **Signature**

  ```python wrap theme={null}
  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
  ):
  ```
</Card>

## generate\_tool\_descriptions

<Card type="info">
  ### `function` generate\_tool\_descriptions

  Generates a list of formatted tool descriptions, excluding disallowed tools.

  ```python theme={null}
  from mcp_use.agents.prompts.system_prompt_builder import generate_tool_descriptions
  ```

  **Parameters**

  > <ParamField body="tools" type="list[langchain_core.tools.base.BaseTool]" required="True">   The list of available BaseTool objects. </ParamField>
  > <ParamField body="disallowed_tools" type="list[str] | None" default="None">   A list of tool names to exclude. </ParamField>

  **Returns**

  > <ResponseField name="returns" type="list[str]">A list of strings, each describing a tool in the format "- tool\_name: description".</ResponseField>

  **Signature**

  ```python wrap theme={null}
  def generate_tool_descriptions(
  tools: list[langchain_core.tools.base.BaseTool],
      disallowed_tools: list[str] | None = None
  ):
  ```
</Card>
