Cloud Infrastructure Auditor MCP Guide
Run automated cloud configuration security audits. Identify leaky S3 buckets, open security group ports, and loose IAM profiles directly from your IDE.
Generate & Validate Multi-Client MCP Config
One-click export with environment variables & path locators for Claude Desktop, Cursor, Windsurf, and OpenAI Codex CLI.
Cloud Infrastructure Auditor MCP Guide
Maintaining cloud security posture across sprawling AWS and GCP environments requires continuous verification against industry baselines such as CIS Benchmarks, SOC 2, and HIPAA. DevSecOps engineers often spend excessive time manually navigating cloud web consoles, running cross-region CLI inspection commands, and cross-referencing security group rules against IP CIDR blocks to ensure sensitive databases are not publicly exposed.
By connecting cloud provider auditing SDKs directly to the Model Context Protocol (MCP), organizations can provide AI assistants in Claude Desktop, Cursor, or OpenAI Codex CLI with structured, read-only security inspection tools. Agents can proactively identify unencrypted storage buckets, detect open ingress ports (such as SSH 0.0.0.0/0), and flag stale IAM credentials.
However, granting cloud API access to generative language models introduces serious security risks if permissions are overly permissive. An agent must never possess write or mutation capabilities that could accidentally terminate instances or alter network access control lists.
This guide provides an end-to-end architectural manual, multi-client configurations, a production TypeScript MCP server using the AWS SDK v3, JSON-RPC wire frames, and compliance guardrails for cloud auditing.
1. System Architecture: Read-Only Cloud Security Gates
The Cloud Infrastructure Auditor MCP server operates as an unprivileged, read-only inspection gateway between the AI host application and cloud provider control planes.
Essential Security Guardrails
- ▸Strict Managed Policy Scoping: The server credentials must be bound exclusively to the AWS-managed
SecurityAuditpolicy or an equivalent GCP viewer role. Never supplyAdministratorAccessor power-user credentials. - ▸Ephemeral STS Sessions: Avoid provisioning permanent, long-lived access key pairs. Instead, use AWS Security Token Service (STS) or IAM Identity Center to generate temporary credentials that expire automatically after one hour.
- ▸Structured Finding Serialization: Raw AWS API responses contain deep metadata trees, pagination markers, and internal ARNs. The MCP server extracts only actionable vulnerability signals (e.g., bucket name, public access block status, open CIDR ranges) to protect the agent context window.
2. Environment Prerequisites and Software Matrix
Verify that your system satisfies the following runtime requirements:
| Component | Minimum Version | Installation Verification | Purpose |
|---|---|---|---|
| Node.js | >= 20.0.0 | node -v | Server runtime environment |
| AWS CLI | >= 2.15.0 | aws --version | Authentication and credential verification |
| @aws-sdk/client-s3 | >= 3.650.0 | Package manifest | AWS SDK v3 S3 client module |
| @aws-sdk/client-ec2 | >= 3.650.0 | Package manifest | AWS SDK v3 EC2 client module |
| @modelcontextprotocol/sdk | >= 1.2.0 | Package manifest | Core Model Context Protocol framework |
Verify your active AWS authentication identity:
aws sts get-caller-identity3. Creating a Hardened Read-Only IAM Auditor Role
Provision an unprivileged IAM user or role attached strictly to the AWS SecurityAudit managed policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowSecurityAuditReadOnly",
"Effect": "Allow",
"Action": [
"s3:GetBucketPublicAccessBlock",
"s3:GetBucketPolicyStatus",
"s3:ListAllMyBuckets",
"ec2:DescribeSecurityGroups",
"iam:ListUsers",
"iam:ListAccessKeys"
],
"Resource": "*"
}
]
}4. Multi-Host Configuration Snippets
Configure your MCP clients to launch the auditor server over standard input and output (stdio). Pass temporary credentials or profile names through environment variables.
Claude Desktop Configuration (claude_desktop_config.json)
{
"mcpServers": {
"cloud-auditor": {
"command": "node",
"args": ["/opt/mcp-servers/cloud-auditor/dist/index.js"],
"env": {
"AWS_REGION": "us-east-1",
"AWS_PROFILE": "security-auditor-profile"
}
}
}
}Cursor IDE Configuration (.cursor/mcp.json)
{
"mcpServers": {
"cloud-auditor": {
"command": "node",
"args": ["./dist/index.js"],
"env": {
"AWS_REGION": "us-east-1"
}
}
}
}OpenAI Codex CLI Configuration (~/.codex/config.toml)
[mcp_servers.cloud_auditor]
command = "node"
args = ["/opt/mcp-servers/cloud-auditor/dist/index.js"]
[mcp_servers.cloud_auditor.env]
AWS_REGION = "us-east-1"
AWS_PROFILE = "security-auditor-profile"5. Production TypeScript Cloud Auditor MCP Server
The following server implementation exposes three core audit tools: audit_s3_public_access, audit_ec2_security_groups, and audit_iam_key_rotation. Save this as src/index.ts:
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
import { S3Client, ListBucketsCommand, GetPublicAccessBlockCommand } from '@aws-sdk/client-s3';
import { EC2Client, DescribeSecurityGroupsCommand } from '@aws-sdk/client-ec2';
import { IAMClient, ListUsersCommand, ListAccessKeysCommand } from '@aws-sdk/client-iam';
const region = process.env.AWS_REGION || 'us-east-1';
const s3 = new S3Client({ region });
const ec2 = new EC2Client({ region });
const iam = new IAMClient({ region });
const server = new Server(
{ name: 'cloud-infrastructure-auditor-mcp', version: '1.0.0' },
{ capabilities: { tools: {} } }
);
server.setRequestHandler(ListToolsRequestSchema, async () => {
return {
tools: [
{
name: 'audit_s3_public_access',
description: 'Audit S3 buckets in account to identify missing Public Access Blocks or public exposure.',
inputSchema: { type: 'object', properties: {} }
},
{
name: 'audit_ec2_security_groups',
description: 'Audit EC2 security groups for open ingress rules from 0.0.0.0/0 on sensitive ports (SSH 22, RDP 3389, DB 5432).',
inputSchema: { type: 'object', properties: {} }
},
{
name: 'audit_iam_key_rotation',
description: 'Inspect active IAM user access keys to flag credentials older than 90 days.',
inputSchema: { type: 'object', properties: {} }
}
]
};
});
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name } = request.params;
try {
if (name === 'audit_s3_public_access') {
const { Buckets = [] } = await s3.send(new ListBucketsCommand({}));
const findings = [];
for (const bucket of Buckets.slice(0, 20)) {
try {
const block = await s3.send(new GetPublicAccessBlockCommand({ Bucket: bucket.Name }));
const conf = block.PublicAccessBlockConfiguration;
const isFullyProtected = conf?.BlockPublicAcls && conf?.BlockPublicPolicy && conf?.IgnorePublicAcls && conf?.RestrictPublicBuckets;
if (!isFullyProtected) {
findings.push({ bucket: bucket.Name, status: 'VULNERABLE: Public access block incomplete' });
}
} catch (err: any) {
findings.push({ bucket: bucket.Name, status: 'WARNING: No public access block configured' });
}
}
return {
content: [{ type: 'text', text: JSON.stringify(findings, null, 2) }]
};
}
if (name === 'audit_ec2_security_groups') {
const { SecurityGroups = [] } = await ec2.send(new DescribeSecurityGroupsCommand({}));
const openRules: any[] = [];
for (const sg of SecurityGroups) {
for (const rule of sg.IpPermissions || []) {
const hasGlobalIngress = rule.IpRanges?.some(range => range.CidrIp === '0.0.0.0/0');
if (hasGlobalIngress) {
openRules.push({
groupId: sg.GroupId,
groupName: sg.GroupName,
fromPort: rule.FromPort,
toPort: rule.ToPort,
protocol: rule.IpProtocol,
risk: (rule.FromPort === 22 || rule.FromPort === 3389) ? 'CRITICAL: Open Management Port' : 'MEDIUM'
});
}
}
}
return {
content: [{ type: 'text', text: JSON.stringify(openRules, null, 2) }]
};
}
if (name === 'audit_iam_key_rotation') {
const { Users = [] } = await iam.send(new ListUsersCommand({ MaxItems: 25 }));
const staleKeys = [];
const now = Date.now();
const ninetyDaysMs = 90 * 24 * 60 * 60 * 1000;
for (const user of Users) {
const { AccessKeyMetadata = [] } = await iam.send(new ListAccessKeysCommand({ UserName: user.UserName }));
for (const key of AccessKeyMetadata) {
if (key.Status === 'Active' && key.CreateDate) {
const ageMs = now - new Date(key.CreateDate).getTime();
if (ageMs > ninetyDaysMs) {
staleKeys.push({
user: user.UserName,
keyId: key.AccessKeyId,
ageDays: Math.floor(ageMs / (24 * 60 * 60 * 1000))
});
}
}
}
}
return {
content: [{ type: 'text', text: JSON.stringify(staleKeys, null, 2) }]
};
}
throw new Error(`Tool '${name}' is not recognized.`);
} catch (err: any) {
return {
isError: true,
content: [{ type: 'text', text: `AWS Audit Error: ${err.message}` }]
};
}
});
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
}
main().catch((err) => {
process.stderr.write(`Fatal auditor error: ${err.message}\n`);
process.exit(1);
});6. JSON-RPC 2.0 Wire Payloads
Verifying JSON-RPC communication frames confirms proper parameter and response handling.
Tool Invocation Request (tools/call)
{
"jsonrpc": "2.0",
"id": "audit-sg-01",
"method": "tools/call",
"params": {
"name": "audit_ec2_security_groups",
"arguments": {}
}
}Result Payload
{
"jsonrpc": "2.0",
"id": "audit-sg-01",
"result": {
"content": [
{
"type": "text",
"text": "[\n {\n \"groupId\": \"sg-04a18f29e19\",\n \"groupName\": \"bastion-host-sg\",\n \"fromPort\": 22,\n \"toPort\": 22,\n \"protocol\": \"tcp\",\n \"risk\": \"CRITICAL: Open Management Port\"\n }\n]"
}
]
}
}7. Common Errors and Production Troubleshooting
When conducting cloud compliance scans through autonomous AI tools, prepare for the following operational challenges:
Error: AccessDenied: User is not authorized to perform: ...
- ▸Root Cause: The unprivileged IAM user lacks specific read permissions for the requested service (e.g.,
s3:GetBucketPublicAccessBlock). - ▸Resolution: Attach the AWS-managed
SecurityAuditpolicy to the IAM user or role rather than attempting to handcraft individual IAM statements.
Error: ExpiredToken: The security token included in the request is expired
- ▸Root Cause: Temporary credentials obtained via AWS STS or AWS SSO have exceeded their 1-hour time-to-live.
- ▸Resolution: Re-authenticate your terminal session using
aws sso loginor refresh your temporary session credentials.
API Rate Throttling (RequestLimitExceeded)
- ▸Root Cause: An agent issued dozens of rapid queries across multiple AWS regions simultaneously.
- ▸Resolution: Scope audit tools to explicit single regions (e.g.
us-east-1) and incorporate exponential backoff in client handlers.
8. External Citations and Security Guardrails
Cloud infrastructure auditing must be conducted within rigorous compliance guardrails:
- ▸Prevent Modification Privileges: Under no circumstances should the MCP auditor server possess
UpdateSecurityGroupRuleorDeleteBucketpermissions. Remediations should always be applied via audited infrastructure-as-code (Terraform, Pulumi) pipelines. - ▸Official Standards and Repositories:
Weekly Protocol Diffs & Verified Drops
New server guides, benchmarks, and security audits. No spam. Unsubscribe anytime.
Zero marketing spam. 1-click unsubscribe anytime.
Build your full agent toolstack in the Visual Generator
Combine Cloud Infrastructure Auditor MCP Guide with databases, search APIs, and memory graphs in a single configuration file.
Did this setup guide work with your AI host?
Help test this configuration across Claude, Cursor, and Codex CLI. Be the first to report:
Cloud Infrastructure Auditor MCP Guide FAQ
What is the Cloud Infrastructure Auditor MCP Guide?
Run automated cloud configuration security audits. Identify leaky S3 buckets, open security group ports, and loose IAM profiles directly from your IDE.
How do I configure Cloud Infrastructure Auditor MCP Guide in Claude Desktop or Cursor?
You can copy the configuration JSON from our guide or launch the interactive MCP Codex Config Generator at https://mcp-codex.com/generator to export valid configs in 1 click.
Can I use Cloud Infrastructure Auditor MCP Guide with the OpenAI Codex CLI?
Yes, OpenAI Codex CLI supports Model Context Protocol. You can add it directly to ~/.codex/config.toml or pass arguments to codex mcp add.
Specializing in Model Context Protocol (MCP) integrations, autonomous AI agent orchestration, and distributed developer toolchains. Researches and benchmarks production MCP client-server architectures across OpenAI Codex, Claude, and Cursor.
Related Guides
Kubernetes and Helm MCP Server Guide
Connect your Kubernetes clusters and Helm releases to AI agents via MCP. Run safe container diagnostics, view cluster logs, and perform rollbacks.
Cloud ServicesNotion MCP Server Setup for Codex & Claude | Search, Create, Update Pages
Integrate Notion with OpenAI Codex & Claude. Query databases, create pages, update content via MCP. Includes Notion API token setup, config.toml example, and tool reference (search_pages, create_page, update_page).
Cloud ServicesHow to Use the Google Drive MCP Server for Document Access
Connect Google Drive to your AI agent for searching, reading, and managing documents, spreadsheets, and files stored in your Drive.