餐厅预订管理服务器

一个基于AWS基础设施的餐厅预订管理MCP服务器,提供ECS Fargate和Lambda部署选项,支持OAuth 2.0认证。

  • by Gyurmatag
  • 本地部署
  • 更新于
在 GitHub 查看 Gyurmatag/free-table-remote-mcp-aws

使用说明

在AWS上的FreeTable远程MCP服务器

部署在AWS基础设施上的餐厅预订管理模型上下文协议(MCP)服务器。该项目提供ECS Fargate和Lambda两种部署选项,并采用安全的OAuth 2.0认证。

🏗️ 建筑学

graph TB
    subgraph "Internet"
        U[Users/Clients]
        CF[CloudFront Distribution]
    end
    
    subgraph "AWS Global"
        WAF[WAF Protection]
        CF --> WAF
    end
    
    subgraph "AWS Region (us-east-1)"
        subgraph "VPC"
            subgraph "Public Subnets"
                ALB[Application Load Balancer]
                NAT[NAT Gateway]
            end
            
            subgraph "Private Subnets"
                ECS[ECS Fargate Cluster]
                LAMBDA[Lambda Functions]
            end
        end
        
        subgraph "Security & Auth"
            COGNITO[Cognito User Pool]
            IAM[IAM Roles & Policies]
        end
        
        subgraph "Monitoring"
            CW[CloudWatch Logs]
            S3[S3 Access Logs]
        end
        
        subgraph "External APIs"
            FT[FreeTable API<br/>free-table.gyurmatag.workers.dev]
        end
    end
    
    %% Connections
    U --> CF
    WAF --> ALB
    ALB --> ECS
    ALB --> LAMBDA
    ECS --> COGNITO
    LAMBDA --> COGNITO
    ECS --> FT
    LAMBDA --> FT
    ECS --> CW
    LAMBDA --> CW
    ALB --> S3
    ECS --> IAM
    LAMBDA --> IAM
    
    %% Styling
    classDef aws fill:#ff9900,stroke:#232f3e,stroke-width:2px,color:#fff
    classDef external fill:#00a86b,stroke:#232f3e,stroke-width:2px,color:#fff
    classDef compute fill:#4d148c,stroke:#232f3e,stroke-width:2px,color:#fff
    classDef security fill:#dd344c,stroke:#232f3e,stroke-width:2px,color:#fff
    
    class CF,WAF,ALB,ECS,LAMBDA,COGNITO,IAM,CW,S3,NAT aws
    class U,FT external
    class ECS,LAMBDA compute
    class COGNITO,IAM,WAF security

架构组件

  • VPC 栈带有公有/私有子网的虚拟私有云
  • 安全栈Cognito 用户池、WAF 规则和 IAM 角色
  • CloudFront-WAF 堆栈全球内容安全分发
  • MCP服务器堆栈ECS Fargate 和 Lambda MCP 服务器

数据流

sequenceDiagram
    participant C as MCP Client
    participant CF as CloudFront
    participant WAF as WAF
    participant ALB as Load Balancer
    participant MCP as MCP Server
    participant COG as Cognito
    participant FT as FreeTable API
    
    C->>CF: 1. MCP Request
    CF->>WAF: 2. Security Check
    WAF->>ALB: 3. Forward Request
    ALB->>MCP: 4. Route to ECS/Lambda
    
    MCP->>COG: 5. Validate OAuth Token
    COG-->>MCP: 6. Token Valid
    
    MCP->>FT: 7. API Call (get_restaurants/create_booking/update_booking)
    FT-->>MCP: 8. API Response
    
    MCP-->>ALB: 9. MCP Response
    ALB-->>CF: 10. Forward Response
    CF-->>C: 11. Return to Client

安全层

  1. **CloudFront(云前端)**具有DDoS防护的全球CDN
  2. WAF(Web Application Firewall)即网络应用防火墙带速率限制的Web应用防火墙
  3. **VPC(Virtual Private Cloud)的中文翻译是“虚拟私有云”**网络隔离和安全组
  4. **Cognito(可译为“认知”或根据上下文具体含义灵活翻译,此处保留原词以体现品牌或特定术语)**OAuth 2.0 认证和授权
  5. **IAM(独立审计师/认证审计师/身份与访问管理等,具体含义根据上下文而定)**最小权限访问控制

