Files
mcp-use__mcp-use/docs/python/api-reference/mcp_use_agents_adapters_base.mdx
pietrozullo ad42b4bb3e docs: noindex auto-generated Python API reference instead of searchable flag
The searchable: false approach on the API Reference tab was inert on
visible tabs. Switch to per-page noindex: true frontmatter, which keeps
pages in the sidebar but excludes them from search indexing (search
engines, internal docs search, and AI context) so generic queries like
"CLI" surface curated guides instead of the generated reference.

Applied to all 73 existing reference pages and emitted by the generator
on every regeneration.

Closes MCP-2398
2026-06-29 10:23:42 +02:00

242 lines
6.4 KiB
Plaintext

---
title: "Base"
description: "Base adapter interface for MCP tools API Documentation"
icon: "code"
github: "https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/agents/adapters/base.py"
noindex: true
---
import {RandomGradientBackground} from "/snippets/gradient.jsx"
<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</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
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
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
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
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
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
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
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
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
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
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
def parse_result(tool_result: Any):
```
</Card>
</div>