Skip to main content
Glama
DEPLOY.mdβ€’2.97 kB
# Code-MCP Cloud Deployment Guide ## πŸš€ Deploy to Cloud (Free Hosting Options) ### Option 1: Railway (Recommended) [![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/code-mcp) ```bash # One-click deploy via Railway dashboard # Or use CLI: npm i -g @railway/cli railway login railway init railway up ``` **Railway Config** (`railway.toml`): ```toml [build] builder = "dockerfile" [deploy] healthcheckPath = "/health" healthcheckTimeout = 100 ``` --- ### Option 2: Render (Free tier available) 1. Fork this repo 2. Go to [render.com](https://render.com) 3. New > Web Service 4. Connect GitHub repo 5. Build command: `npm run build` 6. Start command: `node dist/index.js` --- ### Option 3: Fly.io ```bash # Install flyctl curl -L https://fly.io/install.sh | sh # Deploy fly launch fly deploy ``` **fly.toml**: ```toml app = "code-mcp" [build] dockerfile = "Dockerfile" [http_service] internal_port = 3000 force_https = true [[vm]] memory = "256mb" cpu_kind = "shared" ``` --- ### Option 4: Vercel (Edge Functions) ```bash npm i -g vercel vercel ``` --- ## πŸ” Adding Authentication For a hosted MCP server, you'll want authentication: ### Simple API Key Auth ```typescript // In your server const API_KEY = process.env.CODE_MCP_API_KEY; app.use((req, res, next) => { const key = req.headers['x-api-key']; if (key !== API_KEY) { return res.status(401).json({ error: 'Unauthorized' }); } next(); }); ``` ### OAuth / Login System Consider using: - **Clerk** - Free tier, easy setup - **Auth0** - Free tier available - **Supabase Auth** - Free & open source --- ## 🌐 HTTP Transport for Cloud Currently, Code-MCP uses stdio transport. For cloud hosting, we need HTTP: ```typescript // HTTP server for cloud deployment import express from 'express'; import { Server } from '@modelcontextprotocol/sdk/server/index.js'; const app = express(); app.use(express.json()); app.post('/mcp', async (req, res) => { const { method, params } = req.body; const result = await handleMCPRequest(method, params); res.json(result); }); app.get('/health', (req, res) => { res.json({ status: 'healthy', tools: 36 }); }); app.listen(process.env.PORT || 3000); ``` --- ## Environment Variables Set these in your hosting platform: ```env PORT=3000 CODE_MCP_API_KEY=your-secret-key NODE_ENV=production ``` --- ## Connect from AI Tools Once deployed, connect like this: ### Claude Desktop ```json { "mcpServers": { "code-mcp-cloud": { "url": "https://your-deployment-url.railway.app/mcp", "headers": { "x-api-key": "your-api-key" } } } } ``` ### Cursor Add to settings with your cloud URL. --- ## Free Hosting Comparison | Platform | Free Tier | Best For | |----------|-----------|----------| | Railway | 500hrs/mo | Easy deploys | | Render | 750hrs/mo | Web services | | Fly.io | 3 shared VMs | Edge deployment | | Vercel | Unlimited | Serverless |

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/millsydotdev/Code-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server