Serverless MCP Framework

Serverless MCP Framework

A framework to deploy MCP servers on AWS using serverless services like Lambda, API Gateway, and EventBridge, with dynamic tools, prompts, and resources managed via SSM parameters and Lambda functions.

Category
访问服务器

README

Serverless MCP Framework

CloudFormation Lambda API Gateway

MCP Server implementation with AWS Serverless services.

Created resources

A set of Lambda function connected to EventBridge rules that handle start, stop and task start. Create StepFunction state machine to wait until a specific date and send events.

Infrastructure Schema

Installation

Using the SAM CLI:

sam build
sam deploy --guided

Parameters

This application need some parameters when you deploy it:

  • EventBusName: The event bus name to connect the integration to

  • Project: Project identifier

  • Environment: Environment identifier

  • ServerName: The MCP server name

  • ServerVersion: The MCP server version

  • Instructions: The MCP server instructions

  • DomainName: The domain name of the endpoint

  • AcmCertificateArn: The certificate arn for the domain name provided

  • AuthenticationType: Authentication type for the MCP server

  • AuthenticationToken: The authentication token for the MCP server

  • OAuthIssuerUrl: The issuer URL for OAuth authentication

  • OAuthAuthorizationUrl: The authorization URL for OAuth authentication

  • OAuthTokenUrl: The token URL for OAuth authentication

  • OAuthRevocationUrl: The revocation URL for OAuth authentication

  • OAuthRedirectUris: The redirect URIs for OAuth authentication

Outputs

  • ServerEndpoint: The MCP server endpoint

Development

Requirements:

Install NPM modules

npm install

Configure the .env file with MCP server specifications:

SERVER_NAME=local
SERVER_VERSION=1.0.0
INSTRUCTIONS=""

Configure the .env file with AWS environment configuration:

AWS_PROFILE=<your AWS profile>
AWS_REGION=<selected AWS region>

SSM_PREFIX=
TOOLS_SSM_PREFIX=
RESOURCES_SSM_PREFIX=
PROMPTS_SSM_PREFIX=
TOOL_LAMBDA_PREFIX=

Run local MCP server

npm run dev

The MCP server is running on http://localhost:3000/mcp.

Tool Inspector

Run the MCP Inspector

npm run inspector

Configure the inspector with:

  • Transport Type: Streamable HTTP
  • URL: http://localhost:3000/mcp

Connect to the MCP server with "Connect" button.

Claude Desktop

Use mcp-remote to proxy HTTP to STDIO:

{
  "mcpServers": {
    "example": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://xxxxxxxxxx.execute-api.eu-west-1.amazonaws.com/dev/mcp",
        "--transport",
        "http-only"
      ]
    }
  }
}

Deploy

Requirements:

Build project

sam build

Deploy the stack

sam deploy --profile <your AWS profile> --guided

Usage

Once the solution is installed, you can extend the MCP server with resources, prompts or tools using SSM parameters and Lambda functions. The SSM parameters must begin with the prefix /<project name>/<environment name>/, for example /mcp/dev/tools/echo.

As an example of integration you can take inspiration from the template: template.integration.yaml.

Resources

The SSM parameters must begin with prefix /<project name>/<environment name>/resources/, for example /mcp/dev/resources/example. The content must be in valid JSON format and have the properties:

  • name: Resource name
  • uri: Resource URI, for example "config://example"
  • content: Resource text content

It can be declared in a SAM template as:

ExampleResourceParameter:
  Type: AWS::SSM::Parameter
  Properties:
    Name: !Sub "/${Project}/${Environment}/resources/example"
    Type: String
    Value: |
      {
        "name": "example",
        "uri": "config://example",
        "content": "Just an example resource"
      }

Prompts

The SSM parameters must begin with prefix /<project name>/<environment name>/prompts/, for example /mcp/dev/prompts/echo. The content must be in valid JSON format and have the properties:

  • name: Prompt name
  • description: Prompt description
  • inputSchema.json: JSON schema
  • content: Prompt template content

The content template will be elaborate with ejs with input data interpolation.

It can be declared in a SAM template as:

EchoPromptParameter:
  Type: AWS::SSM::Parameter
  Properties:
    Name: !Sub "/${Project}/${Environment}/prompts/echo"
    Type: String
    Value: |
      {
        "name": "echo",
        "description": "Execute the example tool",
        "inputSchema": {
          "json": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              }
            },
            "required": ["message"]
          }
        },
        "content": "Execute the tool 'echo' with the message '<%= message %>'"
      }

Tools

The SSM parameters must begin with prefix /<project name>/<environment name>/tools/, for example /mcp/dev/tools/echo. The content must be in valid JSON format and have the properties:

  • name: Prompt name
  • description: Prompt description
  • inputSchema.json: JSON schema

The related Lambda function that will be executed must be name as <project name>-<environment name>-tools-<tool name>, for example mcp-dev-tools-echo. The function input and output must respect the Converse API pattern.

The parameter can be declared in a SAM template as:

EchoToolParameter:
  Type: AWS::SSM::Parameter
  Properties:
    Name: !Sub "/${Project}/${Environment}/tools/echo"
    Type: String
    Value: |
      {
        "name": "echo",
        "description": "Print the message provided in input",
        "inputSchema": {
          "json": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              }
            },
            "required": ["message"]
          }
        }
      }

The Lambda function implementation could be:

exports.handler = async ({ toolUseId, name, input }, context) => {
  return {
    name,
    toolUseId,
    status: 'success',
    content: [{
      text: input.message
    }]
  }
}

declared inline in a SAM template:

EchoToolFunction:
  Type: AWS::Serverless::Function
  Properties:
    FunctionName: !Sub "${Project}-${Environment}-tools-echo"
    Handler: index.handler
    InlineCode: |
      exports.handler = async ({ toolUseId, name, input }, context) => {
        return {
          name,
          toolUseId,
          status: 'success',
          content: [{
            text: input.message
          }]
        }
      }

Credits

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选