How to let Claude Code and Codex run your local dev servers
Written by GuruHat, which makes ServerHat.
Short answer: install ServerHat, then run one setup command so Claude Code or Codex gets MCP tools to list, start, restart and read the logs of your dev servers.
The servers keep running after the session ends, and any command the agent adds or changes waits for your approval in the menu bar.
The problem with servers started by an agent
When a coding agent starts npm run dev in its own shell, that server belongs to the session. It can disappear when the session ends, hold a port you then can't find, or print errors the agent has to hunt for. You end up asking which process has port 3000.
Set it up in three steps
- Install ServerHat. It's a free Mac menu-bar app (macOS 13+, Apple silicon) and a Windows tray app. On a Mac:
brew install --cask getguruhat/tap/serverhat. - Copy the command. Open Settings from the menu and choose Copy for Claude Code or Copy for Codex.
- Paste it into Terminal. The commands look like this:
# Claude Code
claude mcp add --scope user serverhat -- \
/Applications/ServerHat.app/Contents/MacOS/ServerHat --mcp
# Codex
codex mcp add serverhat -- \
/Applications/ServerHat.app/Contents/MacOS/ServerHat --mcp
What the agent can do
The MCP server exposes tools such as list_servers, start_server, stop_server, restart_server, get_logs, add_server and import_project. You can then say:
- “Start the docs site.”
- “Why did the API crash?” (the agent reads the log and the last line of output.)
- “Add this project.” (it imports the project's
.claude/launch.json,package.jsondev script, Procfile or Docker Compose file.)
You stay in control
- Approval first. A server an agent or script adds or changes can't run until you click Allow in ServerHat. You see the exact command, folder and environment variable names first. After that, the agent can start and restart it without asking again.
- Local only. The API listens on 127.0.0.1, needs a private token and refuses web pages.
- No account, no analytics. Nothing is sent anywhere.
Beyond agents: one place for every dev server
ServerHat also works without an agent. Each server has Start/Stop, Restart, Open in browser and View logs. It shows when a server crashes (with its last line of output) or when its port is taken and by which process. Logs stay readable after a server stops, and you can optionally restart a crashed server with growing delays and a retry limit. Everything lives in one readable servers.json file.
What to know
- The MCP server is on macOS 13+ (Apple silicon) for now. The Windows 10/11 tray app has the local API, but some features are Mac-only.
- The Mac app isn't notarized yet, so allow its first launch in System Settings › Privacy & Security.
- ServerHat is free and MIT-licensed, and follows your system language (English, Spanish, German, French, Portuguese, Japanese, Simplified Chinese and Korean).
Frequently asked questions
How do I add an MCP server to Claude Code?
Run claude mcp add with a name and the command that starts the server. For ServerHat, open its Settings and choose Copy for Claude Code, then paste the command into Terminal. The same works for Codex with codex mcp add.
Can Claude Code or Codex start my dev server and keep it running?
Yes, through ServerHat's MCP tools. The agent asks ServerHat to start the server, so it keeps running after the session ends instead of being tied to the agent's own shell.
Can the agent run any command it wants?
No. A new or changed command waits for your Allow in ServerHat, where you see the exact command, folder and environment names. Once you allow it, the agent can start and restart that server.
Does ServerHat work on Windows?
There is a Windows 10/11 tray app with a local API, but the MCP server and some features are Mac-only for now.
Is ServerHat free?
Yes. It is free and open source under the MIT license, with no account and no analytics.