Skip to main content
Base adapter interface for MCP tools. This module provides the abstract base class that all MCP tool adapters should inherit from.

BaseAdapter

from mcp_use.agents.adapters.base import BaseAdapter

method init

Initialize a new adapter.Parameters
disallowed_tools
list[str] | None
default:"None"
list of tool names that should not be available.
Signature
def __init__(disallowed_tools: list[str] | None = None):

method create_all

Create tools, resources, and prompts from an MCPClient instance.Parameters
client
mcp_use.client.client.MCPClient
required
MCP client instance
Signature
def create_all(client: mcp_use.client.client.MCPClient):

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
client
mcp_use.client.client.MCPClient
required
MCP client instance
Returns
returns
list[mcp_use.agents.adapters.base.T]
A list of prompts in the target framework’s format.
Signature
def create_prompts(client: mcp_use.client.client.MCPClient):

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
client
mcp_use.client.client.MCPClient
required
MCP client instance
Returns
returns
list[mcp_use.agents.adapters.base.T]
A list of resources in the target framework’s format.
Signature
def create_resources(client: mcp_use.client.client.MCPClient):

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
client
mcp_use.client.client.MCPClient
required
MCP client instance
Returns
returns
list[mcp_use.agents.adapters.base.T]
A list of tools in the target framework’s format.
Signature
def create_tools(client: mcp_use.client.client.MCPClient):

method fix_schema

Convert JSON Schema ‘type’: [‘string’, ‘null’] to ‘anyOf’ format and fix enum handling.Parameters
schema
dict
required
The JSON schema to fix.
Returns
returns
dict
The fixed JSON schema.
Signature
def fix_schema(schema: dict):

method load_prompts_for_connector

Dynamically load prompts for a specific connector.Parameters
connector
mcp_use.client.connectors.base.BaseConnector
required
The connector to load prompts for.
Returns
returns
list[mcp_use.agents.adapters.base.T]
The list of prompts that were loaded in the target framework’s format.
Signature
def load_prompts_for_connector(connector: mcp_use.client.connectors.base.BaseConnector):

method load_resources_for_connector

Dynamically load resources for a specific connector.Parameters
connector
mcp_use.client.connectors.base.BaseConnector
required
The connector to load resources for.
Signature
def load_resources_for_connector(connector: mcp_use.client.connectors.base.BaseConnector):

method load_tools_for_connector

Dynamically load tools for a specific connector.Parameters
connector
mcp_use.client.connectors.base.BaseConnector
required
The connector to load tools for.
Returns
returns
list[mcp_use.agents.adapters.base.T]
The list of tools that were loaded in the target framework’s format.
Signature
def load_tools_for_connector(connector: mcp_use.client.connectors.base.BaseConnector):

method parse_result

Parse the result from any MCP operation (tool, resource, or prompt) into a string.Parameters
tool_result
Any
required
The result object from an MCP operation.
Returns
returns
str
A string representation of the result content.
Signature
def parse_result(tool_result: Any):