MCP server for auditing Terraform state files for security misconfigurations
Project description
mcp-tfstate-reader
A local Model Context Protocol (MCP) server that parses Terraform .tfstate files and lets AI agents audit enterprise infrastructure for security misconfigurations — without requiring direct cloud credentials.
Features
| Tool | Description |
|---|---|
list_resources |
Parse a .tfstate file and list every managed resource with its address and type |
audit_security |
Scan for common misconfigurations (see below) |
get_resource_detail |
Dump the full attributes of a specific resource by address |
Security checks in audit_security
- S3 — buckets without server-side encryption
- Security Groups — ingress rules open to
0.0.0.0/0on sensitive ports: 22 (SSH), 3389 (RDP), 5432 (PostgreSQL) - IAM — policies with wildcard
*actions (full admin access) - RDS — instances without
storage_encrypted = true - EC2 — instances with
associate_public_ip_address = true - CloudWatch — log groups without a retention policy
Requirements
- Python 3.10+
mcpSDK
Installation
git clone https://github.com/berkay-yildirim/mcp-tfstate-reader.git
cd mcp-tfstate-reader
make setup
Or install directly:
pip install mcp-tfstate-reader
Usage
Run the server
make start
# or
python -m mcp_tfstate_reader.server
The server communicates over stdio (standard input/output), which is the default MCP transport for local tools.
Use with a tfstate file
Point any of the three tools at a local .tfstate file path:
{
"tfstate_path": "/path/to/terraform.tfstate"
}
Claude Desktop integration
Add the following to your Claude Desktop MCP configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Option A — installed via pip
{
"mcpServers": {
"tfstate-reader": {
"command": "mcp-tfstate-reader"
}
}
}
Option B — from source (virtualenv)
{
"mcpServers": {
"tfstate-reader": {
"command": "/absolute/path/to/mcp-tfstate-reader/.venv/bin/python",
"args": ["-m", "mcp_tfstate_reader.server"]
}
}
}
Option C — with uvx (no install required)
{
"mcpServers": {
"tfstate-reader": {
"command": "uvx",
"args": ["mcp-tfstate-reader"]
}
}
}
Development
# Install with dev dependencies
make setup
# Run tests
make test
# Build distribution
make build
# Clean everything
make clean
Example interaction
Once connected to Claude Desktop, you can ask:
"Audit
/home/user/infra/prod/terraform.tfstatefor security issues."
Claude will call audit_security and return a structured list of findings like:
Found 4 finding(s):
[HIGH] aws_s3_bucket.assets: S3 bucket has no server-side encryption configuration.
[HIGH] aws_security_group.bastion: Security group allows 0.0.0.0/0 ingress on port 22.
[CRITICAL] aws_iam_policy.admin: IAM policy contains a wildcard (*) action — grants unrestricted permissions.
[HIGH] aws_db_instance.prod: RDS instance storage is not encrypted.
License
MIT © Berkay Yildirim
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_tfstate_reader-0.1.1.tar.gz.
File metadata
- Download URL: mcp_tfstate_reader-0.1.1.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28155a60c824c15c798f259c52c88aa603b4938175c5fe2c43b4e95dd2320028
|
|
| MD5 |
1b7abca7dd306a6188a6949973b65068
|
|
| BLAKE2b-256 |
d3c6598cd53fc4a4279dddaacca67da9e5054dcaa3610294b1c7b5fcacf79445
|
Provenance
The following attestation bundles were made for mcp_tfstate_reader-0.1.1.tar.gz:
Publisher:
release.yml on berkayyildirim/mcp-tfstate-reader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_tfstate_reader-0.1.1.tar.gz -
Subject digest:
28155a60c824c15c798f259c52c88aa603b4938175c5fe2c43b4e95dd2320028 - Sigstore transparency entry: 1006720873
- Sigstore integration time:
-
Permalink:
berkayyildirim/mcp-tfstate-reader@e6d4789f7ca170ae81e8afecb4e88e73b31ca885 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/berkayyildirim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e6d4789f7ca170ae81e8afecb4e88e73b31ca885 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mcp_tfstate_reader-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mcp_tfstate_reader-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33f2e4af7c67b12ba5067364059d7974f518c0ac99f3e4ef1c445c1d3df6c66c
|
|
| MD5 |
e377bae292218451f6598bb4c15cfa75
|
|
| BLAKE2b-256 |
730e99976f3bf525a66f2e29fb2f65d3bae710e930d9314e47d2daa1c887fd56
|
Provenance
The following attestation bundles were made for mcp_tfstate_reader-0.1.1-py3-none-any.whl:
Publisher:
release.yml on berkayyildirim/mcp-tfstate-reader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_tfstate_reader-0.1.1-py3-none-any.whl -
Subject digest:
33f2e4af7c67b12ba5067364059d7974f518c0ac99f3e4ef1c445c1d3df6c66c - Sigstore transparency entry: 1006720875
- Sigstore integration time:
-
Permalink:
berkayyildirim/mcp-tfstate-reader@e6d4789f7ca170ae81e8afecb4e88e73b31ca885 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/berkayyildirim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e6d4789f7ca170ae81e8afecb4e88e73b31ca885 -
Trigger Event:
push
-
Statement type: