FlashMCP servers can be run in different ways depending on your application’s needs, from local command-line tools to persistent web services. This guide covers the primary methods for running your server, focusing on the available transport protocols: STDIO, Streamable HTTP, and SSE.Documentation Index
Fetch the complete documentation index at: https://flashmcpdocs.com/llms.txt
Use this file to discover all available pages before exploring further.
The run() Method
FlashMCP servers can be run directly from Python by calling the run() method on a FlashMCP instance.
my_server.py
python my_server.py.
MCP servers can be run with a variety of different transport options, depending on your application’s requirements. The run() method can take a transport argument and other transport-specific keyword arguments to configure how the server operates.
The FlashMCP CLI
FlashMCP also provides a command-line interface for running servers without modifying the source code. After installing FlashMCP, you can run your server directly from the command line:dev command to run your server with the MCP Inspector:
Transport Options
Below is a comparison of available transport options to help you choose the right one for your needs:| Transport | Use Cases | Recommendation |
|---|---|---|
| STDIO | Local tools, command-line scripts, and integrations with clients like Claude Desktop | Best for local tools and when clients manage server processes |
| Streamable HTTP | Web-based deployments, microservices, exposing MCP over a network | Recommended choice for web-based deployments |
| SSE | Existing web-based deployments that rely on SSE | Deprecated - prefer Streamable HTTP for new projects |
STDIO
The STDIO transport is the default and most widely compatible option for local MCP server execution. It is ideal for local tools, command-line integrations, and clients like Claude Desktop. However, it has the disadvantage of having to run the MCP code locally, which can introduce security concerns with third-party servers. STDIO is the default transport, so you don’t need to specify it when callingrun(). However, you can specify it explicitly to make your intent clear:
Streamable HTTP
Streamable HTTP is a modern, efficient transport for exposing your MCP server via HTTP. It is the recommended transport for web-based deployments. To run a server using Streamable HTTP, you can use therun() method with the transport argument set to "streamable-http". This will start a Uvicorn server on the default host (127.0.0.1), port (8000), and path (/mcp).
run() method.
SSE
Server-Sent Events (SSE) is an HTTP-based protocol for server-to-client streaming. While FlashMCP still supports SSE, it is deprecated and Streamable HTTP is preferred for new projects. To run a server using SSE, you can use therun() method with the transport argument set to "sse". This will start a Uvicorn server on the default host (127.0.0.1), port (8000), and with default SSE path (/sse) and message path (/messages/).
run() method. You can also adjust the SSE path (which clients should connect to) and the message POST endpoint (which clients use to send subsequent messages).
Async Usage
FlashMCP provides both synchronous and asynchronous APIs for running your server. Therun() method seen in previous examples is a synchronous method that internally uses anyio.run() to run the asynchronous server. For applications that are already running in an async context, FlashMCP provides the run_async() method.
run() and run_async() accept the same transport arguments, so all the examples above apply to both methods.
Custom Routes
You can also add custom web routes to your FlashMCP server, which will be exposed alongside the MCP endpoint. To do so, use the@custom_route decorator. Note that this is less flexible than using a full ASGI framework, but can be useful for adding simple endpoints like health checks to your standalone server.