Skip to main content
The Model Context Protocol (MCP) enables standardized communication between AI applications and external tools. Agentor’s LiteMCP makes it easy to build MCP servers that work with any MCP client.

What is LiteMCP?

LiteMCP is a FastAPI-native MCP server implementation. Unlike other solutions, it integrates directly with FastAPI using standard ASGI patterns, making it easy to add to existing applications.

LiteMCP vs FastMCP

Quick Start

Create a basic MCP server:
Your MCP server is now running at http://localhost:8000/mcp!

Server Components

Tools

Tools are functions that agents can call:

Prompts

Prompts are reusable templates for common tasks:

Resources

Resources provide access to data or content:

Authentication & Context

Access request headers, cookies, and authentication tokens:

Integration Patterns

Standalone Server

Run LiteMCP as a standalone application:

With Existing FastAPI App

Integrate MCP into your existing FastAPI application:
Now your MCP endpoints are available at /mcp alongside your existing API.

With ASGI Servers

LiteMCP is a native ASGI application:
Run with any ASGI server:

Using MCP Servers with Agents

Connect to an HTTP MCP Server

Hand the agent an MCPServer alongside its other tools. Agentor connects to it when a run starts, turns its remote tools into ordinary tools, and closes the connection when the run ends — including when the run raises.
agent.run(...) works the same way — you do not need to manage the connection yourself.
str
required
The server’s streamable-HTTP MCP endpoint, usually ending in /mcp.
dict[str, str]
default:"None"
Headers sent on every request, typically for authentication.
float
default:"30.0"
Request timeout in seconds.
str
default:"the url"
A label used in logs and warnings.
str
default:"None"
Prepended to every tool name from this server. Use it when two servers expose the same tool name — otherwise the second one is skipped with a warning.
Remote tools behave like local ones: they appear in traces, and a tool that keeps failing is withdrawn after the same failure budget.

Inspect a server directly

MCPServer is also an async context manager, which is handy for checking what a server offers:
Tool discovery follows pagination, so servers with many tools are listed in full.
Connect and close on the same event loop — inside one asyncio.run(), or with async with. Closing from a different loop raises, because the underlying session is bound to the task that opened it.

Migrating from MCPServerStreamableHttp

The old constructor still works and emits a DeprecationWarning. Options it accepted that the client no longer needs, such as cache_tools_list and max_retry_attempts, are ignored.

Connect to Celesto MCP Hub

Access shared MCP servers via Celesto:

Complete Example

Here’s a full-featured MCP server:

Best Practices

Deployment

LiteMCP is a FastAPI app, so host it like any other ASGI service - see Serve agents as an API. The MCP endpoint is served relative to wherever you mount it:

Next Steps

Last modified on July 30, 2026