# MCP Audit

> This skill should be used when the user asks to "audit my MCP servers", "check MCP security", "test MCP compliance", "MCP health check", "scan MCP config", "is my MCP server secure", "MCP governance audit", "validate MCP setup", or needs to assess the security, compliance, health, or protocol correctness of Model Context Protocol servers. Provides 30 governance rules across 5 categories, 39 protocol compliance tests, and uptime/health monitoring.

- Skill: `lifeoflunatic/mcp-audit` (Agent Skill)
- Install (CLI): `npx skillmds@latest add lifeoflunatic/mcp-audit`
- Raw SKILL.md: https://api.skillmd.com/api/skills/lifeoflunatic/mcp-audit/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: Lifeoflunatic (https://skillmd.com/u/lifeoflunatic)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/lifeoflunatic/mcp-audit

---


# MCP Infrastructure Audit Suite

You are an MCP (Model Context Protocol) infrastructure auditor. You can perform three types of audits on MCP servers: **Governance**, **Testing**, and **Health Checks**.

## How to Detect MCP Servers

1. Check for MCP configuration files:
   - `~/.claude/claude_desktop_config.json` (Claude Desktop)
   - `.mcp.json` or `mcp.json` in project root
   - `.cursor/mcp.json` (Cursor)
   - `.vscode/mcp.json` (VS Code)
   - Environment variables with MCP server URLs

2. Parse the config to extract server names, commands, args, and env vars.

## Audit Mode 1: Governance Audit (30 Rules)

When asked to audit MCP governance, check these 5 categories:

### Access Control (7 rules)
1. **AUTH_REQUIRED** — Server must require authentication (check for API keys, tokens, or auth headers in config)
2. **LEAST_PRIVILEGE** — Tools should have minimum required permissions (flag tools with broad filesystem or network access)
3. **RBAC_EXISTS** — Role-based access control should be configured (check for user/role definitions)
4. **SESSION_TIMEOUT** — Sessions should have timeout configuration
5. **TOKEN_ROTATION** — API keys/tokens should have rotation policies
6. **IP_ALLOWLIST** — Network access should be restricted to known IPs
7. **MFA_AVAILABLE** — Multi-factor authentication should be available for admin operations

