serverless-mcp

hteek/serverless-mcp

3.3

If you are the rightful owner of serverless-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A serverless implementation of the Model Context Protocol (MCP) using AWS Lambda, CloudFront, and Cognito authentication.

The Serverless MCP project provides a comprehensive infrastructure for hosting Model Context Protocol (MCP) servers in the cloud, leveraging AWS services such as Lambda, CloudFront, and Cognito for a scalable, secure, and efficient solution. This implementation supports OAuth 2.0 authentication, ensuring secure access through AWS Cognito, and offers real-time streaming capabilities via Server-Sent Events (SSE) with JSON-RPC 2.0 messaging format. The architecture is designed to be serverless, utilizing AWS Lambda functions to handle requests dynamically, which allows for automatic scaling based on demand. The project includes a custom transport implementation compatible with the official Model Context Protocol TypeScript SDK, making it easy to integrate with existing MCP clients. Additionally, the infrastructure is managed using AWS Cloud Development Kit (CDK), enabling automated deployments and updates through GitHub Actions with OIDC-based CI/CD pipelines. This setup ensures that the MCP server is always up-to-date and can handle high traffic volumes without manual intervention.

Features

  • MCP Protocol Implementation: Full support for Model Context Protocol with tools and resources.
  • Serverless Architecture: AWS Lambda functions with CloudFront distribution.
  • OAuth 2.0 Authentication: Secure authentication using AWS Cognito.
  • Real-time Streaming: Server-Sent Events (SSE) support for live communication.
  • Session Management: Stateful and stateless session handling.

Usages

usage with aws lambda

typescript
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StreamableHTTPTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';

const transport = new StreamableHTTPTransport('https://your-domain.com/mcp');

const client = new Client(
  { name: 'my-client', version: '1.0.0' },
  { capabilities: {} }
);

await client.connect(transport);

usage with github actions

yaml
name: CI

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Set up Node.js
      uses: actions/setup-node@v2
      with:
        node-version: '22'

    - name: Install dependencies
      run: pnpm install

    - name: Build
      run: pnpm build

    - name: Test
      run: pnpm test

    - name: Deploy
      run: pnpm cdk deploy --all
      env:
        AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }}

Tools

  1. get_today_date

    Get the current date to help with relative date queries.

  2. get_dimension_values

    Get available values for AWS Cost Explorer dimensions (SERVICE, REGION, etc.).

  3. get_tag_values

    Get available values for a specific tag key.

  4. get_cost_and_usage

    Retrieve AWS cost and usage data with filtering and grouping.

  5. get_cost_forecast

    Generate cost forecasts based on historical usage patterns.

  6. get_cost_and_usage_comparisons

    Compare costs between two time periods.

  7. get_cost_comparison_drivers

    Analyze what drove cost changes between periods.