MCP ExplorerExplorer

Cdk Remotify Stdio Mcp

@ish-joshion 14 days ago
1 MIT
FreeCommunity
AI Systems
Easily convert local MCP servers to remote transport using SSE.

Overview

What is Cdk Remotify Stdio Mcp

cdk-remotify-stdio-mcp is a CDK construct that allows users to easily convert local MCP servers that use STDIO transport into remote servers using Server-Sent Events (SSE). It automates the deployment of the necessary infrastructure to host the MCP server.

Use cases

Use cases include deploying time services, data processing applications, and any other MCP-based applications that need to be accessed remotely via SSE.

How to use

To use cdk-remotify-stdio-mcp, import the RemoteSTDIOMCP class and create an instance by specifying the MCP command you wish to run. The construct will handle the deployment of the required infrastructure, including ECS Fargate service and load balancer.

Key features

Key features include the ability to deploy a remote MCP server with minimal configuration, support for injecting existing AWS resources like VPCs and ECS clusters, and plans for future enhancements such as support for WebSocket and Streamable HTTP.

Where to use

cdk-remotify-stdio-mcp is suitable for cloud-based applications that require remote access to MCP servers, particularly in environments where Server-Sent Events are supported.

Content

Remotify MCP

Easily convert local (STDIO transport) MCP servers to remote (sse for now) transport.

The flexible CDK construct allows you to deploy a remote MCP server that can be used by any MCP client supporting SSE (Server-Sent Events).

Simply specify the mcp command to run and the construct will spin up the necessary infrastructure to host it.

Video demo for usage in MCP clients

Usage

import { RemoteSTDIOMCP } from './remote-stdio-mcp';

const remoteTimeMCP = new RemoteSTDIOMCP(this, 'RemoteTimeMCP', {
    mcpCommand: 'uvx mcp-server-time --local-timezone=Australia/Melbourne'
});

Architecture

Currently the construct deploys a ECSFargate service with a load balancer in front of it. The service runs a Docker container that executes the specified MCP command and serves the output over SSE.

Injecting Existing Resources

If no infrastructure is specified, the construct will create a new VPC, ECS cluster, and load balancer. However, you can also inject existing resources to avoid creating new ones.

  • VPC: If you have an existing VPC, you can pass it to the construct to deploy the service within that VPC.
  • Cluster: If you have an existing ECS cluster, you can pass it to the construct to deploy the service in that cluster.
interface RemoteSTDIOMCPProps {
    vpc?: IVpc;
    cluster?: Cluster;
}

Next steps

  • Add support for more transports (e.g. WebSocket)
  • Add support for Streamable HTTP
  • Support hosting via Lambda (for simple commands) - this would allow for a more cost-effective solution for low-traffic commands.
  • Provide a way to easily get HTTP(S) URLs for the deployed services (probably via hosting in API Gateway)

Useful commands

  • npm run build compile typescript to js
  • npm run watch watch for changes and compile
  • npm run test perform the jest unit tests
  • npx cdk deploy deploy this stack to your default AWS account/region
  • npx cdk diff compare deployed stack with current state
  • npx cdk synth emits the synthesized CloudFormation template

Tools

No tools

Comments