🚀 特点

MCP 服务器工具

  1. get_restaurants - 获取可用餐厅列表
  2. create_booking - 创建餐厅预订
  3. update_booking - 更新现有的餐厅预订信息

安全功能

  • OAuth 2.0 受保护资源元数据(RFC9728)
  • AWS WAF 保护
  • VPC隔离
  • IAM 最小权限访问
  • JWT令牌验证

📋 先决条件

  • AWS CLI(v2.0+)
  • Node.js(v14+)
  • AWS CDK(v2.0+)
  • Docker

🚀 快速入门

  1. 克隆仓库

    git clone https://github.com/yourusername/free-table-remote-mcp-aws.git
    cd free-table-remote-mcp-aws
    
  2. 安装依赖项

    cd guidance-for-deploying-model-context-protocol-servers-on-aws/source/cdk/ecs-and-lambda
    npm install
    
  3. 部署到AWS

    # Login to ECR
    aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
    
    # Deploy all stacks
    npx cdk deploy --all --require-approval never
    
  4. 测试部署

    # Get CloudFront URL
    CLOUDFRONT_URL=$(aws cloudformation describe-stacks \
      --stack-name MCP-Server \
      --query 'Stacks[0].Outputs[?OutputKey==`CloudFrontDistributions`].OutputValue' \
      --output text)
    
    # Test health endpoints
    curl "https://$CLOUDFRONT_URL/restaurant-booking/"
    curl "https://$CLOUDFRONT_URL/restaurant-booking-lambda/"
    

📚 文档

🛠️ 开发

项目结构

free-table-remote-mcp-aws/
├── guidance-for-deploying-model-context-protocol-servers-on-aws/
│   └── source/cdk/ecs-and-lambda/
│       ├── servers/
│       │   ├── sample-ecs-weather-streamablehttp-stateless-nodejs-express/
│       │   └── sample-lambda-weather-streamablehttp-stateless-nodejs-express/
│       ├── lib/
│       └── bin/
├── RESTAURANT_MCP_DEPLOYMENT_GUIDE.md
└── README.md

MCP服务器实现

MCP服务器是使用TypeScript实现的,采用 @modelcontextprotocol/sdk 并且与FreeTable API集成:

  • 基本URL: https://free-table.gyurmatag.workers.dev
  • 交通可流式传输的HTTP
  • 认证使用Cognito的OAuth 2.0

🔧 配置

环境变量

AWS_REGION=us-east-1
COGNITO_USER_POOL_ID=<from CloudFormation output>
COGNITO_USER_POOL_CLIENT_ID=<from CloudFormation output>
BASE_URL=https://<cloudfront-domain>

FreeTable API 集成

服务器与FreeTable API端点集成:

  • GET /api/restaurants - 列出餐厅
  • POST /api/bookings - 创建预订
  • PUT /api/bookings/{id} - 更新预订

💰 成本估算

月度成本(美国东部1区):

  • VPC(NAT网关):约$37.35
  • 应用负载均衡器:约16.83美元
  • CloudFront: 约87.96美元
  • WAF:约10.00美元
  • ECS Fargate:约36.04美元
  • Lambda:约0.20美元
  • 总计每月约194.18美元

🧹 清理

# Destroy all stacks
npx cdk destroy --all --force

📄 许可证

这个项目遵循MIT许可证授权——详见 许可证 文件中有详细信息。

🤝 贡献

  1. 为仓库创建分支(或“克隆仓库”)
  2. 创建一个特性分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add some amazing feature')
  4. 推送到分支(git push origin feature/amazing-feature)
  5. 提交一个拉取请求

📞 支持

  • 检查一下 部署指南 用于故障排除
  • 审查CloudFormation事件以排查部署问题
  • 检查 CloudWatch 日志中的运行时错误

🔗 相关链接