Railway MCP Server
MCP server with Streamable HTTP transport, deployed on Railway, offering tools like weather, BMI calculator, greetings, and question generation.
README
MCP Server with HTTP Streaming - Railway Deployment
This project demonstrates deploying a Model Context Protocol (MCP) server with HTTP streaming support to Railway. The server uses the modern Streamable HTTP transport which provides efficient bidirectional communication over a single HTTP endpoint.
Features
- ✅ Streamable HTTP Transport: Modern MCP transport with full bidirectional streaming
- ✅ HTTP Streaming: Supports real-time communication and server-sent events
- ✅ Multiple Tools: Weather API, BMI calculator, and more
- ✅ Resources & Prompts: Dynamic greetings and question generation
- ✅ Railway Optimized: Configured for seamless Railway deployment
Tools Available
- get_weather(city) - Get simulated weather data for any city
- calculate_bmi(weight_kg, height_m) - Calculate BMI with category classification
- greeting://{{name}} - Personalized greeting resource
- ask_question(topic, style) - Generate styled questions about topics
Local Development
Prerequisites
- Python 3.8+
- pip or uv package manager
Setup
# Clone this repository
git clone <your-repo-url>
cd mcp-railway-server
# Install dependencies
pip install -r requirements.txt
# OR with uv
uv pip install -r requirements.txt
# Run locally
python main.py
The server will start on http://localhost:8000/mcp with Streamable HTTP transport.
Testing the Server
You can test the server using the MCP Inspector or any MCP client that supports Streamable HTTP:
# Install MCP CLI tools (if available)
uv tool install mcp
# Test with MCP Inspector
mcp inspect http://localhost:8000/mcp
Railway Deployment
Method 1: Deploy from GitHub (Recommended)
-
Fork this repository to your GitHub account
-
Create a new Railway project:
- Go to Railway
- Click "New Project"
- Select "Deploy from GitHub repo"
- Choose your forked repository
-
Configure deployment:
- Railway will automatically detect the
railway.jsonconfiguration - The app will build using Nixpacks
- No additional environment variables needed
- Railway will automatically detect the
-
Generate domain:
- Go to your service settings
- Navigate to "Networking" tab
- Click "Generate Domain"
- Your MCP server will be available at:
https://your-app-name.railway.app/mcp
Method 2: Deploy with Railway CLI
# Install Railway CLI
npm install -g @railway/cli
# Login to Railway
railway login
# Initialize project
railway init
# Deploy
railway up
Method 3: Deploy with Docker
If you prefer using Docker:
# Build Docker image
docker build -t mcp-server .
# Run locally (test)
docker run -p 8000:8000 -e PORT=8000 mcp-server
# Deploy to Railway (Railway will handle this automatically if Dockerfile is present)
Configuration
Environment Variables
Railway automatically sets the PORT environment variable. No additional configuration is required for basic deployment.
Optional environment variables you can add:
MCP_SERVER_NAME: Custom server name (default: "Railway MCP Server")DEBUG: Set to "true" for debug logging
MCP Client Configuration
To connect an MCP client to your deployed server, use this configuration:
{
"mcpServers": {
"railway-mcp": {
"type": "streamable-http",
"url": "https://your-app-name.railway.app/mcp"
}
}
}
Architecture
This server uses:
- FastMCP: High-level MCP server framework
- Streamable HTTP Transport: Modern bidirectional communication protocol
- Railway Platform: Serverless deployment with automatic scaling
Key Benefits of Streamable HTTP:
- Single endpoint for all communication (
/mcp) - Automatic connection upgrades to SSE when needed
- Better performance than traditional HTTP+SSE approach
- Full bidirectional communication support
Troubleshooting
Common Issues
-
Port binding error locally:
# Make sure port 8000 is available lsof -i :8000 -
Railway deployment fails:
- Check that
requirements.txtincludesmcp>=1.8.0 - Ensure
railway.jsonhas correct start command - Verify Railway has access to your GitHub repository
- Check that
-
MCP client connection issues:
- Ensure client supports Streamable HTTP transport
- Use correct URL format:
https://your-app.railway.app/mcp - Check that Railway domain is generated and accessible
Logs and Debugging
View Railway logs:
railway logs
Enable debug mode by setting environment variable:
railway variables set DEBUG=true
Next Steps
- Add Authentication: Implement OAuth 2.1 for secured endpoints
- Add Real APIs: Replace simulated data with real weather/data APIs
- Database Integration: Add persistent storage with Railway PostgreSQL
- Monitoring: Set up logging and monitoring for production use
Resources
License
MIT License - see LICENSE file for details.
Recommended Servers
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.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.