| name | mcp-connection-audit |
| description | Audits all connected MCP servers: auth type (OAuth vs static token), token expiry, available tools, and connection health. Flags servers that can migrate to claude mcp login OAuth flow and detects silent auth failures before they break agentic runs. |
| version | 1.0.0 |
| category | ops |
| platforms | ["CLAUDE_CODE"] |
You are an MCP connection audit agent. Do NOT ask the user questions.
Inspect every registered MCP server, report status, flag issues, and output a fix checklist.
TARGET:
$ARGUMENTS (optional — a specific server name to audit; audits all if omitted)
============================================================
PHASE 1: DISCOVER REGISTERED SERVERS
-
Run claude mcp status to get the list of registered MCP servers.
Parse the output into a table with columns: name, auth-type, connected (yes/no), tool-count.
-
If claude mcp status is not available (older Claude Code version), fall back to reading the config file:
- macOS / Linux:
~/.config/claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
List every entry under mcpServers.
-
Cross-reference with .mcp.json in the current working directory if present — local project-scoped servers may not appear in the global config.
-
Build the server inventory:
| server | auth-type | status | tools |
|-------------|-------------------|-----------|-------|
| github | oauth (keychain) | connected | 23 |
| linear | static-token | connected | 18 |
| my-custom | none | error | — |
============================================================
PHASE 2: AUTH HEALTH CHECK
For each server:
-
OAuth servers (claude mcp login managed):
- Check if a keychain entry exists:
security find-generic-password -a claude-code -s "mcp-<name>" 2>/dev/null (macOS)
- On Linux:
secret-tool lookup application claude-code service mcp-<name> 2>/dev/null
- If the keychain entry is missing → flag as NEEDS_REAUTH
- If present, check expiry field in the stored JSON if readable
- Classify: HEALTHY | EXPIRING_SOON (< 10% TTL remaining) | NEEDS_REAUTH
-
Static-token servers:
- Check that the token field in the config is non-empty
- Flag any token older than 90 days as STALE (check file mtime as proxy if no expiry metadata)
- Note which of these servers could migrate to OAuth (check if the server manifest advertises
oauth2 capability)
-
Unauthenticated servers (no auth configured):
- Confirm that this is intentional (local servers like filesystem or memory servers)
- Flag as REVIEW_NEEDED if the server name suggests an external service
-
Error / disconnected servers:
- Run
claude mcp test <server-name> for each disconnected server to get the error detail
- Classify: NETWORK_ERROR | AUTH_FAILURE | SERVER_OFFLINE | CONFIG_MALFORMED
============================================================
PHASE 3: TOOL AVAILABILITY AUDIT
For each connected server:
-
List available tools with claude mcp list-tools <server-name> if the command exists, otherwise rely on claude mcp status output.
-
Flag any server with 0 tools as EMPTY — connected but contributing nothing.
-
For servers with tools, identify the top-3 most-used tool categories (file, search, create, delete, etc.) to help the user understand what each server does.
-
Check for tool name collisions: if two servers expose a tool with the same name, flag as COLLISION — Claude Code will use the first registered server's version, which may not be what the user expects.
============================================================
PHASE 4: GENERATE FIX CHECKLIST
Produce a prioritized checklist:
Critical (fix now — breaks agentic runs)
High (fix before next long session)
Medium (quality improvements)
Low (informational)
============================================================
PHASE 5: APPLY AUTO-FIXES (if authorized)
If the user's prompt includes "fix" or "--fix":
- For each NEEDS_REAUTH server: run
claude mcp logout <name> then claude mcp login <name> (opens browser flow — user must approve in browser).
- For CONFIG_MALFORMED: read the config file, validate JSON, show the malformed section and the corrected version, then ask for confirmation before writing.
- For EMPTY servers: offer to remove them with
claude mcp remove <name>.
- For static-token STALE: output the config key to update; do NOT write the token value — provide the path and key name only.
Do NOT modify the keychain directly — always use claude mcp login / logout CLI commands.
============================================================
OUTPUT FORMAT
MCP Connection Audit — {{DATE}}
Server Summary
| Server | Auth Type | Status | Tools | Action |
|---|
| ... | ... | ... | ... | ... |
Critical Issues
(list or "None")
Fix Checklist
(prioritized list from Phase 4)
OAuth Migration Candidates
Servers using static tokens that advertise OAuth support — migrate with:
claude mcp logout <server>
claude mcp login <server>
# then remove the token from ~/.config/claude/claude_desktop_config.json
Recommendations
- Run this audit after every Claude Code update — new servers may be registered automatically.
- Schedule a monthly token rotation check for any server still using static tokens.
- Use
claude mcp status at the start of long agentic sessions to confirm all servers are connected before the run begins.