FastMCP Template Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@FastMCP Template Servergreet Alice"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
FastMCP Template
This is a FastMCP template project that works seamlessly in local, Docker, and cloud environments. Get started instantly by deploying to Railway with one click!
š Quick Deploy to Railway (Recommended)
The fastest way to get your FastMCP server running in the cloud:
One-Click Deploy
Connect Remote Client to Railway
Once deployed, use this client to connect from anywhere:
Simple Method (Direct URL):
# my_client_remote.py
import asyncio
from fastmcp import Client
# Replace with your Railway URL
RAILWAY_URL = "https://your-railway-url.up.railway.app/mcp"
client = Client(RAILWAY_URL)
async def call_tool(name: str):
async with client:
result = await client.call_tool("greet", {"name": name})
print(result)
if __name__ == "__main__":
asyncio.run(call_tool("Ford"))Run it:
uv run my_client_remote.pyWith Environment Variable (More Flexible):
export RAILWAY_URL="https://your-railway-url.up.railway.app/mcp"
uv run my_client_remote.pyRelated MCP server: FastMCP Demo Server
Project Structure
my_server.py- FastMCP server with agreettool (works locally, Docker, and Railway)my_client.py- Local/Docker client that connects via HTTPmy_client_remote.py- Remote client for Railway connectionsDockerfile- Container configuration for all cloud deployments
Local Development
Perfect for testing and development on your machine.
Terminal 1 - Start the server:
uv run fastmcp run my_server.py:mcp --transport http --port 8080Terminal 2 - Run the client:
export PORT=8080
export HOST_URL="http://localhost"
uv run my_client.pyOutput: Hello, Ford!
Docker Deployment
Deploy locally with Docker or on any container platform.
Build the Docker image:
docker build -t fastmcp-server .Run the Docker container:
docker run -p 8080:8080 fastmcp-serverConnect the client:
export PORT=8080
export HOST_URL="http://localhost"
uv run my_client.pyEnvironment Variables
Local & Docker Deployments
HOST_URL- The server host URL (default:http://localhost)PORT- The server port (default:8080)
Examples:
# Custom port
export PORT=3000
uv run fastmcp run my_server.py:mcp --transport http --port 3000
export PORT=3000
uv run my_client.py
# Custom host
export HOST_URL="http://192.168.1.100"
export PORT=8080
uv run my_client.pyRailway Deployment
RAILWAY_URL- Full Railway endpoint URL (e.g.,https://your-url.up.railway.app/mcp)Configure additional variables in Railway dashboard ā Variables tab
Architecture
Why This Approach?
This template uses HTTP transport for consistency across all deployment scenarios:
Consistency - Same protocol everywhere
Simplicity - Just two files for any scenario
Scalability - HTTP enables cloud deployment
Flexibility - Easy to modify URLs/ports per environment
Deployment Options
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā š RECOMMENDED: Railway Cloud ā
ā ⢠One-click deployment ā
ā ⢠Automatic HTTPS & CDN ā
ā ⢠Global access ā
ā URL: https://your-url.up.railway.app/mcp ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā š³ Docker (Local or Any Cloud) ā
ā ⢠Full control ā
ā ⢠Works anywhere with Docker ā
ā URL: http://localhost:8080/mcp ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā š Local Development ā
ā ⢠Perfect for testing ā
ā ⢠Two terminal setup ā
ā URL: http://localhost:8080/mcp ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāConfiguration Details
Server (my_server.py)
The server uses the FastMCP framework with a simple greet tool:
@mcp.tool
def greet(name: str) -> str:
return f"Hello, {name}!"When run locally with:
uv run fastmcp run my_server.py:mcp --transport http --port 8080When run in Docker via Dockerfile:
CMD ["sh", "-c", "uv run fastmcp run my_server.py:mcp --transport http --host 0.0.0.0 --port $PORT"]Client (my_client.py)
Local/Docker client connects with environment variables:
PORT = os.getenv("PORT", "8080")
HOST_URL = os.getenv("HOST_URL", "http://localhost")
client = Client(f"{HOST_URL}:{PORT}/mcp")Remote Client (my_client_remote.py)
Railway/remote client connects with direct URL or environment variable:
RAILWAY_URL = os.getenv("RAILWAY_URL", "https://your-url.up.railway.app/mcp")
client = Client(RAILWAY_URL)Troubleshooting
Railway Connection Issues
Server not responding:
Check Railway deployment logs in dashboard
Verify URL:
https://your-url.up.railway.app/mcpTest with curl:
curl https://your-railway-url.up.railway.app/mcp
Finding your Railway URL:
Go to Railway project dashboard
Select the deployment
Go to "Settings"
Copy the domain URL
Append
/mcpfor the endpoint
Custom Domain on Railway:
Go to Service Settings ā Custom Domain
Add your domain (e.g.,
mcp.example.com)
Local Development Issues
Connection failed:
Check if server is running:
ps aux | grep fastmcpVerify port accessible:
curl http://localhost:8080/mcpEnsure PORT and HOST_URL environment variables are set
Port already in use:
# Use different port
export PORT=3000
uv run fastmcp run my_server.py:mcp --transport http --port 3000
export PORT=3000
uv run my_client.pyDocker Issues
Check if container is running:
docker psView logs:
docker logs <container-id>Verify port mapping:
docker run -p 8080:8080 ...Test connectivity:
curl http://localhost:8080/mcp
Summary
This FastMCP template provides multiple deployment options:
ā Railway - Fastest cloud deployment (recommended)
ā Docker - Full control, works anywhere
ā Local - Perfect for development and testing
ā Same codebase - No changes needed for different deployments
ā Just change URLs - Environment variables handle all variations
This server cannot be deployed
Maintenance
Related MCP Connectors
Primarily to be used as a template repository for developing MCP servers with FastMCP in Python, Pā¦
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA minimal, dockerized template for creating HTTP-based Model Context Protocol servers. Provides a starting point with FastMCP framework integration and includes a sample cat fact tool that can be replaced with custom functionality.-
- FlicenseNot gradedqualityDmaintenanceA minimal demonstration MCP server built with FastMCP that exposes a simple greeting tool, showcasing basic server setup and remote deployment capabilities.-
- FlicenseBqualityDmaintenanceA template and demonstration project for building, testing, and deploying remote MCP servers using FastMCP and uv. It provides a foundational structure for creating MCP-compliant tools that can be hosted publicly and integrated with LLM agents.2-
- FlicenseAqualityDmaintenanceA simple MCP server that provides a greeting tool using FastMCP, with support for both local and containerized deployment.1-