# Adapting Speakeasy MCP Servers for Remote Deployment
Source: https://speakeasy.com/docs/standalone-mcp/remote-mcp-servers

import { Callout } from "@/mdx/components";



Speakeasy-generated MCP servers are designed to run locally using Node.js, but
they can be adapted into remote services using MCP's [Streamable HTTP transport
specification](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#streamable-http).
This adaptation unlocks several key advantages:

- **Simplified deployment**: Users don't need Node.js, npm, or other local
  tooling installed
- **Flexible hosting**: Deploy to any cloud provider, container platform, or
  server infrastructure
- **Distribution independence**: Eliminate reliance on npm registries for
  server distribution
- **Multi-client support**: Handle concurrent connections from multiple MCP
  clients

This guide demonstrates how to prepare a Speakeasy-generated MCP server for
cloud deployment by wrapping it in an HTTP framework like Express.js, enabling
it to serve multiple clients simultaneously over standard HTTP connections.

## Prerequisites

Before starting, readers will need the following:

- [Node.js and npm installed](https://nodejs.org/en/download/)
- [A Speakeasy-generated MCP Server](/docs/standalone-mcp/build-server)

## Testing the MCP Server Locally

While working on the MCP server, take advantage of the [MCP
Inspector](https://modelcontextprotocol.io/legacy/tools/inspector) to test
your work locally. 

First, run the inspector with the following command:

```bash
npx @modelcontextprotocol/inspector
```

Once the inspector is running, set the transport to "Streamable HTTP" and the
URL to the address of the local MCP endpoint, which is
`http://localhost:3000/mcp` in this tutorial. This will allow you to connect to
the MCP server and verify it's working correctly before deployment.

![MCP Inspector with Streamable HTTP transport](/assets/docs/mcp-inspector_streamable-http-local-config.png)

## Preparing the HTTP Server

From a terminal, navigate to the root directory of your Speakeasy-generated MCP
server project, and create a new file for the HTTP server:

```bash
touch src/http-server.ts
```

In this file, we will set up an Express.js server to handle incoming HTTP
requests and route them to the MCP server. First, we'll set up the skeleton for
the HTTP server - a thin wrapper around the generated MCP server. For now, it
only requires a single endpoint to handle incoming requests.

```typescript
import express from 'express';

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

app.post('/mcp', async (req, res) => {
  // Here, we will handle incoming MCP requests
});

// This GET endpoint is required by the protocol for opening SSE connections
app.get('/mcp', async (req, res) => {
  res.status(405).send('Method not allowed: SSE not implemented.');
})

// Start the server and listen for requests
app.listen(3000, () => {
  console.log('Server listening on port 3000');
});
```

<Callout title="Note" type="info">

  The MCP protocol requires a `GET /mcp` endpoint for establishing Server-Sent
  Events (SSE) connections. In this example, we return a `405 Method Not
  Allowed` response for this endpoint, as we are not implementing SSE support for the scope of this guide.

  Read the [MCP
  Specification](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#listening-for-messages-from-the-server)
  for more details.

</Callout>

Start the server with the following command:

```bash