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

# Base

> Base adapter interface for MCP tools 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/adapters/base.py" target="_blank" rel="noopener noreferrer">[https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp\_use/agents/adapters/base.py](https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/agents/adapters/base.py)</a>
</Callout>

Base adapter interface for MCP tools.

This module provides the abstract base class that all MCP tool adapters should inherit from.

## BaseAdapter

<div>
  <RandomGradientBackground className="rounded-lg p-4 w-full h-full rounded-full">
    <div className="text-black">
      <div className="text-black font-bold text-xl mb-2 mt-8"><code className="!text-black">class</code> BaseAdapter</div>

      Abstract base class for converting MCP tools to other framework formats.

      This class defines the common interface that all adapter implementations
      should follow to ensure consistency across different frameworks.
    </div>
  </RandomGradientBackground>

  ```python theme={null}
  from mcp_use.agents.adapters.base import BaseAdapter
  ```

  <Card type="info">
    **Attributes**

    >

    <ParamField body="framework" type="str" required="True">   String value </ParamField>
  </Card>

  <Card type="info">
    ### `method` **init**

    Initialize a new adapter.

    **Parameters**

    > <ParamField body="disallowed_tools" type="list[str] | None" default="None">   list of tool names that should not be available. </ParamField>

    **Signature**

    ```python wrap theme={null}
    def __init__(disallowed_tools: list[str] | None = None):
    ```
  </Card>

  <Card type="info">
    ### `method` create\_all

    Create tools, resources, and prompts from an MCPClient instance.

    **Parameters**

    > <ParamField body="client" type="mcp_use.client.client.MCPClient" required="True">   MCP client instance </ParamField>

    **Signature**

    ```python wrap theme={null}
    def create_all(client: mcp_use.client.client.MCPClient):
    ```
  </Card>

  <Card type="info">
    ### `method` create\_prompts

    Create prompts from the MCPClient instance.

    This handles session creation and connector extraction automatically.
    The created prompts are stored in `self.prompts`.

    **Parameters**

    > <ParamField body="client" type="mcp_use.client.client.MCPClient" required="True">   MCP client instance </ParamField>

    **Returns**

    > <ResponseField name="returns" type="list[mcp_use.agents.adapters.base.T]">A list of prompts in the target framework's format.</ResponseField>

    **Signature**

    ```python wrap theme={null}
    def create_prompts(client: mcp_use.client.client.MCPClient):
    ```
  </Card>

  <Card type="info">
    ### `method` create\_resources

    Create resources from the MCPClient instance.

    This handles session creation and connector extraction automatically.
    The created resources are stored in `self.resources`.

    **Parameters**

    > <ParamField body="client" type="mcp_use.client.client.MCPClient" required="True">   MCP client instance </ParamField>

    **Returns**

    > <ResponseField name="returns" type="list[mcp_use.agents.adapters.base.T]">A list of resources in the target framework's format.</ResponseField>

    **Signature**

    ```python wrap theme={null}
    def create_resources(client: mcp_use.client.client.MCPClient):
    ```
  </Card>

  <Card type="info">
    ### `method` create\_tools

    Create tools from the MCPClient instance.

    This handles session creation and connector extraction automatically.
    The created tools are stored in `self.tools`.

    **Parameters**

    > <ParamField body="client" type="mcp_use.client.client.MCPClient" required="True">   MCP client instance </ParamField>

    **Returns**

    > <ResponseField name="returns" type="list[mcp_use.agents.adapters.base.T]">A list of tools in the target framework's format.</ResponseField>

    **Signature**

    ```python wrap theme={null}
    def create_tools(client: mcp_use.client.client.MCPClient):
    ```
  </Card>

  <Card type="info">
    ### `method` fix\_schema

    Convert JSON Schema 'type': \['string', 'null'] to 'anyOf' format and fix enum handling.

    **Parameters**

    > <ParamField body="schema" type="Any" required="True">   The JSON schema to fix. </ParamField>

    **Returns**

    > <ResponseField name="returns" type="Any">The fixed JSON schema.</ResponseField>

    **Signature**

    ```python wrap theme={null}
    def fix_schema(schema: Any):
    ```
  </Card>

  <Card type="info">
    ### `method` load\_prompts\_for\_connector

    Dynamically load prompts for a specific connector.

    **Parameters**

    > <ParamField body="connector" type="mcp_use.client.connectors.base.BaseConnector" required="True">   The connector to load prompts for. </ParamField>

    **Returns**

    > <ResponseField name="returns" type="list[mcp_use.agents.adapters.base.T]">The list of prompts that were loaded in the target framework's format.</ResponseField>

    **Signature**

    ```python wrap theme={null}
    def load_prompts_for_connector(connector: mcp_use.client.connectors.base.BaseConnector):
    ```
  </Card>

  <Card type="info">
    ### `method` load\_resources\_for\_connector

    Dynamically load resources for a specific connector.

    **Parameters**

    > <ParamField body="connector" type="mcp_use.client.connectors.base.BaseConnector" required="True">   The connector to load resources for. </ParamField>

    **Signature**

    ```python wrap theme={null}
    def load_resources_for_connector(connector: mcp_use.client.connectors.base.BaseConnector):
    ```
  </Card>

  <Card type="info">
    ### `method` load\_tools\_for\_connector

    Dynamically load tools for a specific connector.

    **Parameters**

    > <ParamField body="connector" type="mcp_use.client.connectors.base.BaseConnector" required="True">   The connector to load tools for. </ParamField>

    **Returns**

    > <ResponseField name="returns" type="list[mcp_use.agents.adapters.base.T]">The list of tools that were loaded in the target framework's format.</ResponseField>

    **Signature**

    ```python wrap theme={null}
    def load_tools_for_connector(connector: mcp_use.client.connectors.base.BaseConnector):
    ```
  </Card>

  <Card type="info">
    ### `method` parse\_result

    Parse the result from any MCP operation (tool, resource, or prompt) into a string.

    **Parameters**

    > <ParamField body="tool_result" type="Any" required="True">   The result object from an MCP operation. </ParamField>

    **Returns**

    > <ResponseField name="returns" type="str">A string representation of the result content.</ResponseField>

    **Signature**

    ```python wrap theme={null}
    def parse_result(tool_result: Any):
    ```
  </Card>
</div>
