MCP API Reference
This document provides a complete API reference for AG-Kit Python’s Model Context Protocol (MCP) integration components.Core Classes
AGKitMCPServer
Exposes AG-Kit tools as a standard MCP server.Constructor
config: dict- Server configuration dictionary
Methods
register_tool()
Register a single AG-Kit tool with the server.
tool: BaseTool- The AG-Kit tool to registerregistration: dict- Optional tool registration configuration
dict - Metadata for the registered tool
register_tools()
Register multiple AG-Kit tools with shared configuration.
tools: list[BaseTool]- List of AG-Kit tools to registerregistration: dict- Optional shared configuration
list[dict] - List of metadata for registered tools
unregister_tool()
Remove a tool from the server.
name: str- Name of the tool to remove
bool - True if tool was removed, False if not found
run()
Start the MCP server with specified transport.
transport_config: dict- Transport configuration
stop()
Stop the MCP server and cleanup resources.
call_tool()
Execute a registered tool directly.
name: str- Name of the tool to executeargs: dict- Tool arguments
dict - MCP-formatted tool result
list_tools()
Get list of all registered tools.
is_server_running()
Check if the server is currently running.
bool - True if server is running
get_stats()
Get server statistics and information.
get_server_info()
Get server information.
get_config()
Get current server configuration.
update_config()
Update server configuration.
get_connection_info()
Get connection information.
get_transport_type()
Get current transport type.
get_memory_id()
Get memory transport ID if using memory transport.
add_event_listener()
Add event listener for server events.
listener: Callable- Event listener function that takes an MCPEvent
remove_event_listener()
Remove event listener.
bool - True if listener was removed
MCPClientManager
Manages connections to external MCP servers.Constructor
Methods
add_server()
Add and connect to an MCP server.
server_id: str- Unique identifier for the serverconfig: dict- Client configurationconnection_options: dict- Optional connection settings
disconnect_server()
Disconnect from a specific server.
disconnect_all()
Disconnect from all servers.
create_client_tools()
Create AG-Kit tool wrappers for all available MCP tools.
server_id: str- Optional server ID to filter tools
list[MCPClientTool] - List of wrapped tools
create_client_tool()
Create a specific AG-Kit tool wrapper for an MCP tool.
server_id: str- Server ID containing the tooltool_name: str- Name of the MCP toolagkit_tool_name: str- Optional custom name for the AG-Kit tool
MCPClientTool - Wrapped tool instance
call_tool()
Call an MCP tool directly.
get_server_tools()
Get tool metadata from a specific server.
get_all_tools()
Get tool metadata from all servers.
is_server_connected()
Check if a server is connected.
get_connection_status()
Get connection status for all servers.
get_all_statuses()
Get detailed status for all servers.
get_stats()
Get client manager statistics.
add_event_listener()
Add event listener for client events.
remove_event_listener()
Remove event listener.
MCPClientTool
Wraps an external MCP tool to work within AG-Kit’s tool system.Constructor
mcp_client: Client- MCP client instancemcp_tool_metadata: dict- Tool metadata from MCP serverconfig: dict- Optional tool configurationadapter_config: dict- Optional adapter configuration
Methods
invoke()
Execute the MCP tool (inherited from BaseTool).
get_mcp_metadata()
Get the original MCP tool metadata.
is_connected()
Check if the underlying MCP client is connected.
update_config()
Update tool configuration.
update_adapter_config()
Update adapter configuration.
MCPToolkit
High-level toolkit for managing MCP tools from external servers.Constructor
name: str- Toolkit name (default: ‘mcp-toolkit’)description: str- Optional toolkit description
Properties
manager
Get the underlying MCPClientManager.
Methods
add_server()
Add an MCP server and load its tools.
remove_server()
Remove a server and its tools.
get_connected_servers()
Get list of connected server IDs.
get_server_tools()
Get tools from a specific server.
get_server_statuses()
Get connection status for all servers.
refresh_tools()
Refresh tools from a specific server or all servers.
destroy()
Cleanup all resources and disconnect from servers.
get_metadata()
Get toolkit metadata.
Utility Functions
pydantic_to_json_schema()
Convert a Pydantic model to MCP JSON schema format.
model: type[BaseModel]- Pydantic model class to convert
convert_agkit_tool_to_mcp_metadata()
Convert AG-Kit BaseTool to MCP tool metadata.
tool: BaseTool- AG-Kit tool instanceconfig: dict- Optional server configtool_config: dict- Optional tool-specific config
create_agkit_mcp_server()
Utility function to create and configure an MCP server.
create_mcp_toolkit()
Create a new MCP toolkit with pre-configured servers.
servers: list[dict]- List of server configurationsname: str- Optional toolkit name
Memory Transport Registry
MemoryTransportRegistry
Singleton registry for managing in-memory MCP transports.Methods
get_instance()
Get the singleton instance.
register_server()
Register an MCP server with memory transport.
unregister_server()
Unregister a server.
get_server()
Get a registered server.
create_transport_pair()
Create a linked pair of memory transports.
get_client_transport()
Get client transport for connections.
call_tool()
Direct tool call via memory transport.
list_tools()
List tools via memory transport.
Type Definitions
MCPEvent
Event class for MCP events.MCPEventType
Enumeration of MCP event types.ConnectionStatus
Enumeration of connection statuses.MCPServerConfig
Server configuration model.MCPClientConfig
Client configuration model.MCPToolMetadata
Tool metadata model.MCPToolConfig
Tool configuration model.MCPAdapterConfig
Adapter configuration model.MCPToolRegistration
Tool registration configuration model.Transport Configuration Models
MCPStdioTransportConfig
MCPSSETransportConfig
MCPStreamableHTTPTransportConfig
MCPMemoryTransportConfig
Error Handling
Exception Classes
Module Exports
Core Classes
Utility Functions
Memory Transport
Types and Models
Usage Patterns
Server Pattern
Client Pattern
Toolkit Pattern
This API reference provides complete documentation for all public interfaces and methods in AG-Kit Python’s MCP integration. For usage examples and implementation patterns, see the MCP Integration Guide and the example files in
python-sdk/examples/.