
amazonq_mcp_redshift
展示如何使用Python在AWS Lambda上部署无状态MCP服务器。
Repository Info
About This Server
展示如何使用Python在AWS Lambda上部署无状态MCP服务器。
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
Stateless MCP on AWS Lambda (Python)
This project demonstrates :
- How to deploy a stateless MCP (Message Control Protocol) server on AWS Lambda using Python. The implementation uses AWS API Gateway for HTTP endpoints and AWS Lambda for serverless execution.
- How to coordinate multiple MCP Tools using COT (Chain of Thought) for intelligent Redshift operations and maintenance
Architecture Overview
!System Architecture
!Workflow
Prerequisites
- AWS CLI configured with appropriate credentials
- Python 3.9+
- Make
- AWS SAM CLI
- Docker
#Take Aamzon Linux 2023 As an example
sudo su ec2-user
sudo yum install git -y
sudo yum install make
wget https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip
mv aws-sam-cli-linux-x86_64.zip ~/
cd
unzip aws-sam-cli-linux-x86_64.zip -d sam-installation
sudo ./sam-installation/install
sam --version
sudo yum install docker -y
sudo systemctl start docker
sudo gpasswd -a $USER docker
newgrp docker
Project Structure
/
├── cot_mcpserver/ # COT (Chain-of-Thought) MCP Server code
├── monitor_mcpserver/ # MCP Server code for retrieving Redshift monitoring metrics
├── redshift_mcpserver/ # MCP Server code for accessing Redshift
├── etc/ # Configuration files (such as environment variables, etc.)
├── iac/ # Infrastructure as Code (SAM templates, etc.)
├── layer/ # Lambda Layer dependencies and documentation
├── mcp_cli/ # Using Strands SDK, integrates Remote MCP with functionality similar to Q Developer CLI
├── README.md # Project documentation
├── makefile # Build and deployment commands
Configuration
Before deploying, you need to configure the environment variables in etc/environment.sh:
-
AWS Configuration:
PROFILE: Your AWS CLI profile nameBUCKET: S3 bucket name for deployment artifactsREGION: AWS region (default: us-east-1)
-
MCP Dependencies:
P_DESCRIPTION: MCP package version (default: "mcp==1.8.0")O_LAYER_ARN: This will be updated after creating the Lambda layer
-
API Gateway and Lambda Configuration:
P_API_STAGE: API Gateway stage name (default: dev)P_FN_MEMORY: Lambda function memory in MB (default: 128)P_FN_TIMEOUT: Lambda function timeout in seconds (default: 30)
Deployment Steps
-
Create the Lambda Layer:
make layerAfter execution, copy the
outLayervalue and update theO_LAYER_ARNinetc/environment.sh. -
Deploy the API Gateway and Lambda function:
make apigwThis will create the API Gateway and Lambda function, which will have the MCP dependencies layer attached.
-
After the API Gateway and Lambda have been created
- Lambda function mcp-redshift
- Enable vpc mode of Lambda function mcp-redshift, set VPC, Subnet and security group
- Modify the Env Variables , Set the host, port, database, user, password for the specified Redshift
- Lambda function mcp-cot
- Modify the Env Variables, set S3 Bucket and Object key for the Markdown Context and the region for the Bedrockm
- Lambda function mcp-monitor
- Modify the Env Variables, Set the Redshift Cluster name
- API Gateway
- Set API Key for all the methods in the API
Testing
- After deployment, you'll receive an
outApiEndpointvalue. - Using the Q Developer CLI to integrate the MCP Tools and Test them. vim .amazonq/mcp.json
{
"mcpServers":
{
"redshiftserver":
{
"command": "npx",
"args":
[
"mcp-remote",
"https://xxxx.execute-api.ap-southeast-1.amazonaws.com/dev/redshift/mcp/",
"--header",
"x-api-key: you api key of api gateway"
]
},
"cotserver":
{
"command": "npx",
"args":
[
"mcp-remote",
"https://xxxx.execute-api.ap-southeast-1.amazonaws.com/dev/cot/mcp/",
"--header",
"x-api-key: you api key of api gateway"
]
},
"monitorserver":
{
"command": "npx",
"args":
[
"mcp-remote",
"https://xxxx.execute-api.ap-southeast-1.amazonaws.com/dev/monitor/mcp/",
"--header",
"x-api-key: you api key of api gateway"
]
}
}
}
Make Commands
make layer: Creates the Lambda layer with MCP dependenciesmake apigw: Deploys the API Gateway and Lambda function
Troubleshooting
If you encounter any issues:
- Ensure all environment variables are properly set in
etc/environment.sh - Verify AWS credentials are correctly configured
- Check AWS CloudWatch logs for Lambda function errors
- Ensure the S3 bucket specified in
BUCKETexists and is accessible
Quick Start
Clone the repository
git clone https://github.com/chinapanpan/amazonq_mcp_redshiftInstall dependencies
cd amazonq_mcp_redshift
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.