# Deployment Guide (Future Enhancement)
This guide is for deploying the Vega-Lite MCP Server as a **remote server** accessible over the internet.
⚠️ **Note**: The current implementation uses STDIO transport for local use. This guide describes the changes needed for remote deployment.
## Current Status: Local Only (STDIO)
The server currently runs locally using:
- **Transport**: `StdioServerTransport` (standard input/output)
- **Clients**: Claude Desktop, VS Code (local)
- **Deployment**: None needed - runs on user's machine
## To Deploy Remotely: Required Changes
### 1. Change Transport Layer
You'll need to modify `src/index.ts` to support HTTP or SSE transport:
```typescript
// Instead of StdioServerTransport
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
// or
import { StreamableHttpTransport } from "@modelcontextprotocol/sdk/server/http.js";
```
### 2. Add Web Server
Create a new file `src/server.ts`:
```typescript
import express from 'express';
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
const app = express();
const PORT = process.env.PORT || 3000;
app.get('/mcp', async (req, res) => {
const transport = new SSEServerTransport('/mcp', res);
await server.connect(transport);
});
app.listen(PORT, () => {
console.log(`MCP Server running on port ${PORT}`);
});
```
### 3. Add Authentication
For security, add API key authentication:
```typescript
app.use((req, res, next) => {
const apiKey = req.headers['x-api-key'];
if (apiKey !== process.env.API_KEY) {
return res.status(401).json({ error: 'Unauthorized' });
}
next();
});
```
## Deployment Platforms
### Option 1: Vercel
**Pros**: Easy deployment, free tier, global CDN
**Cons**: Serverless functions have 10s timeout
1. Install Vercel CLI:
```bash
npm i -g vercel
```
2. Create `vercel.json`:
```json
{
"version": 2,
"builds": [
{
"src": "dist/server.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/mcp",
"dest": "dist/server.js"
}
]
}
```
3. Deploy:
```bash
vercel
```
### Option 2: Cloudflare Workers
**Pros**: Edge computing, fast, generous free tier
**Cons**: Different runtime environment
See: https://blog.cloudflare.com/remote-model-context-protocol-servers-mcp/
### Option 3: Railway
**Pros**: Simple, supports long-running processes
**Cons**: No free tier
1. Connect GitHub repo
2. Deploy automatically on push
### Option 4: Fly.io
**Pros**: Good for WebSocket/SSE, free tier
**Cons**: Requires Docker knowledge
## Client Configuration (Remote)
Once deployed, clients configure differently:
```json
{
"mcpServers": {
"vegalite": {
"type": "sse",
"url": "https://your-deployment-url.com/mcp",
"headers": {
"x-api-key": "your-api-key-here"
}
}
}
}
```
## Considerations
### Performance
- Add caching (Redis, Cloudflare KV)
- Implement rate limiting
- Optimize response sizes
### Security
- Use HTTPS only
- Implement proper authentication (OAuth, API keys)
- Add CORS headers appropriately
- Validate all inputs
### Monitoring
- Add logging (Winston, Pino)
- Track usage metrics
- Set up error alerting
### Costs
- Vercel: Free tier generous, then $20/month
- Cloudflare Workers: Free tier very generous
- Railway: ~$5-20/month
- Fly.io: Free tier available
## Migration Path
1. **Phase 1**: Keep STDIO for local development ✅ (Current)
2. **Phase 2**: Add HTTP/SSE transport support
3. **Phase 3**: Deploy to staging environment
4. **Phase 4**: Add authentication and monitoring
5. **Phase 5**: Deploy to production
6. **Phase 6**: Support both local and remote
## Example: Dual Transport
Support both local and remote:
```typescript
// src/index.ts
const transport = process.env.REMOTE
? new SSEServerTransport('/mcp', res)
: new StdioServerTransport();
await server.connect(transport);
```
## Testing Remote Deployment
Before deploying:
1. Test locally with HTTP transport
2. Test authentication flow
3. Test with actual MCP clients
4. Load test the endpoints
5. Monitor error rates
## References
- [MCP Remote Servers Guide](https://modelcontextprotocol.io/docs/concepts/transports)
- [Cloudflare MCP Blog Post](https://blog.cloudflare.com/remote-model-context-protocol-servers-mcp/)
- [Microsoft Remote MCP Server](https://learn.microsoft.com/api/mcp)
---
**Status**: 📝 Planning document - implementation not started
**Priority**: Low - Local deployment works well for now
**Next Steps**:
1. Finish local version features first
2. Gather user feedback
3. Assess need for remote deployment
4. Implement if there's demand