FastMCP Template

FastMCP Template

A FastMCP server template that provides a greet tool returning personalized greetings. It supports local, Docker, and Railway cloud deployments.

Category
Visit Server

README

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

Deploy on Railway

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.py

With Environment Variable (More Flexible):

export RAILWAY_URL="https://your-railway-url.up.railway.app/mcp"
uv run my_client_remote.py

Project Structure

  • my_server.py - FastMCP server with a greet tool (works locally, Docker, and Railway)
  • my_client.py - Local/Docker client that connects via HTTP
  • my_client_remote.py - Remote client for Railway connections
  • Dockerfile - 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 8080

Terminal 2 - Run the client:

export PORT=8080
export HOST_URL="http://localhost"
uv run my_client.py

Output: 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-server

Connect the client:

export PORT=8080
export HOST_URL="http://localhost"
uv run my_client.py

Environment 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.py

Railway 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:

  1. Consistency - Same protocol everywhere
  2. Simplicity - Just two files for any scenario
  3. Scalability - HTTP enables cloud deployment
  4. 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 8080

When 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:

  1. Check Railway deployment logs in dashboard
  2. Verify URL: https://your-url.up.railway.app/mcp
  3. Test with curl: curl https://your-railway-url.up.railway.app/mcp

Finding your Railway URL:

  1. Go to Railway project dashboard
  2. Select the deployment
  3. Go to "Settings"
  4. Copy the domain URL
  5. Append /mcp for 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:

  1. Check if server is running: ps aux | grep fastmcp
  2. Verify port accessible: curl http://localhost:8080/mcp
  3. Ensure 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.py

Docker Issues

  1. Check if container is running: docker ps
  2. View logs: docker logs <container-id>
  3. Verify port mapping: docker run -p 8080:8080 ...
  4. 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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured