AWS AppRunner MCP Server
A boilerplate TypeScript MCP server with Express.js designed for AWS AppRunner deployment. Provides sample tools, resources, and prompts with Docker containerization and GitHub Actions CI/CD workflow.
README
MCP Server for AWS AppRunner
A boilerplate Model Context Protocol (MCP) server implementation using TypeScript, Express.js, and the @modelcontextprotocol/sdk. This server is designed to be deployed to AWS AppRunner.
Overview
This server implements the Model Context Protocol, enabling AI assistants and applications to securely connect to external tools, data sources, and resources. The server provides:
- Tool Integration: Define and expose tools that AI can use to perform actions
- Resource Access: Control access to files and other resources
- Prompt Templates: Provide standardized prompt templates for consistent interactions
Features
- MCP Server implementation with TypeScript and Express.js
- Streamable HTTP transport supporting both JSON-RPC and SSE
- Sample tools, resources, and prompts
- AWS AppRunner deployment configuration
- Docker containerization with production and development configurations
- Docker Compose for local development with hot reloading
- GitHub Actions CI/CD workflow
- Environment configuration management
- Structured logging with Pino
- MCP Inspector integration for testing and debugging
Requirements
- Node.js 20+
- npm or yarn
- Docker (for containerization)
- Docker Compose (for local development)
- AWS account (for deployment)
Getting Started
Installation
-
Clone this repository:
git clone https://github.com/yourusername/mcp-server.git cd mcp-server -
Install dependencies:
npm install -
Create a
.envfile based on the example:cp .env.example .env
Development
Local Development
-
Start the development server:
npm run dev -
The server will be available at http://localhost:3000
Docker Compose Development (Recommended)
This method provides a consistent development environment with hot reloading:
-
Optional: Configure npm registry for development:
The project is configured to work with both public and private npm registries:
- Using public registry (default): No action needed.
- Using private/corporate registry: Create a
.npmrcfile in the project root with your registry configuration:registry=https://your-private-registry.com/ strict-ssl=true|false
-
Start the Docker development environment:
docker-compose up -d -
View logs in real-time:
docker-compose logs -f -
The server will be available at http://localhost:3000
-
Changes to source files will be automatically reflected in the running container thanks to volume mounts and hot reloading
-
Stop the development container:
docker-compose down
Using the Makefile
This project includes a Makefile to simplify common development tasks:
-
Start the MCP server with Docker Compose:
make mcp -
Start the MCP Inspector for testing and debugging:
make inspector -
Start both the MCP server and Inspector together:
make start -
Start both services using Docker Compose:
make compose -
Stop all running containers:
make stop -
Clean up containers and images:
make clean
Using the MCP Inspector
The MCP Inspector is a tool for testing and debugging MCP implementations:
-
Start the Inspector using one of these methods:
# Stand-alone Inspector make inspector # Both MCP server and Inspector with Docker Compose make compose -
Access the Inspector web UI at http://localhost:6274
-
Connect to your local MCP server at http://localhost:3000
-
Use the Inspector to:
- Test MCP initialization and session management
- Discover available tools, resources, and prompts
- Make tool calls and view responses
- Debug protocol communication issues
Testing Your MCP Server
You can test the MCP server using cURL:
# Health check
curl http://localhost:3000/health
# Initialize MCP connection (POST request)
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{},"protocolVersion":"1.0"},"id":1}'
# After initialization, use the returned Mcp-Session-Id for subsequent requests
# Example (replace SESSION_ID with the actual session ID from the response):
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-H "Mcp-Session-Id: SESSION_ID" \
-d '{"jsonrpc":"2.0","method":"tool/call","params":{"name":"tool-name","args":{}},"id":2}'
# Connect to SSE stream (GET request) with session ID
curl -N http://localhost:3000/mcp -H "Mcp-Session-Id: SESSION_ID"
# Terminate session (DELETE request)
curl -X DELETE http://localhost:3000/mcp -H "Mcp-Session-Id: SESSION_ID"
Project Structure
├── src/
│ ├── mcp/ # MCP implementation
│ │ ├── tools.ts # Tool handlers
│ │ ├── resources.ts # Resource handlers
│ │ ├── prompts.ts # Prompt handlers
│ │ └── server.ts # MCP server setup with Streamable HTTP transport
│ ├── utils/ # Utilities
│ │ ├── config.ts # Configuration
│ │ └── logger.ts # Logging
│ ├── app.ts # Express app setup
│ └── index.ts # Application entry point
├── Dockerfile # Production Docker configuration
├── Dockerfile.dev # Development Docker configuration with hot reloading
├── docker-compose.yml # Docker Compose for local development
├── apprunner.yaml # AWS AppRunner configuration
├── Makefile # Makefile with development commands
├── .github/ # GitHub Actions workflows
├── CLAUDE.md # Implementation notes and guidance for Claude Code
└── ... # Project configuration files
Docker Configuration
The project includes two Docker configurations:
Development Docker (Dockerfile.dev)
- Based on Node.js 20 Alpine
- Supports both public and private npm registries
- Mounts source code for hot reloading
- Uses tsx for TypeScript execution without compilation
- Configured to work with or without an
.npmrcfile
Production Docker (Dockerfile)
- Multi-stage build for optimized image size
- First stage builds the TypeScript application
- Second stage contains only the compiled JavaScript and production dependencies
- Uses public npm registry for AWS AppRunner deployment
- Optimized for security and performance
Deployment to AWS AppRunner
Prerequisites
- AWS account with appropriate permissions
- AWS CLI configured
- ECR repository created for the container image
- AppRunner service role with permissions to pull from ECR
Manual Deployment
-
Build and tag the Docker image:
docker build -t your-ecr-repo/mcp-server:latest . -
Push the image to ECR:
aws ecr get-login-password --region your-region | docker login --username AWS --password-stdin your-account-id.dkr.ecr.your-region.amazonaws.com docker push your-ecr-repo/mcp-server:latest -
Create or update the AppRunner service:
aws apprunner create-service --cli-input-json file://apprunner-config.json
GitHub Actions Deployment
This repository includes a GitHub Actions workflow in .github/workflows/deploy.yml that automates the deployment process when you push to the main branch.
To use it, set up the following GitHub secrets:
AWS_ACCESS_KEY_ID: AWS access key with appropriate permissionsAWS_SECRET_ACCESS_KEY: AWS secret access keyAWS_REGION: AWS region for deploymentECR_REPOSITORY: Name of your ECR repositoryAPPRUNNER_SERVICE: Name of your AppRunner serviceAPPRUNNER_SERVICE_ROLE_ARN: ARN of the service role for AppRunner
Customization
Adding New Tools
Edit src/mcp/tools.ts to add new tool definitions and handlers:
// Add to tool list
{
name: 'your-tool-name',
description: 'Description of your tool',
inputSchema: yourToolSchema
}
// Add to tool call handler
case 'your-tool-name':
return {
content: [
{
type: 'text',
text: `Result from your tool with args: ${JSON.stringify(args)}`
}
]
};
Adding New Resources
Edit src/mcp/resources.ts to add new resource definitions and content.
Adding New Prompts
Edit src/mcp/prompts.ts to add new prompt templates.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。