Skip to main content

LiteMCP

LiteMCP is an ASGI-compatible Model Context Protocol (MCP) server built on FastAPI. It provides a decorator-based API for registering tools, prompts, and resources.

Class Definition

Inherits from MCPAPIRouter and adds ASGI compatibility with FastAPI.

Constructor

**kwargs
dict
Additional arguments passed to MCPAPIRouter. Common options:
  • name (str): Server name (default: “agentor-mcp-server”)
  • version (str): Server version (default: “0.1.0”)
  • instructions (str): Instructions for using the server
  • prefix (str): URL prefix for MCP endpoints (default: “/mcp”)
  • website_url (str): Server website URL
  • icons (List[Icon]): Server icons
  • dependencies (List[Callable]): FastAPI dependencies

Methods

serve()

Run the server with uvicorn.
host
str
default:"0.0.0.0"
Host to bind the server to
port
int
default:"8000"
Port to bind the server to
enable_cors
bool
default:"true"
Whether to enable CORS middleware with permissive settings
**uvicorn_kwargs
dict
Additional arguments passed to uvicorn.run(), such as:
  • reload (bool): Enable auto-reload
  • log_level (str): Logging level (“debug”, “info”, “warning”, “error”)
  • workers (int): Number of worker processes

run()

Deprecated. Use serve() instead.

Decorators

LiteMCP inherits all decorators from MCPAPIRouter:
  • @app.tool() - Register a tool
  • @app.prompt() - Register a prompt
  • @app.resource() - Register a resource
  • @app.method() - Register a custom MCP method handler
See MCPAPIRouter for detailed decorator documentation.

ASGI Interface

LiteMCP implements the ASGI interface via __call__, making it compatible with any ASGI server:
This allows you to use LiteMCP with uvicorn CLI:

Example Usage

Basic Server

Running with Different Methods

Custom Configuration

See Also

Last modified on May 5, 2026