Connect Gemini CLI to Threadgehog
Gemini CLI can read your Threadgehog projects, draft and edit posts, approve them and send the queue, right from your terminal. Connect it once in Settings, Agents, and Threadgehog opens a private server on this Mac that only an agent with your token can reach. Gemini CLI is a separate, open source tool with its own Google account or API billing; when it asks Threadgehog to write or generate something, that still runs through the AI and image provider you set up in Threadgehog's own Settings.
How to set up Gemini CLI
Open Settings, Agents
In Threadgehog, press Cmd+, (or Threadgehog menu, Settings), then click the Agents tab. It sits right after Publishing.
Turn on agents
Switch on "Allow agents on this Mac to use Threadgehog". This starts a private server on this Mac only, at 127.0.0.1. Agents can read your projects, write and edit drafts, approve posts and send the queue. They use the same AI provider, image provider and scheduler as the buttons in the app; nothing else leaves your Mac. The line under it adds that your agent can also answer questions about Threadgehog, using the help built into this version and your app's live status.

Copy the address and token
With agents on, the tab shows Address (http://127.0.0.1:47331/mcp, or another port if 47331 is taken) and a masked Token. You need these only for the optional Direct (HTTP) setup; the snippet in the next step reads them itself. Regenerate issues a new token if you ever need one; a Direct (HTTP) connection will need the new value.

Connect an agent
Under "Connect an agent", pick Gemini CLI from the list. Threadgehog fills in a ready-made snippet that starts the threadgehog command (no token goes in your config), plus a Copy button and a Setup guide link to this page. Threadgehog must stay open while Gemini CLI uses it.

Add Threadgehog to Gemini CLI
Add this to ~/.gemini/settings.json. If you use the optional Direct (HTTP) setup instead, use httpUrl, not url: that's the key Gemini CLI expects for a local streamable HTTP server.
{ "mcpServers": { "threadgehog": { "command": "/usr/local/bin/threadgehog", "args": ["mcp-stdio"] } } }Confirm it's connected
Start a Gemini CLI session and type /mcp. threadgehog should show as CONNECTED with its tools listed.
/mcpOptional: install the threadgehog command
Still in Settings, Agents, click "Install the threadgehog command". It asks for your Mac password once and creates /usr/local/bin/threadgehog. If you'd rather run it yourself, click Copy fallback for the exact command for your Mac. Once installed, threadgehog status checks the connection, threadgehog mcp prints the address, header and the Claude Code, Codex and Cursor snippets, and threadgehog help answers a question from the help built into the app.
sudo mkdir -p /usr/local/bin && sudo ln -sf "<helper path>" /usr/local/bin/threadgehog threadgehog status threadgehog mcp threadgehog help how do I connect Buffer
What you get
- List your projects and their publishing settings
- Check your writing plan and how much capacity is left
- List posts waiting for approval in a project
- List posts waiting in the publishing queue, for one project or all of them
- Get one post by ID to see its full text and status
- Generate new draft post ideas for a project
- Write post text from a prompt without saving it, so you can review it first
- Save text you already wrote as a new draft
- Replace a post's text
- Revise a post's wording from feedback, keeping its idea
- Approve a pending draft into the publishing queue
- Reject a pending or queued post
- Attach a local image or video file to a post (png, jpg, gif, webp, mp4 or mov)
- Generate an image for a post
- Set the order of posts waiting in the queue
- Send eligible queued posts right now, once Let agents send posts is on in Settings, Agents
- Check the app's live status: version, plan, AI and image providers, connected schedulers, queue counts and anything that needs attention
- Answer how-to, setup and troubleshooting questions about Threadgehog from the help built into your version
What it costs
Threadgehog doesn't charge anything extra to connect Gemini CLI. Gemini CLI itself is free and open source; it runs on your own Google account's free tier or on paid API billing, separate from Threadgehog, depending on how you sign in. Drafts, ideas and images Gemini CLI asks Threadgehog for still use the AI provider and image provider you've set up in Threadgehog's own Settings, and are billed the same way a click in the app would be.
Your key and your data
Threadgehog's agent server only listens on 127.0.0.1, this Mac, on the port shown in Settings, Agents (47331 by default, or another free port if that one is taken). Every request needs the bearer token from that tab, and a request with the wrong Origin header is refused too. Gemini CLI connects to that address directly over HTTP, since it runs on this Mac already. Threadgehog stores the token in the macOS Keychain, and also writes it with the port to ~/Library/Application Support/Threadgehog Public/agent.json (readable only by your Mac user account) so the threadgehog command can find the server. That file stays on disk, even after you quit Threadgehog, until you turn Allow agents off. The copy you paste into ~/.gemini/settings.json is what Gemini CLI uses to authenticate, so treat that file like it holds a password. Click Regenerate in Settings, Agents any time to issue a new token, which immediately invalidates the old one everywhere it was used. Agent calls run entirely between Gemini CLI and Threadgehog on your Mac, through the same AI provider, image provider and scheduler you already configured; Threadgehog's own servers never see this traffic, and no keys or tokens are ever returned to an agent.
Limits to know
- Works only on this Mac: the server listens on 127.0.0.1, so no other device can reach it.
- Threadgehog must be open with Agents turned on in Settings, Agents, or every call fails.
- Works with agents that run on your Mac: Claude Code, Codex, Cursor, Claude Desktop and Gemini CLI.
- approve_post only works on posts still pending, and reject_post only on posts pending or queued; neither can touch a post that already published.
- Media attachments must already exist under your home folder, as png, jpg, gif, webp, mp4 or mov files.
Troubleshooting
"Threadgehog isn't running with agents enabled. Open Threadgehog, then Settings > Agents, and turn on Allow agents."
Why: The threadgehog command found no running server: either Threadgehog is closed, or the Allow agents toggle in Settings, Agents is off. Only the threadgehog command prints this message; Gemini CLI shows its own connection error for the same problem.
Fix: Open Threadgehog, go to Settings, Agents, and turn on Allow agents. Keep the app open while you use the agent.
Right after someone clicks Regenerate in Settings, Agents, every Threadgehog call from Gemini CLI fails as unauthorized (Threadgehog answers HTTP 401).
Why: Gemini CLI is connected through the optional Direct (HTTP) setup and is still sending the old token. The default snippet is not affected. The threadgehog command is not affected, because it reads the current token from the app each time it runs.
Fix: In Settings, Agents, click Copy next to Token, then update your config or snippet with the new value and reconnect.
No Agents tab in Settings.
Why: This Threadgehog version doesn't have agent support yet.
Fix: Open the Threadgehog menu and choose Check for Updates…, install the update, then reopen Settings.
"Only pending posts can be approved; <id> is published."
Why: approve_post only moves a draft still waiting for approval into the queue. This post already moved past pending, so a repeat approval is refused instead of resending it.
Fix: Check the post's current status with get_post or list_pending before approving it again.
"Unknown tool: <name>"
Why: The agent called a tool name that isn't one of Threadgehog's supported tools, for example a misspelled or made-up name.
Fix: Reconnect the agent, or restart the session, so it reloads the current tool list.
/mcp shows threadgehog as DISCONNECTED.
Why: Threadgehog isn't open, or the snippet points to an old command path. With the Direct (HTTP) setup, a common cause is using "url" instead of "httpUrl".
Fix: Open Threadgehog, copy the snippet fresh from Settings > Agents with Gemini CLI selected, save, and start a new session. For the Direct (HTTP) setup, use httpUrl in ~/.gemini/settings.json.
Questions
Do I need to turn on Agents to use Threadgehog normally?
No. Agents are optional. Everything in Threadgehog still works from its own buttons with Agents off; turning it on adds a way for Gemini CLI, or another MCP client you connect, to drive the same actions.
Can Gemini CLI answer questions about how Threadgehog works?
Yes, in Threadgehog 1.0.4 or later. Ask Gemini CLI something like "how do I connect Buffer" and it looks the answer up in the help built into your copy of Threadgehog. When something isn't working, it also checks your app's live status, such as a scheduler or AI key that stopped working or posts waiting on a setting. That help ships inside the app and is updated with every release. It runs on Gemini CLI, so nothing extra is sent to Threadgehog.
Does connecting Gemini CLI cost anything extra in Threadgehog?
No, Threadgehog doesn't charge anything extra to connect an agent. Gemini CLI is a separate tool with its own plan, though. When it asks Threadgehog to draft text, generate ideas or make an image, that still runs through the AI provider and image provider set up in Threadgehog's own Settings, billed the same way a click in the app would be.
Can Gemini CLI publish to Threads or X directly?
No. Gemini CLI can approve a post into Threadgehog's queue and tell Threadgehog to send the queue now, but Threadgehog only publishes through the scheduler you've connected under Settings, Publishing, or not at all if you use Export only. Gemini CLI never talks to Threads or X directly.
Can Gemini CLI send posts without me clicking anything in Threadgehog?
Yes. approve_post moves a pending draft into the queue without a click, and those posts go out on your send schedule. For an agent to send right away with send_queue_now, turn on Let agents send posts in Settings, Agents (it starts off). Click Regenerate there any time to cut a connected agent off.
Will this work with ChatGPT, Manus or Perplexity's Computer agent?
Threadgehog connects to agents that run on your Mac: Claude Code, Codex, Cursor, Claude Desktop or Gemini CLI.
What happens if I close Threadgehog while Gemini CLI is connected?
Every call fails until you reopen Threadgehog with Agents still turned on. The threadgehog command line shows "Threadgehog isn't running with agents enabled..." in that case, and Gemini CLI will see a similar connection error.
I copied the Cursor or Claude Desktop snippet. Will it work?
Yes. Cursor, Claude Desktop and Gemini CLI use the same snippet, which starts the threadgehog command. Paste it into ~/.gemini/settings.json and start a new session.