markvp_mcp_lambda_layer

markvp_mcp_lambda_layer

by markvp
A Node.js package enabling AWS Lambda functions to operate as MCP servers with SSE support.

MCP Lambda Server for AWS

Overview

The MCP Lambda Server for AWS is a Node.js package designed to provide MCP (Model Context Protocol) server infrastructure for AWS Lambda functions. It supports Server-Sent Events (SSE) through Lambda response streaming, making it ideal for real-time applications.

Features

  • AWS Lambda Integration: Adapts the MCP TypeScript SDK to work seamlessly with AWS Lambda.
  • Server-Sent Events (SSE): Supports real-time communication through Lambda response streaming.
  • CORS and HTTP Method Validation: Handles Cross-Origin Resource Sharing (CORS) and validates HTTP methods.
  • TypeScript Support: Fully compatible with TypeScript for type-safe development.

Important Notes

  • Function URLs Required: Lambda response streaming only works with Function URLs. It is not compatible with API Gateway or Application Load Balancer.
  • Node.js Runtime: Only the Node.js runtime is officially supported for response streaming.

Installation

To install the package, run the following command:

npm install @markvp/mcp-lambda-layer

Usage

Creating a Lambda Function

Import the package and create your Lambda function:

import { MCPHandlerFactory } from '@markvp/mcp-lambda-layer';
import { z } from 'zod';

const factory = new MCPHandlerFactory({
  tools: {
    summarize: {
      params: {
        text: z.string(),
      },
      handler: async ({ text }) => {
        const summary = await yourSummarizeImplementation(text);
        return {
          content: [{ type: 'text', text: summary }],
        };
      },
    },
  },
  prompts: {
    generate: {
      description: 'Generate content based on a prompt',
      handler: async extra => {
        const result = await yourGenerateImplementation(extra.prompt);
        return {
          content: [{ type: 'text', text: result }],
        };
      },
    },
  },
});

export const handler = factory.getHandler();

Required Lambda Configuration

  • Runtime: Node.js 18.x or later
  • Handler: index.handler
  • Memory: 128 MB minimum (adjust based on your needs)
  • Timeout: 120 seconds recommended
  • Function URL: Required with response streaming enabled
  • API Gateway/ALB: Not supported with streaming

Package Contents

This package includes:

  • MCP Server implementation with SSE transport
  • Protocol handling (JSON-RPC)
  • Streaming response support
  • Type definitions and interfaces

Your Lambda function provides:

  • Tool and prompt implementations
  • Business logic
  • Any necessary API clients or services
  • Configuration

License

This project is licensed under the MIT License.

About

The MCP Lambda Server for AWS is a Lambda Layer that enables a Lambda function to operate as an MCP server. It is designed for developers looking to integrate MCP with AWS Lambda for real-time, scalable applications.

Resources

Activity

  • Stars: 8
  • Watchers: 2
  • Forks: 1

Languages

  • TypeScript: 85.6%
  • JavaScript: 14.4%

Features & Capabilities

Categories
mcp_server model_context_protocol typescript javascript aws_lambda sse api_integration

Implementation Details

Stats

0 Views
8 GitHub Stars

Repository Info

markvp Organization

Similar MCP Servers

continuedev_continue by continuedev
25049
21423
9300