Connect Claude Code
Add Moly to the Claude Code CLI using a Personal Access Token for headless tool access.
Connect Claude Code
Claude Code is Anthropic's command-line agent. It supports both OAuth and Personal Access Token MCP servers; for CLI use the PAT path is simpler — no browser redirect needed.
Before you start
You'll need:
- Claude Code installed (
brew install claude-codeor follow the official docs) - A Moly account
- 30 seconds to mint a Moly PAT
1. Mint a Personal Access Token
- In Moly, go to Settings → Integrations.
- In the Personal Access Tokens card, click Create token.
- Name it something memorable:
Claude Code on Laptoporclaude-cli. - Pick an expiry (or leave Never).
- Click Create token. The token is shown once — copy it now.
The token starts with mp_ and is ~50 characters long.
2. Add the MCP server to Claude Code
claude mcp add moly \
--transport http \
--url https://api.moly.so/mcp \
--header "Authorization: Bearer mp_<your-token-here>"That's it. The next time you start Claude Code (claude in your terminal), it will list Moly tools alongside any other MCP servers you have.
Verify
claude
> List my Moly workspacesClaude should call list_workspaces and stream the response.
Why PAT and not OAuth for CLI?
Claude Code can do OAuth too, but the CLI experience requires you to keep a browser session open every ~15 minutes for refresh. PATs avoid that — you set the header once and Claude Code never has to round-trip a refresh.
If you prefer OAuth anyway (multi-device sync, easy revoke from Moly's UI), use:
claude mcp add moly \
--transport http \
--url https://api.moly.so/mcpClaude Code will open the OAuth flow in your browser on first call.
Revoking access
PAT path: Settings → Integrations → Personal Access Tokens → Revoke. Any tool using that token loses access on its next request.
OAuth path: Settings → Integrations → Connected MCP clients → Disconnect.
Either way, Claude Code shows the server as unreachable until you re-add it.
Multiple machines
PATs are not bound to a device — you can paste the same mp_... token into Claude Code on multiple laptops. If you want per-device revocation, mint a separate token per machine and name it accordingly.