The MCP (Model Context Protocol), developed by Anthropic, is an open protocol that standardizes how applications provide context to LLMs.

MCP Tool

MCPTool allows you to consume external tools exposed via MCP protocol. See the MCP tool documentation for more information.

MCP Server

MCPServer allows you to expose your tools to external systems that support the Model Context Protocol (MCP) standard, enabling seamless integration with LLM tools ecosystems. Key benefits
  • Fast setup with minimal configuration
  • Support for multiple transport options
  • Register multiple tools on a single server
  • Custom server settings and instructions
from mcp.server.fastmcp.server import Settings

from beeai_framework.adapters.mcp.serve.server import MCPServer, MCPServerConfig
from beeai_framework.tools import tool
from beeai_framework.tools.types import StringToolOutput
from beeai_framework.tools.weather.openmeteo import OpenMeteoTool


@tool
def reverse_tool(word: str) -> StringToolOutput:
    """
    A tool that reverses a word
    """
    return StringToolOutput(result=word[::-1])


def main() -> None:
    # create a MCP server with custom config, register ReverseTool and OpenMeteoTool to the MCP server and run it
    MCPServer(config=MCPServerConfig(transport="sse", settings=Settings(port=8001))).register_many(
        [reverse_tool, OpenMeteoTool()]
    ).serve()


if __name__ == "__main__":
    main()

The MCP adapter uses the MCPServerConfig class to configure the MCP server:
class MCPServerConfig(BaseModel):
"""Configuration for the MCPServer."""
transport: Literal["stdio", "sse"] = "stdio"  # Transport protocol (stdio or server-sent events)
name: str = "MCP Server"                     # Name of the MCP server
instructions: str | None = None              # Optional instructions for the server
settings: mcp_server.Settings[Any] = Field(default_factory=lambda: mcp_server.Settings())
Transport Options
  • stdio: Uses standard input/output for communication (default)
  • sse: Uses server-sent events over HTTP
Creating an MCP server is easy. You instantiate the MCPServer class with your configuration, register your tools, and then call serve() to start the server:
from beeai_framework.adapters.mcp import MCPServer, MCPServerConfig
from beeai_framework.tools.weather import OpenMeteoTool

# Create an MCP server with default configuration
server = MCPServer()

# Register tools
server.register(OpenMeteoTool())

# Start serving
server.serve()
You can configure the server behavior by passing a custom configuration:
from beeai_framework.adapters.mcp import MCPServer
from beeai_framework.tools.weather import OpenMeteoTool
from beeai_framework.tools.search.wikipedia import WikipediaTool
from beeai_framework.tools.search.duckduckgo import DuckDuckGoSearchTool

def main():
server = MCPServer()
server.register_many([
OpenMeteoTool(),
WikipediaTool(),
DuckDuckGoSearchTool()
])
server.serve()

if __name__ == "__main__":
main()
MCPTool lets you add MCP-compatible tools to any agent, see Tools documentation to learn more.