BaseAgent (agents/base.py)

mcp-use · libraries/python/mcp_use/agents/base.py · python · MIT
ai, tag:knn-classified

Abstract base class for MCP agents, defining init, run, and step methods.

# Source: https://github.com/mcp-use/mcp-use | License: MIT | Copyright 2025 pietrozullo
# Provided via justclaw.it.com; keep this notice with the code.
"""
Base agent interface for MCP tools.

This module provides a base class for agents that use MCP tools.
"""

from abc import ABC, abstractmethod
from typing import Any

from mcp_use.client.session import MCPSession


class BaseAgent(ABC):
    """Base class for agents that use MCP tools.

    This abstract class defines the interface for agents that use MCP tools.
    Agents are responsible for integrating LLMs with MCP tools.
    """

    def __init__(self, session: MCPSession):
        """Initialize a new agent.

        Args:
            session: The MCP session to use for tool calls.
        """
        self.session = session

    @ab

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key