AWS 安全服务
STDIOAI助手分析AWS基础设施安全的MCP服务器
AI助手分析AWS基础设施安全的MCP服务器
AWS Security MCP is a Model Context Protocol (MCP) server that enables AI assistants like Claude to interact with AWS security services. Think of it as a bridge that lets AI assistants directly inspect and analyze your AWS infrastructure for security issues, just by asking questions in plain English.
AWS Security MCP automatically discovers and accesses multiple AWS accounts using a smart approach:
aws organizations list-accounts
aws-security-mcp-cross-account-access
For each AWS account you want to access, create an IAM role with these specifications:
Role Name: aws-security-mcp-cross-account-access
Trust Policy:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::YOUR-MASTER-ACCOUNT-ID:root" }, "Action": "sts:AssumeRole" } ] }
Attached Policy: SecurityAudit
(AWS Managed Policy)
This setup allows the MCP server to securely access resources across all your AWS accounts with read-only security permissions.
This is the primary and recommended way to run AWS Security MCP. SSE provides better performance, stability, and compatibility with various MCP clients.
Configure your AWS Credentials:
AWS Security MCP automatically detects and uses AWS credentials from your ~/.aws/credentials, AWS_PROFILE, env variables or metadata endpoints.
Required IAM Permissions: Your default AWS profile/credentials must have the following permissions:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "CrossAccountAccess", "Effect": "Allow", "Action": [ "sts:AssumeRole" ], "Resource": [ "arn:aws:iam::*:role/aws-security-mcp-cross-account-access" ] } ] }
{ "Version": "2012-10-17", "Statement": [ { "Sid": "OrganizationAccess", "Effect": "Allow", "Action": [ "organizations:ListAccounts" ], "Resource": "*" } ] }
arn:aws:iam::aws:policy/SecurityAudit
Important: These permissions allow the default profile to discover organization accounts, assume cross-account roles, and perform security audits across your AWS infrastructure.
Security Note: At no point can the MCP Client retrieve AWS credentials. All credential handling is done securely by the MCP server, and only API responses are shared with the client.
Cross-Account Access: The system automatically discovers AWS Organization accounts and assumes the aws-security-mcp-cross-account-access
role where available.
Start the SSE Server locally:
# Navigate to the aws-security-mcp directory cd /path/to/aws-security-mcp # Start the SSE server python aws_security_mcp/main.py sse
Configure Your MCP Client:
For Claude Desktop with SSE:
First, install the mcp-proxy tool:
# Install mcp-proxy using uv uv tool install mcp-proxy # Find the absolute path of mcp-proxy (you'll need this for the config) which mcp-proxy # Example output: /Users/username/.local/bin/mcp-proxy
Then configure Claude Desktop:
{ "mcpServers": { "aws-security": { "command": "/Users/username/.local/bin/mcp-proxy", "args": ["http://localhost:8000/sse"] } } }
Important: Replace /Users/username/.local/bin/mcp-proxy
with the actual path from the which mcp-proxy
command above.
For Other MCP Clients:
http://localhost:8000/sse
http://localhost:8000/health
Note: This method is kept for backward compatibility but SSE is recommended.
Configure Claude Desktop with stdio:
{ "mcpServers": { "aws-security": { "command": "/full/path/to/aws-security-mcp/run_aws_security.sh", "args": ["stdio"] } } }
Direct File Edit Locations:
/Users/YOUR_USER/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
Restart Claude Desktop to load the new configuration
Test with MCP Inspector:
# Use the MCP Inspector to test the connection: npx @modelcontextprotocol/inspector http://127.0.0.1:8000/sse
Direct SSE Testing:
# Test the SSE endpoint directly: curl -N -H "Accept: text/event-stream" http://localhost:8000/sse
Health Check:
# Check server health: curl http://localhost:8000/health
Docker Deployment:
# Build the container: docker build -t aws-security-mcp . # Run with environment variables: docker run -p 8000:8000 \ -e AWS_ACCESS_KEY_ID=your_key \ -e AWS_SECRET_ACCESS_KEY=your_secret \ -e AWS_DEFAULT_REGION=us-east-1 \ aws-security-mcp
Environment Variables for SSE:
# Optional SSE configuration export MCP_HOST=0.0.0.0 # Bind to all interfaces export MCP_PORT=8000 # Server port export MCP_LOG_LEVEL=info # Logging level export MCP_DEBUG=false # Debug mode
When deploying behind a load balancer:
/health
/sse
/sse
to /sse/
Query: "Can you share connected AWS accounts?"
Response: The MCP tool will return a list of all AWS accounts in your organization that the server can access, including account IDs, names, and status.
Query: "Can you refresh my AWS session?"
Response: The MCP tool refreshes all valid boto3 sessions across multiple AWS accounts, ensuring you have the latest credentials and permissions.
Query: "Show me all EC2 instances across all accounts"
Query: "Find security groups with port 22 open to the internet"
Query: "List S3 buckets with public read access"
Query: "Show me GuardDuty findings from the last 7 days"
Query: "Generate a network map for my production environment"
Query: "What's the blast radius if the web-tier security group is compromised?"
AWS Security MCP has been optimized from 110+ individual tools to 38 core tools with nested functionality. This provides several benefits:
The 38 tools are organized into these categories:
Each tool can handle multiple related operations, providing the same functionality as the original 110+ tools but with better performance.
You can combine AWS Security MCP with other MCP servers for enhanced capabilities:
{ "mcpServers": { "aws-security": { "command": "/Users/username/.local/bin/mcp-proxy", "args": [ "http://localhost:8000/sse" ] }, "shodan": { "command": "npx", "args": ["@mcp/shodan"], "env": { "SHODAN_API_KEY": "your-shodan-key" } }, "brave-search": { "command": "npx", "args": ["@mcp/brave-search"], "env": { "BRAVE_API_KEY": "your-brave-key" } } } }
"No tools available" or empty tool list:
run_aws_security.sh
script is executableCross-account access not working:
aws-security-mcp-cross-account-access
role exists in target accountsMCP server crashes or memory errors:
Slow response times:
MCP Server Logs:
/Users/{userName}/Library/Logs/Claude
%APPDATA%\Claude\Logs
~/.local/share/Claude/Logs
Enable Debug Mode:
# Add to run_aws_security.sh export MCP_DEBUG=true export AWS_SDK_DEBUG=true
Test MCP Server Directly:
# Test the server without Claude python -m aws_security_mcp.server --transport stdio
This project is licensed under the MIT License - see the LICENSE file for details.