# Environment Variable Usage Auditor MCP for AI Agents MCP

> Environment Variable Usage Auditor MCP helps you find and fix discrepancies between your application code and your configuration files. It scans your .env, docker-compose.yml, or Kubernetes ConfigMaps to identify missing keys in your environment setup and unused variables declared in your configuration. This prevents production crashes caused by configuration errors.

## Overview
- **Category:** security
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_Z2JEnF7s23UACpfnJgUdNSc7xX3d1ATvjzSLO4Je/mcp
- **Tags:** env, dotenv, audit, kubernetes, docker

## Description

Keeping your application's environment variables in sync is a constant headache for any developer or DevOps engineer. You might have a variable declared in your .env file, but it's no longer used anywhere in your source code, leaving behind dead configuration that clutters your setup. Even worse, you's find 'ghost variables'—keys that your application code expects to even run, but which are completely missing from your deployment environment or Docker containers. These mismariesches can lead to production crashes and difficult-to-debug runtime errors. This MCP allows your AI agent to act as a configuration auditor. It scans your files to see exactly what is being used versus what is actually declared. By connecting this MCP through the Vinkius catalog, you can automate the tedious process of manual checks. You'll stop guessing which variables are safe to delete and start ensuring that every key in your deployment environment matches exactly what your application expects.

## Tools

### audit_consistency
Compares your declared environment variables against the keys used in your source code to find mismatches.

### extract_keys
Reads through files like .env or docker-compose.yml to pull out all defined variable names.

### extract_used_keys
Scans your application source code to find every instance where an environment variable is being called.

## Prompt Examples

**Prompt:** 
```
Are my environment variables consistent for this project?
```

**Response:** 
```
The audit is complete. All declared keys match the used keys with no discrepancies found.

| Status | Details |
| :--- | :--- |
| **Consistency** | **True** |
| **Discrepancies** | **None** |
```

**Prompt:** 
```
Extract all variable names from this .env content: 'PORT=3000\nDB_URL=postgres://localhost'
```

**Response:** 
```
The extracted keys are:

* `PORT`
* `DB_URL`
```

**Prompt:** 
```
Can you audit my .env file against my code?
```

**Response:** 
```
I've analyzed your configuration and source code. Here is the breakdown of what I found:

### Audit Results
- **Missing Keys:** `DATABASE_URL` (Found in code, but not in .env)
- **Unused Keys:** `STRIPE_API_KEY`, `API_SECRET` (Found in .env, but not used in code)

Please update your configuration files to ensure parity.
```

## Capabilities

### Identify missing keys
Finds variables used in code but not present in your configuration files.

### Identify unused keys
formats and identifies variables declared in .env or Docker files but never actually called in your source code.

###  , 
undefined

### Generate parity reports
Creates a complete comparison between your environment setup and your application's requirements.

## Use Cases

### Cleaning up a legacy codebase
A developer has a massive .env file with dozens of unused keys. They ask their agent to find which ones are safe to delete without breaking the application.

### Migryating to Kubernetes
s DevOps engineer is moving from Docker Compose to K8s ConfigMaps. They use this MCP to ensure all necessary variables are present in the new setup.

### undefined
undefined

### Checking a CI/CD pipeline step
A developer wants to automate a configuration audit as part of their build process, using the agent to identify any missing keys in a new branch.

## Benefits

- Eliminate production crashes by catching missing keys before they reach your deployment pipeline.
- Clean up dead configuration in your .env or Docker setup using extract_keys to find unused entries.
- Stop manual auditing of large projects by letting your agent use audit_consistency to verify parity between files.
- Reduce technical debt by identifying variables that are no longer referenced in your source code via extract_used_keys.
- Improve deployment reliability by ensuring every key required by your application is present in your environment setup.

## How It Works

The bottom line is you'll have a single, verified truth for your configuration management.

1. Point your AI agent to the configuration files like .env or docker-compose.yml.
2. The agent uses the MCP to scan your source code for any environment variable references.
3. You get a clear report showing exactly which keys are an exact match and where the discrepancies exist.

## Frequently Asked Questions

**How can I use Environment Variable Usage Auditor to find missing keys?**
You simply point your agent to your .env or Docker files and ask it to check for any variables used in code but not present in your configuration. The agent uses the MCP to scan both files and report the mismatches.

**Can Environment Variable Usage Auditor work with Kubernetes ConfigMaps?**
Yes, this MCP can audit your Kubernetes ConfigMaps against your source code. It identifies any keys that are declared in your configuration but not used, or keys required by the code but missing from the setup.

**How do I find unused variables using Environment Variable Usage Auditor?**
The agent scans your configuration files for all declared keys and then compares them against the list of keys extracted from your application's source code. Any key found in your .env but not in your code is flagged as an unneeded variable.

**s Environment Variable Usage Auditor reliable for large projects?**
It's highly reliable because it doesn't rely on manual checks. The agent uses the MCP to scan every file and extract all keys, providing a complete and automated audit of your configuration management.

**s Environment Variable Usage Auditor useful for checking .env files?**
It's perfect for this MCP. It identifies both 'ghost variables' that your code expects but are are missing from your .env file, and 'dead configuration' that unused keys are present in your .env file.

**What files does the auditor scan for declarations?**
It scans files like `.env`, `.env.example`, `docker-compose.yml`, and Kubernetes ConfigMaps using the `extract_keys` tool.

**How can I find variables used in my TypeScript code?**
Use the `extract_used_keys` tool by providing the contents of your `.ts` or `.js` files.

**What does a 'missing' variable mean?**
A missing variable is one that your code attempts to access (e.g., `process.env.API_KEY`) but which was not found in any of your declaration files.