infralens
An open-source MCP server that lets any AI agent discover cloud cost savings and catch reliability issues early, across AWS, Azure and Kubernetes. Read-only by design.
Plug clouds in on one side and AI clients on the other: Claude, ChatGPT, Cursor, or a local model through Ollama, all over the open Model Context Protocol. infralens discovers and explains; a human takes the suggested action.
📖 Documentation wiki · Getting started · Connect your AI · Safety model · Real-account results
Why
Every platform team has two opportunities hiding in plain sight:
- Cost savings waiting to be captured. Idle instances, unattached volumes, databases with zero connections, unused IPs, old snapshots. Give each one an owner and a one-line action, and the money comes back.
- Knowing first. Error rates creep up after a deploy; a disk fills over a week. Spot it early and answer "what changed?" in seconds instead of 40 minutes across consoles.
AI assistants can reason about this, but they can't see your infrastructure. infralens gives them safe, structured, read-only eyes, with one standard that works on every cloud and with every model.
What it discovers
| AWS | Azure (beta) | Kubernetes | |
|---|---|---|---|
| 💰 Cost savings | Idle EC2 and RDS, unattached EBS, unused Elastic IPs, old snapshots, long-stopped instances | Unattached disks, stopped-but-billing VMs, unused public IPs | Unmounted volume claims, Released volumes, LoadBalancers with no ready backends |
| 🛡️ Reliability alerts | Firing alarms, log error spikes vs. baseline | Fired alerts | CrashLoopBackOff, OOMKilled, pods stuck Pending, NotReady nodes |
| 🔎 "What changed?" | CloudTrail write events | Activity Log | Deployment rollouts |
| 🏷️ Ownership gaps | Missing owner / team / env tags |
Missing labels on workloads |
Every discovery has an estimated $/month, an owner (from tags), evidence and a ready-to-run action. Each one is tracked over time (new → open → acknowledged/suppressed → resolved), so the report shows only what changed, and resolved cost savings are counted as savings captured.
Tested on real infrastructure
AWS (real account, us-east-2). Planted 5 resources with demo/sandbox-tofu, then
scanned:
| Planted | Discovered |
|---|---|
| CloudWatch alarm in ALARM | ✅ reliability alert, traced to the PutMetricAlarm that created it |
| 60 errors in a log group | ✅ reliability alert with the actual log lines |
| Unused Elastic IP | ✅ $3.65/mo, with the release command |
| Unattached 20 GiB volume | ✅ $1.60/mo, owner read from tags |
| Untagged volume | ✅ ownership gap |
After tofu destroy, the next scan reported 5 resolved and $5.25/mo of cost savings captured. The run
also found two bugs that simulated data couldn't: CloudShell heartbeats being reported as "likely causes", and
misleading timing labels. Both are fixed, with regression tests built from the real events.
Kubernetes (real cluster in every CI run). CI creates a kind cluster, deploys
the deliberately broken demo/k8s namespace and scans it using only the read-only RBAC role:
7 of 7 discoveries, no false positives, and the crash loop traced to the rollout that caused it.
See it run
An AI client calling the MCP server (simulated AWS account, docker compose up):
The daily discoveries report. Note the likely cause pinned to the deploy that changed DB_POOL_MAX, and
the password masked in the log line:
Quick start
No cloud account needed:
git clone https://github.com/balakrishnagatla/infralens && cd infralens
pip install -e ".[aws]"
infralens scan # built-in demo environment
From PyPI: pip install "infralens-mcp[aws,k8s]", or as a container:
docker run -p 127.0.0.1:8080:8080 -e INFRALENS_API_TOKEN=... ghcr.io/balakrishnagatla/infralens:latest.
Or straight from GitHub: pip install "infralens-mcp[aws,k8s] @ git+https://github.com/balakrishnagatla/infralens".
Full local demo against a simulated AWS account (Docker only):
docker compose up --build -d # simulated AWS → seeded discoveries → MCP server on localhost:8080
python demo/mcp_client_demo.py http://localhost:8080/mcp change-me-local-demo # talk to it like an AI would
docker compose run --rm infralens scan
docker compose down # when done
Your own infrastructure (read-only):
INFRALENS_PROVIDERS=aws INFRALENS_REGIONS=us-east-1 infralens scan # uses your AWS credentials/profile
infralens -p kubernetes scan # uses your current kubeconfig context
Connect your AI
Claude Desktop (claude_desktop_config.json):
{ "mcpServers": { "infralens": { "command": "infralens", "args": ["serve"],
"env": { "INFRALENS_PROVIDERS": "aws", "AWS_PROFILE": "readonly" } } } }
Claude Code:
claude mcp add infralens -- infralens serve # local
claude mcp add --transport http infralens https://<your-host>/mcp \
--header "Authorization: Bearer $INFRALENS_API_TOKEN" # hosted
ChatGPT: host it (Deploy), then add the /mcp URL as a custom connector in Developer Mode.
Local models: Ollama isn't an MCP client itself, so put one in front of it, such as
ollmcp, Goose or Open WebUI, with a tool-capable model.
Then ask:
- "Where can we save money? Group it by team."
- "Why is payment-api failing? What changed right before it started?"
- "Search the payment-api logs for 'pool exhausted' in the last 30 minutes."
- "Suppress the snapshot finding; it's our legal-hold backup."
- "How much have we saved since we started using infralens?"
| MCP tool | Purpose |
|---|---|
scan |
All discoveries, plus what's new or resolved since the last scan |
find_cost_savings |
Cost savings opportunities with totals by team |
find_incidents |
Reliability alerts, each with suspected changes |
what_changed |
Deploys and write events in the last N hours |
search_logs |
Log search, secrets masked |
list_findings · acknowledge_finding · suppress_finding |
Triage. Changes infralens' own state, never the cloud |
savings_report |
Cost savings captured and still available |
list_providers |
Installed and enabled providers |
Plus the prompts morning_check and investigate(service).
Watch mode
infralens daily --model anthropic/claude-sonnet-5-5 --github-repo you/ops-reports # or openai/..., ollama/...
Scans, asks any LLM (via LiteLLM) for a short triage summary, and publishes the report to a file, a GitHub Issue or Slack. The report still ships if the LLM is unavailable. Schedule it with Lambda + EventBridge (included in the OpenTofu module), GitHub Actions (OIDC, no stored keys) or cron.
Deploy
- AWS:
deploy/aws(OpenTofu) creates the MCP server on App Runner (HTTPS + bearer token from Secrets Manager), the daily Lambda + EventBridge Scheduler, an encrypted state bucket and a least-privilege read-only IAM policy (shared module, with an explicit Deny on data reads). - Kubernetes:
deploy/kubernetes/rbac.yamlis a read-only ClusterRole (get/listonly). - Container: non-root, multi-arch image
ghcr.io/balakrishnagatla/infralens(with SBOM and provenance), published on every release.
Safety model
- Read-only. Providers only call describe/list/get APIs, and the shipped IAM policy and RBAC role enforce it. CI proves the Kubernetes role can't delete anything.
- Suggest, never apply. Actions are returned as commands for a human to run.
- Secrets never reach the AI. Passwords, tokens, keys, JWTs and connection strings are masked in evidence, log results and LLM prompts.
- Everything is audited. Every tool call is written to
~/.infralens/audit.jsonl. - Locked-down HTTP. Refuses to start without a token, compares it in constant time, and binds to
127.0.0.1unless told otherwise. - Supply chain. CodeQL, Bandit, pip-audit and Trivy on every PR; third-party Actions pinned to commit SHAs;
Dependabot; protected
main. See SECURITY.md.
Configuration
Teams tune behaviour in infralens.yaml (example) without code changes: idle
thresholds, error-spike sensitivity, the "what changed?" window, required tags, tag-based ignore rules
(env: sandbox is ignored by default), namespaces, and price overrides.
Contributing
Adding a cloud means implementing four read-only methods that return standard discoveries:
class GCPProvider(Provider):
name = "gcp"
def find_cost_savings(self): ... # -> list[Finding]
def find_incidents(self): ... # -> list[Finding]
def recent_changes(self, since): ... # -> list[Change]
def list_resources(self): ... # optional, for ownership gaps
See CONTRIBUTING.md and the wiki's Adding a provider page. A GCP provider is a great first PR.
pip install -e ".[aws,k8s,dev]" && pytest -q && ruff check src tests demo
Roadmap
- AWS, Azure (beta) and Kubernetes providers
- MCP over stdio and Streamable HTTP; watch mode; OpenTofu deploy
- Tested on a real AWS account and a real Kubernetes cluster
- Multi-account AWS (assume a read-only role per account)
- OAuth 2.1 for the hosted MCP server
- Actual costs from Cost Explorer / Azure Cost Management alongside list-price estimates
- GCP provider · Kubernetes idle workloads from metrics-server
Costs are on-demand list-price estimates for ranking opportunities, not invoices. MIT licensed.
Metadata
Release files for infralens-mcp 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| infralens_mcp-0.2.0.tar.gz | 1.1 MB | With provenance | Details for infralens_mcp-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| infralens_mcp-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for infralens_mcp-0.2.0-py3-none-any.whl |
Total release size: 1.2 MB
Release files / infralens_mcp-0.2.0.tar.gz
| Download URL | infralens_mcp-0.2.0.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28030eaadf00825be5bdece99317bdcc1af8ef59665ec8debcf02bec56615869
|
|
BLAKE2b-256 checksum How to use checksums |
42799c9d2dd3b16830075b9884014afd5c513c78d9b73bba21607075bc522110
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / infralens_mcp-0.2.0-py3-none-any.whl
| Download URL | infralens_mcp-0.2.0-py3-none-any.whl |
|---|---|
| Size | 47.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5f272866bd2102a27dbe96d9eea2f91cee2db2821e3d03d480e80b6a8801eb89
|
|
BLAKE2b-256 checksum How to use checksums |
56b5151b1b71d4dc188a285085570141d299ab4ebbe54f68695950e398c63400
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for infralens-mcp 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for infralens_mcp-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.