Claude Skills Guide

Heroku MCP Server Application Deployment Guide

Deploying a Model Context Protocol (MCP) server on Heroku provides a reliable, scalable way to expose AI capabilities to your applications. This guide walks through the complete deployment process, from local development to production-ready infrastructure.

Understanding MCP Servers

MCP servers act as intermediaries between Claude and external tools or data sources They enable Claude to interact with APIs, databases, and services that aren’t natively integrated. Whether you’re building a custom integration with your internal systems or exposing specialized AI capabilities, hosting your MCP server on Heroku simplifies deployment and maintenance.

Prerequisites

Before deploying, ensure you have:

Setting Up Your MCP Server Project

If you’re starting from scratch, create a basic MCP server structure:

mkdir my-mcp-server && cd my-mcp-server
npm init -y
npm install @modelcontextprotocol/server-basic @modelcontextprotocol/sdk

Create your server file:

// server.js
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';

const server = new Server({
  name: 'my-custom-server',
  version: '1.0.0'
}, {
  capabilities: {
    tools: {}
  }
});

server.setRequestHandler('tools/list', async () => {
  return {
    tools: [{
      name: 'greet',
      description: 'Greet a user by name',
      inputSchema: {
        type: 'object',
        properties: {
          name: { type: 'string', description: 'Name to greet' }
        },
        required: ['name']
      }
    }]
  };
});

server.setRequestHandler('tools/call', async ({ name, arguments: args }) => {
  if (name === 'greet') {
    return { content: [{ type: 'text', text: `Hello, ${args.name}!` }] };
  }
  throw new Error(`Unknown tool: ${name}`);
});

const transport = new StdioServerTransport();
await server.connect(transport);

Update your package.json with a start script:

{
  "type": "module",
  "scripts": {
    "start": "node server.js"
  }
}

Configuring Heroku for MCP Deployment

MCP servers typically communicate over stdio, but Heroku’s architecture requires an HTTP-based approach. Modify your server to support HTTP connections:

// server-http.js
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { HttpServerTransport } from '@modelcontextprotocol/sdk/server/http.js';
import express from 'express';

const app = express();
app.use(express.json());

const server = new Server({
  name: 'my-custom-server',
  version: '1.0.0'
}, {
  capabilities: {
    tools: {}
  }
});

// Define your tools and handlers here
server.setRequestHandler('tools/list', async () => {
  return { tools: [...] };
});

server.setRequestHandler('tools/call', async (request) => {
  // Handle tool calls
});

const transport = new HttpServerTransport('/mcp', app);
await server.connect(transport);

app.listen(process.env.PORT || 3000);

Heroku requires a Procfile to know how to run your application:

web: node server-http.js

Deploying to Heroku

Initialize git in your project if you haven’t already:

git init
git add .
git commit -m "Initial MCP server commit"

Create a new Heroku application and deploy:

heroku create my-mcp-server
git push heroku main

Your MCP server is now live. Retrieve the URL:

heroku apps:info | grep Web URL

Connecting Claude to Your Heroku MCP Server

With your server deployed, configure Claude Desktop to connect. Create or edit your Claude configuration file:

{
  "mcpServers": {
    "my-heroku-mcp": {
      "url": "https://your-app-name.herokuapp.com/mcp"
    }
  }
}

Replace your-app-name with your actual Heroku application name. Claude will now be able to call your deployed MCP server for tool invocations.

Production Considerations

When moving to production, several factors require attention:

Environment Variables: Store sensitive configuration in Heroku config vars rather than hardcoding credentials. Access them in your server:

const apiKey = process.env.API_KEY;
const databaseUrl = process.env.DATABASE_URL;

Scaling: Heroku’s free tier sleeps after inactivity. For consistent response times, consider a paid dyno or implement a keep-alive mechanism. Scale your dynos based on demand:

heroku ps:scale web=2

Logging and Monitoring: Heroku provides built-in logging:

heroku logs --tail

For more comprehensive monitoring, integrate with services like DataDog or New Relic through Heroku addons.

Using Claude Skills with Your MCP Server

Your deployed MCP server works well with various Claude skills. The frontend-design skill can help generate UI components that consume your MCP tools. If you’re building documentation, pair your server with the pdf skill to generate reports from MCP-sourced data.

For test-driven development, the tdd skill assists in writing comprehensive tests for your MCP server endpoints. The supermemory skill can help maintain context across complex conversations about your deployment architecture.

Troubleshooting Common Issues

Connection Timeouts: If Claude cannot reach your server, verify your Heroku dyno is running and the endpoint URL is correct in your configuration.

CORS Issues: If your MCP server serves web clients directly, ensure CORS headers are properly configured in Express:

app.use((req, res, next) => {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
  next();
});

Memory Limits: Heroku dynos have memory constraints. Optimize your server’s memory usage and consider upgrading to larger dyno types for resource-intensive operations.

Conclusion

Deploying an MCP server on Heroku bridges the gap between Claude’s capabilities and your custom backend services. The platform handles infrastructure concerns, letting you focus on building valuable integrations. With proper configuration and monitoring, your Heroku-hosted MCP server provides a reliable foundation for AI-powered applications.

Built by theluckystrike — More at zovo.one