Skip to content

MAOTO - MCP Server

__all__ = ['MCPServer'] module-attribute

MCPServer(app, settings=None)

Initialize the MCP server with the given FastAPI app.

Parameters:

Name Type Description Default
app FastAPI

The FastAPI application to mount the MCP server to

required
settings MCPSettings

MCP-specific settings. If not provided, will use default settings.

None
Source code in maoto_agent/mcp/server.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def __init__(self, app: FastAPI, settings: MCPSettings | None = None):
    """
    Initialize the MCP server with the given FastAPI app.

    Parameters
    ----------
    app : FastAPI
        The FastAPI application to mount the MCP server to
    settings : MCPSettings, optional
        MCP-specific settings. If not provided, will use default settings.
    """
    self._settings = settings or MCPSettings()

    self._server = add_mcp_server(
        app,
        mount_path=self._settings.mcp_mount_path,
        name=self._settings.mcp_name,
        description=self._settings.mcp_description,
        base_url=self._settings.url_mp,  # Inherited from AgentSettings
        describe_all_responses=self._settings.mcp_describe_all_responses,
        describe_full_response_schema=self._settings.mcp_describe_full_response_schema,
    )

server property

Get the underlying MCP server instance.

settings property

Get the MCP settings instance.

add_tool(func)

Add a custom tool to the MCP server.

Parameters:

Name Type Description Default
func callable

The function to add as a tool

required
Source code in maoto_agent/mcp/server.py
31
32
33
34
35
36
37
38
39
40
def add_tool(self, func):
    """
    Add a custom tool to the MCP server.

    Parameters
    ----------
    func : callable
        The function to add as a tool
    """
    return self._server.tool()(func)