Overview
This tutorial will guide you through deploying Nuwa MCP Server Proxy on Railway platform, enabling your MCP tools to support DID authentication and paid calls. We’ll use Context7 documentation library MCP as our primary example while providing general configuration templates.Why Railway?
Railway is an ideal platform for deploying MCP Server Proxy:- ✅ Full support for Node.js and child processes (stdio upstream)
- ✅ Supports long connections and real-time communication
- ✅ Simple deployment via Git integration or Docker image
- ✅ Automatic HTTPS and domain generation
- ✅ Flexible environment variable management
Prerequisites
Before starting, ensure you have:- Railway Account: Sign up for a Railway account
- Service Key: Follow the Service Key guide to obtain your service key
Step 1: Create Empty Service on Railway
- Log in to Railway Dashboard
- Click “New Project”
- Select “Empty Service”
- Name your service, for example:
context7-mcp
Step 2: Configure Environment Variables
Add the following environment variables in your Railway project’s Variables page. These variables must match the placeholders used in your remote configuration file:Required Variables
Your service DID private key, obtained from the Service Key guide. Used in config as
${SERVICE_KEY}Rooch network type (test/main). Used in config as
${ROOCH_NETWORK}
Note: Currently only test network is supported.Default tool price in picoUSD (0.0001 USD). Used in config as
${DEFAULT_PRICE_PICO_USD}Optional Variables
Service port, automatically set by Railway. Used in config as
${PORT}Enable debug logging. Used in config as
${DEBUG}Environment variables must match the placeholders in your configuration file. For example, if your config file uses
${SERVICE_KEY}, you must set a SERVICE_KEY environment variable.Step 3: Use Remote Configuration File (Recommended)
Using remote configuration files is the simplest approach, eliminating the need to manage local configuration files. Add the following environment variable:Context7 example:
https://raw.githubusercontent.com/nuwa-protocol/nuwa-caps/main/mcp-proxy-config/context7-mcp.yaml
Understanding Configuration File Variables
The Context7 configuration file uses the following environment variable placeholders:${VARIABLE_NAME} placeholders in the configuration file must have corresponding environment variables set in Railway.
Custom Configuration (Advanced Users)
If you need custom configuration, you can:- Create your own configuration file and host it on a public URL
- Set
CONFIG_PATHto your configuration file URL - Ensure the configuration file is accessible via HTTPS
Step 4: Connect Docker Image and Deploy
4.1 Connect Docker Image
- In the service settings page, find the “Source” section
- Click “Connect” or “Deploy”
- Select “Docker Image”
- Enter the image address:
ghcr.io/nuwa-protocol/mcp-server-proxy:latest - Click “Deploy”

4.2 Monitor Deployment Process
- Railway will automatically start pulling the image and deploying
- View deployment logs in Railway Dashboard
- Wait for deployment to complete
4.3 Generate Public Domain
After successful deployment, you need to manually generate a public domain:- In the Railway service page, find the “Settings” tab
- Scroll to the “Networking” section
- Click the “Generate Domain” button
- Railway will generate a domain for you, similar to:
https://your-project-name.railway.app

Railway services do not automatically generate public domains by default. You need to manually generate one to access the service from outside.
https://context7-mcp-test.up.railway.app. You can use this domain to access your MCP service.
4.4 Service Discovery and Health Check
Verify the deployment using the Nuwa payment service discovery endpoint:Step 5: Test MCP Tools
5.1 Test with Cap Studio (Recommended)
Since MCP tool calls require DID authentication, we recommend using Cap Studio’s MCP Debug tool for testing:- Visit Cap Studio MCP Debug Tool
- Enter your MCP service URL:
https://your-project-name.railway.app/mcp - The tool will automatically handle DID authentication and payments
- Test various tool calls

5.2 Verify Service Status
You can verify that the service is running properly using the following methods: Service Discovery (no authentication required):- Direct curl calls require complex DID authentication flow
- Recommend using Cap Studio MCP Debug Tool for testing
- Cap Studio automatically handles authentication, payments, and tool calls
Troubleshooting
Deployment Failure
Issue: Docker container fails to start Solutions:- Check Railway deployment logs
- Verify
SERVICE_KEYenvironment variable is correctly set - If using
CONFIG_PATH, confirm the path is correct - Ensure all environment variables match the placeholders in your configuration file
- Check environment variable format is correct (boolean values should be
true/false, not"true"/"false")
Cannot Access Service
Issue: Service deployed successfully but cannot be accessed externally Solutions:- Confirm public domain has been generated (Settings → Networking → Generate Domain)
- Check if service is running
- Verify port configuration is correct
- Review Railway service logs
Upstream Connection Failure
Issue: Cannot connect to upstream MCP service Solutions:- Verify upstream URL and authentication information
- Check network connectivity
- Confirm upstream service health status
- Review proxy logs
Next Steps
After successful deployment, you can:- Build a Cap: Use Cap Studio to create a Cap that uses your MCP proxy
- Monitor Revenue: View tool call revenue through the Revenue dashboard
- Optimize Pricing: Adjust tool pricing based on usage
- Expand Functionality: Add more MCP tools or create custom MCP services

