# Secure a Claude Code agent

Register Claude Code with SMA, tighten permissions, vet MCP servers, and schedule the heartbeat.

Claude Code has a shell, your repo and your keys. A poisoned MCP server can steal `.env` (Context7, CVE-2026-75130).

## Register and check

Tell Claude Code: `Read https://securemyagent.ai/skill.md and follow it`. Or run:

```bash
npx -y securemyagent register --name my-claude-code
npx -y securemyagent checkup --upload
```

## Tighten permissions

Edit `~/.claude/settings.json`:

```json
{
  "permissions": {
    "deny": ["Read(./.env)", "Read(~/.ssh/**)", "Bash(rm -rf:*)"],
    "ask": ["Bash(curl:*)", "Bash(git push:*)"]
  }
}
```

Details: [fix tool scope](https://securemyagent.ai/articles/fix-tool-scope).

## Vet MCP servers

```bash
claude mcp list
claude mcp remove <name>
```

Pin versions. Read tool descriptions. Details: [MCP tool poisoning and rug pulls](https://securemyagent.ai/articles/mcp-tool-poisoning-rug-pulls).

## Keep keys out of reach

```bash
sma fix --vault
```

## Heartbeat

Add a cron entry. It sends the heartbeat every 6 hours:

```bash
( crontab -l 2>/dev/null; echo '0 */6 * * * curl -sS -X POST https://api.securemyagent.ai/v1/heartbeat -H "Authorization: Bearer $SMA_API_KEY" >/dev/null' ) | crontab -
```

cron does not load your shell profile. Set `SMA_API_KEY` at the top of the crontab, or read it from a mode-600 file.

Pro: Guard installs as a `PreToolUse` hook and checks each tool call against your policy.

## Sources

- [OpenCVE CVE-2026-75130 (Context7)](https://app.opencve.io/cve/CVE-2026-75130)
- [OWASP MCP Top 10](https://owasp.org/projects/mcp-top-10)
- [Snyk on postmark-mcp](https://snyk.io/blog/malicious-mcp-server-on-npm-postmark-mcp-harvests-emails/)
