🧠 serverless-mcp-server

🧠 serverless-mcp-server

A super simple Model Context Protocol (MCP) server deployed on AWS Lambda and exposed via Amazon API Gateway, deployed with Serverless Framework.

eleva

Developer Tools
Visit Server

README

🧠 serverless-mcp-server

A super simple Model Context Protocol (MCP) server deployed on AWS Lambda and exposed via Amazon API Gateway, deployed with Serverless Framework. 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

πŸ›  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 via serverless-offline
  • πŸ§ͺ Includes a simple example tool (add) with JSON-RPC interaction

πŸ“¦ Project Structure

serverless-mcp-server/
β”œβ”€β”€ src/                    # Source code
β”‚   └── index.js                # MCP server handler
β”œβ”€β”€ .gitignore              # Git ignore file
β”œβ”€β”€ package.json            # Project dependencies
β”œβ”€β”€ package-lock.json       # Project lock file
β”œβ”€β”€ README.md               # This documentation file
└── serverless.yml          # Serverless Framework config

πŸ›  Prerequisites

πŸš€ Getting Started

  1. Install dependencies:
npm install
  1. Install open source severless globally (if not already installed):
npm install -g osls
  1. Run Locally with serverless-offline
npm sls offline

Local endpoint will be available at: POST http://localhost:3000/dev/mcp

Note that the /dev/ stage is added by default when using serverless-offline, reflecting Api Gateway V1 (REST API) behavior.

Switch to Api Gateway V2 (HTTP API)

If you want to use API Gateway V2, you can change the serverless.yml file to use httpApi instead of http in the events section. This will allow you to use HTTP APIs instead of REST APIs. This will allow you to use HTTP APIs instead of REST APIs.

functions:
  mcpServer:
    handler: src/index.handler
    events:
      - httpApi:
          path: mcp
          method: post

Local endpoint will be available at: POST http://localhost:3000/mcp

Note that the /dev/ stage is not needed when using API Gateway V2. Note you should change test curl and postman requests accordingly.

πŸ§ͺ Test with curl requests

List tools

curl --location 'http://localhost:3000/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://localhost:3000/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
    }
  }
}'

🧬 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:

sls deploy

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

πŸ“˜ 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
MCP Package Docs Server

MCP Package Docs Server

Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.

Featured
Local
TypeScript
Claude Code MCP

Claude Code MCP

An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.

Featured
Local
JavaScript
@kazuph/mcp-taskmanager

@kazuph/mcp-taskmanager

Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.

Featured
Local
JavaScript
Linear MCP Server

Linear MCP Server

Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.

Featured
JavaScript
mermaid-mcp-server

mermaid-mcp-server

A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.

Featured
JavaScript
Jira-Context-MCP

Jira-Context-MCP

MCP server to provide Jira Tickets information to AI coding agents like Cursor

Featured
TypeScript
Linear MCP Server

Linear MCP Server

A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Featured
JavaScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.

Featured
Python