Skip to Content
ReferencesArcade MCPPythonServer

Server

Most should use MCPApp instead of MCPServer directly. MCPServer is a low-level API for advanced use cases.

The MCPServer class is the core server implementation that handles protocol messages, middleware orchestration, and component management for , resources, and prompts.

MCPServer

arcade_mcp_server.server.MCPServer

Server with middleware and support.

This server provides:

  • Middleware chain for extensible request processing
  • injection for
  • Component managers for , resources, and prompts
  • Bidirectional communication with clients
  • Authorization and secret management for execution

__init__

Python
MCPServer( catalog, *, name=None, version=None, title=None, instructions=None, settings=None, middleware=None, lifespan=None, auth_disabled=False, arcade_api_key=None, arcade_api_url=None, )

Initialize the server.

Parameters:

NameTypeDescriptionDefault
catalogToolCatalogTool catalog containing tools to serverequired
namestr | NoneServer name. Falls back to the value in settings.server.name if not provided.None
versionstr | NoneServer version. Falls back to the value in settings.server.version if not provided.None
titlestr | NoneServer title for display. Falls back to settings, then to name.None
instructionsstr | NoneServer instructions sent to clients during initializationNone
settingsMCPSettings | NoneMCP settings. Loaded from environment if not provided.None
middlewarelist[Middleware] | NoneCustom middleware to add to the chain (appended after built-in middleware)None
lifespanCallable | NoneLifespan manager function for startup/shutdown hooksNone
auth_disabledboolDisable authenticationFalse
arcade_api_keystr | NoneArcade API key. Overrides settings and credentials file.None
arcade_api_urlstr | NoneArcade API URL. Overrides settings.None

The server automatically adds ErrorHandlingMiddleware and (if enabled in settings) LoggingMiddleware to the middleware chain. Custom middleware is appended after these built-in middleware.

Properties

tools

Access the ToolManager for runtime operations: add_tool(), update_tool(), remove_tool(), list_tools(), get_tool().

resources

Access the ResourceManager for runtime resource operations: add_resource(), remove_resource(), list_resources(), read_resource().

prompts

Access the PromptManager for runtime prompt operations: add_prompt(), remove_prompt(), list_prompts(), get_prompt().

Methods

start

Python
async server.start()

Start the server and all component managers. Loads from the initial catalog, starts the lifespan manager, and checks for missing secrets. Safe to call multiple times (subsequent calls are no-ops).

stop

Python
async server.stop()

Stop the server and all component managers. Shuts down the lifespan manager and cleans up sessions.

run_connection

Python
async server.run_connection(read_stream, write_stream, init_options=None)

Run a single connection. Creates a ServerSession, registers it, and processes messages until the connection ends.

Parameters:

NameTypeDescriptionDefault
read_streamAnyStream for reading messages from the clientrequired
write_streamAnyStream for writing messages to the clientrequired
init_optionsAnyConnection initialization options (for example, {"transport_type": "stdio"})None

handle_message

Python
async server.handle_message(message, session=None, resource_owner=None)

Handle an incoming message. Validates the message, applies middleware, dispatches to the appropriate handler, and returns a response.

Parameters:

NameTypeDescriptionDefault
messageAnyJSON-RPC message dict to handlerequired
sessionServerSession | NoneThe server session for this connectionNone
resource_ownerResourceOwner | NoneAuthenticated resource owner from front-door authNone

Returns:

TypeDescription
MCPMessage | NoneJSON-RPC response, error, or None for notifications

Supported MCP methods

The server handles the following protocol methods:

MethodDescription
initializeInitialize the session and exchange capabilities
pingHealth check
tools/listList available tools
tools/callExecute a tool
resources/listList available resources
resources/readRead a resource
resources/templates/listList resource templates
prompts/listList available prompts
prompts/getGet a specific prompt
logging/setLevelSet the server log level

Example

Python
import asyncio from arcade_core.catalog import ToolCatalog from arcade_mcp_server.server import MCPServer async def main(): catalog = ToolCatalog() server = MCPServer(catalog=catalog, name="example", version="1.0.0") await server.start() try: # The server is now ready to handle connections. # In practice, a transport (stdio or HTTP) feeds # read_stream/write_stream into server.run_connection(). pass finally: await server.stop() if __name__ == "__main__": asyncio.run(main())
Last updated on