cdk-serverless-mcp-server

cdk-serverless-mcp-server

A minimal MCP server deployed on AWS Lambda and API Gateway using AWS CDK, enabling tool execution via JSON-RPC (e.g., an add tool).

Category
Visit Server

README

🧠 cdk-serverless-mcp-server

A super simple Model Context Protocol (MCP) server deployed on AWS Lambda and exposed via Amazon API Gateway, deployed with AWS CDK. This skeleton is based on the awesome work of FrΓ©dΓ©ric Barthelet: which has developed a middy middleware for Model Context Protocol (MCP) server integration with AWS Lambda functions in this repo

Long story

πŸ›  Features

  • πŸͺ„ Minimal MCP server setup using @modelcontextprotocol/sdk
  • πŸš€ Deployed as a single AWS Lambda function
  • 🌐 HTTP POST endpoint exposed via API Gateway at /mcp
  • πŸ”„ Supports local development testing with jest
  • πŸ§ͺ Includes a simple example tool (add) with JSON-RPC interaction

πŸ“¦ Project Structure

cdk-serverless-mcp-server/
β”œβ”€β”€ __tests__/                              # Jest tests
β”œβ”€β”€ bin/                                    # CDK entry point
β”œβ”€β”€ cdk-serverless-mcp-server.ts                # CDK app
β”œβ”€β”€ lib/                                    # CDK stack
β”‚   └── cdk-serverless-mcp-server-stack.ts      # CDK stack
β”œβ”€β”€ src/                                    # Source code
β”‚   └── index.mjs                               # MCP server handler
β”œβ”€β”€ .gitignore                              # Git ignore file
β”œβ”€β”€ cdk.json                                # CDK Project config
β”œβ”€β”€ package.json                            # Project dependencies
β”œβ”€β”€ package-lock.json                       # Project lock file
β”œβ”€β”€ README.md                               # This documentation file

πŸ›  Prerequisites

πŸš€ Getting Started

  1. Install dependencies:
npm install
  1. Install AWS CDK globally (if not already installed):
npm install -g aws-cdk
  1. Test Locally with jest
npm run test

🧬 Code Breakdown

This code is based on the awesome work of FrΓ©dΓ©ric Barthelet: which has developed a middy middleware for Model Context Protocol (MCP) server integration with AWS Lambda functions in this repo

src/index.js

import middy from "@middy/core";
import httpErrorHandler from "@middy/http-error-handler";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import mcpMiddleware from "middy-mcp";

const server = new McpServer({
  name: "Lambda hosted MCP Server",
  version: "1.0.0",
});

server.tool("add", { a: z.number(), b: z.number() }, async ({ a, b }) => ({
  content: [{ type: "text", text: String(a + b) }],
}));

export const handler = middy()
  .use(mcpMiddleware({ server }))
  .use(httpErrorHandler());

πŸ“‘ Deploy to AWS

Just run:

npm run layer-dependencies-install # install dependencies for the layer

Then, deploy the stack:

cdk bootstrap
cdk deploy

After deployment, the MCP server will be live at the URL output by the command.

πŸ§ͺ Once deployed, test with curl requests

List tools

curl --location 'http://your-endpoint/dev/mcp' \
--header 'content-type: application/json' \
--header 'accept: application/json' \
--header 'jsonrpc: 2.0' \
--data '{
  "jsonrpc": "2.0",
  "method": "tools/list",
  "id": 1
}'

βž• Use the add Tool

curl --location 'http://your-endpoint/dev/mcp' \
--header 'content-type: application/json' \
--header 'accept: application/json' \
--header 'jsonrpc: 2.0' \
--data '{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "add",
    "arguments": {
      "a": 5,
      "b": 3
    }
  }
}'

πŸ“˜ License

MIT β€” feel free to fork, tweak, and deploy your own version!

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured