Repository navigation
Show and tell: Hardened Dockerfile & Compose Architecture for Containerized MCP Servers on AWS #4830
A7mdMe
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Disclosure: Maintainer of MCP Production Kit. Posting in Show and tell to share production containerization and security patterns for running Model Context Protocol (MCP) servers on AWS (ECS, App Runner, or EC2).
When moving MCP servers from local desktop experiments (Claude Desktop, Cursor) to AWS cloud hosting, several container security and network boundary concerns arise:
1. Hardened Multi-Stage Container Packaging
Containerized MCP servers should run without root privileges and with minimal layer bloat:
2. SSRF Protection Against Cloud Metadata (IMDS)
When an LLM agent is given a tool to fetch URLs or scrape endpoints, prompt injection can trick it into requesting internal AWS infrastructure:
169.254.169.254) and private VPC subnets (10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,127.0.0.1).3. Application-Level Database Query Safeguards
For database inspection tools (e.g. querying RDS PostgreSQL / Aurora), defense-in-depth requires application-level query sanitization:
--) and block (/* */) comments to prevent SQL injection evasion.SELECTorWITHand contain no destructive DDL/DML mutation keywords (DROP,DELETE,ALTER,UPDATE,TRUNCATE).(Note: Application-level query sanitization is an operational guardrail and should always be paired with PostgreSQL least-privilege read-only roles).
Free Open-Source Core vs. Turnkey Production Add-on
npm run start:sse)secure_http_fetchsecure_http_fetchpostgres_connector.tswith token sanitizerResources
Feedback from AWS teams deploying remote MCP tools on ECS, Fargate, or App Runner is very welcome!
All reactions