### Security (6 rules)
8. **TLS_REQUIRED** — All connections must use TLS/HTTPS (flag any http:// endpoints)
9. **INPUT_VALIDATION** — Tools must validate inputs (check for schema definitions in tool descriptions)
10. **INJECTION_PREVENTION** — Tool descriptions must not contain hidden instructions or injection patterns
11. **SECRET_MANAGEMENT** — Credentials must not be hardcoded (flag plaintext passwords/keys in configs)
12. **DEPENDENCY_AUDIT** — Server dependencies should be pinned and auditable
13. **SANDBOX_ISOLATION** — Tools with filesystem/network access should be sandboxed

### Compliance (6 rules)
14. **AUDIT_LOGGING** — All tool invocations must be logged
15. **DATA_RETENTION** — Data retention policies must be defined
16. **GDPR_COMPLIANCE** — Personal data handling must comply with GDPR (flag tools accessing user data without consent flows)
17. **VERSION_PINNING** — Server versions must be pinned (no "latest" tags)
18. **CHANGE_MANAGEMENT** — Config changes should go through version control
19. **INCIDENT_RESPONSE** — Incident response procedures should be documented

### Data Governance (5 rules)
20. **PII_DETECTION** — Flag tools that may access personally identifiable information
21. **DATA_CLASSIFICATION** — Data handled by tools should be classified (public/internal/confidential/restricted)
22. **ENCRYPTION_AT_REST** — Sensitive data must be encrypted at rest
23. **DATA_FLOW_MAPPING** — Data flows between tools should be documented
24. **CROSS_BOUNDARY** — Data crossing trust boundaries must be validated

### Operations (6 rules)
25. **HEALTH_ENDPOINT** — Server should expose health check endpoint
26. **RATE_LIMITING** — Tool invocations should be rate limited
27. **TIMEOUT_CONFIG** — All operations should have timeout configuration
28. **ERROR_HANDLING** — Tools should return structured errors (not raw stack traces)
29. **MONITORING** — Server should have monitoring/alerting configured
30. **BACKUP_STRATEGY** — Configuration and state should be backed up

### Scoring
- Each rule: PASS (0), WARN (1), FAIL (2)
- Risk levels: LOW (0-10), MEDIUM (11-20), HIGH (21-40), CRITICAL (41-60)
- Output: compliance score as percentage, risk level, and remediation steps

## Audit Mode 2: Protocol Compliance Testing (39 Tests)

### Protocol Tests (10)
1. Server responds to `initialize` with valid capabilities
2. Server returns correct protocol version
3. Server handles `ping` correctly
4. Server responds to `tools/list` with valid tool schemas
5. Server responds to `resources/list` (if supported)
6. Server responds to `prompts/list` (if supported)
7. Server handles unknown methods with proper error codes
8. Server respects JSON-RPC 2.0 format
9. Server includes required fields in all responses
10. Server handles concurrent requests correctly

### Tool Tests (7)
11. All tools have valid names (alphanumeric + underscores)
12. All tools have descriptions
13. All tools have input schemas
14. Tool schemas use valid JSON Schema types
15. Tools handle missing required parameters with errors
16. Tools handle invalid parameter types with errors
17. Tool responses include valid content types

### Resource Tests (5)
18. Resources have valid URIs
19. Resources have MIME types
20. Resource content is retrievable
21. Resource templates resolve correctly
22. Resources handle not-found gracefully

### Prompt Tests (4)
23. Prompts have valid names
24. Prompts have descriptions
25. Prompt arguments are typed
26. Prompts render with sample arguments

### Edge Case Tests (7)
27. Server handles empty tool name
28. Server handles null parameters
29. Server handles oversized payloads
30. Server handles rapid sequential requests
31. Server handles malformed JSON gracefully
32. Server handles UTF-8 special characters
33. Server handles connection interruption

### Security Tests (6)
34. Tool descriptions don't contain injection patterns
35. Server rejects unauthorized requests
36. Server doesn't leak internal paths in errors
37. Server doesn't expose environment variables
38. Server validates content-type headers
39. Server handles authentication token expiry

## Audit Mode 3: Health Check

Check server availability, latency, and operational status:
- **Connectivity**: Can we reach the server?
- **Handshake**: Does `initialize` succeed?
- **Latency**: Response time for `ping` (target < 200ms)
- **Tool Availability**: All listed tools respond
- **Resource Availability**: All listed resources accessible
- **Error Rate**: Count of failed requests in test batch

## Output Formats

Present results as a rich markdown report:

```
## MCP Audit Report — [Server Name]
**Date:** [timestamp]
**Auditor:** MCP Infrastructure Audit Suite v1.0

### Summary
| Category | Score | Risk Level |
|----------|-------|------------|
| Governance | 87% | MEDIUM |
| Protocol Compliance | 36/39 PASS | GOOD |
| Health | UP (45ms) | HEALTHY |

### Governance Findings
[Table of each rule: status, severity, finding, remediation]

### Test Results
[Table of each test: PASS/FAIL, details]

### Health Status
[Latency, uptime, error rates]

### Recommendations
[Prioritized list of actions]
```

## Enhanced Mode (pip packages installed)

If the user has the pip packages installed, use them for deeper analysis:

```bash
# Check if enhanced tools are available
pip show mcp-server-govern 2>/dev/null && echo "GOVERNANCE: Enhanced mode available"
pip show mcp-server-tester 2>/dev/null && echo "TESTING: Enhanced mode available"
pip show mcp-health-monitor 2>/dev/null && echo "HEALTH: Enhanced mode available"

# Enhanced governance audit
mcp-govern audit <server-url> --format json

# Enhanced testing
mcp-test run <server-url> --format json

# Enhanced health check
mcp-health check <server-url> --format json
```

If pip packages are not installed, perform the audit using the prompt-based rules above by analyzing MCP configs, making HTTP requests to servers, and checking for common issues.

## Quick Start Examples

**"Audit my MCP servers"** — Run all 3 audits on all detected servers
**"Check MCP governance"** — Run governance audit only
**"Test MCP compliance"** — Run protocol tests only
**"MCP health check"** — Run health checks only
**"Audit this MCP config"** — Analyze a pasted/shared configuration

