如何用 MCP 和 pendpost 將 Claude 連接至社交媒體
How to connect Claude to social media with MCP
文章示範如何用 pendpost 的 MCP server 將 Claude Desktop、Claude Code 或 Cursor 連接至社交媒體,並先以模擬模式測試發文流程。
To connect Claude to social media, give it an MCP server that holds your platform credentials and exposes posting as tools. Claude never signs in to Instagram or X itself; it calls tools, and the server publishes. With pendpost the setup is one stdio entry, npx -y pendpost --stdio, added to Claude Desktop, Claude Code or Cursor. Start with PENDPOST_MODE=mock and a temp-folder PENDPOST_ROOT, have Claude draft a post, approve it yourself, and watch the mock driver publish it with zero real API calls. Real accounts come after that, one platform at a time.
What does Claude need to post to social media?
Claude needs an MCP server that holds the platform tokens and decides when a post may go out. Claude Desktop, Claude Code and Cursor are MCP clients. They launch local servers, list their tools, and let the model call them. The MCP specification's tools page says there should always be a human in the loop who can deny tool invocations, and Claude Desktop asks for your approval before it runs one.
pendpost is one such server. It is MIT-licensed, binds 127.0.0.1, and keeps tokens in your own .env; every post passes its approval gate. The MCP server page lists what the tools cover. Everything below works the same for any stdio MCP server, only the command changes.
Which config works for Claude Desktop, Claude Code and Cursor?
The config that works is the plain stdio launch plus three environment variables. Here it is for each client, as of November 2026.
Claude Desktop
Open Settings from the Claude menu in your system menu bar, go to Developer, and click Edit Config. The file lives at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS and %APPDATA%\Claude\claude_desktop_config.json on Windows, per the MCP docs.
{
"mcpServers": {
"pendpost": {
"command": "npx",
"args": ["-y", "pendpost", "--stdio"],
"env": {
"PENDPOST_MODE": "mock",
"PENDPOST_ROOT": "/tmp/pendpost-demo",
"PENDPOST_PORT": "8197"
}
}
}
}
Quit Claude Desktop completely and reopen it. A config change only loads on restart.
Claude Code
One command, run from your project folder. The -- separator matters: everything after it goes to the server unchanged (Claude Code MCP docs).
claude mcp add --env PENDPOST_MODE=mock --env PENDPOST_ROOT=/tmp/pendpost-demo --env PENDPOST_PORT=8197 --transport stdio pendpost -- npx -y pendpost --stdio
Keep --transport stdio between the last --env and the name, or the CLI reads pendpost as another variable. The default scope is local to the project. Add --scope user to load it everywhere, or --scope project to write a shared .mcp.json. Run /mcp inside Claude Code to see the connection.
Cursor
Put the same mcpServers block in .cursor/mcp.json in your project or ~/.cursor/mcp.json for all projects. Cursor's MCP docs list "type": "stdio" as a field, so add it next to command.
Any other stdio client
Any client that can launch a stdio server takes the same command, args and env. If you prefer one click, the .mcpb bundle on the download page installs into Claude Desktop without editing JSON, but it starts in live mode, so use the config above for a first mock run.
Why set PENDPOST_ROOT and PENDPOST_PORT?
You set them because of two behaviours that otherwise look like a silent failure. Both come from the engine code, and both made my own test runs exit before the first tool call.
| Variable | Value | What happens without it |
|---|---|---|
PENDPOST_MODE |
mock |
pendpost runs live. Unconnected lanes wait for a credential and nothing fakes a publish, but nothing publishes either. |
PENDPOST_ROOT |
a folder under /tmp
|
In mock mode, pendpost refuses to boot against a data folder outside the temp directory, so fake post ids can never land in real plans. On 2.8.0 and earlier that included the default folder, so it logged "mock mode refused" and exited with code 1. Newer versions fall back to a private demo folder in your temp directory; setting it yourself keeps the demo somewhere you can find it. |
PENDPOST_PORT |
any free port, such as 8197
|
The stdio process also starts the dashboard, on 8090 by default. If another pendpost holds 8090, the new one logs "port 8090 already in use" and exits with code 0, so the client just shows a disconnected server. |
On macOS and Linux, /tmp/pendpost-demo passes the temp check; the folder does not have to exist first. On Windows, use a folder inside the directory that node -p "require('os').tmpdir()" prints. Node.js 22 or newer is required.
If you already run pendpost as a background app on 8090 and want Claude to drive that same instance, skip stdio. In Claude Code, claude mcp add --transport http pendpost http://127.0.0.1:8090/mcp connects to it directly. The MCP clients docs page covers the HTTP route for Claude Desktop too.
What should I ask Claude first?
Start with prompts that each map to one tool call, so you can see what happened. I ran this exact sequence over stdio against pendpost 2.8.0 in mock mode; the responses below are what came back.
- "Call pendpost_health and tell me what is set up." It returns
ready: falsewith one "not yet proven" line per platform. That is correct for a fresh mock run: no lane has a real credential. - "Create a campaign called mcp-test." A fresh temp root starts empty, so this is the first write. Claude calls
campaign_create. - "Draft a Mastodon text post in mcp-test, due now, that says we are testing a draft from my agent." Claude calls
plan_create_post. The post comes back withapproval: "draft"andcreatedByset to the agent's actor name, for exampleagent:claude. - "Publish the due posts now." Nothing publishes.
publish_due_runreturns an empty list, because a draft is not publishable. - "Approve it." If Claude approves under its own actor name, pendpost answers "agent:claude created this post and cannot approve it (no self-approval)". Approve it yourself in the dashboard at
http://127.0.0.1:8197, or tell Claude in plain words that you, the owner, approve it. - "Publish the due posts now." This time the run reports
ok: truefor the Mastodon lane, and the post's status turns toposted. The mock driver invented the post id and wrote the action to a.mock-ledger.jsonfile inside your temp folder.
The mock mode docs describe what the mock driver fakes and what it skips (rate limits and native scheduling only engage on a live lane).
What stops Claude from posting something I did not approve?
The approval gate does: every post starts as a draft, only the approve and reject tools (or an auto-approve policy that only the owner can switch on) change that, and the actor that drafted a post cannot approve it. A human, as owner, can approve their own drafts. If the copy changes after approval, the post is flagged as edited and waits for a fresh approval. In my test run, the publish sweep skipped it.
One honest limit. The actor is a name the caller passes in, so the rule stops an agent from blessing its own draft under its own name; it does not check who is behind the name "owner". The second checkpoint is your MCP client, which asks before running a tool. Read the approve_post prompt before you allow it, and do not set it to always allow. For the wider pattern, see how to let an AI agent post to social media safely, and the security page for what stays on your machine.
How do I move from mock mode to real accounts?
Remove PENDPOST_MODE, point PENDPOST_ROOT at a permanent folder, and connect one platform at a time. Ask Claude to call pendpost_health again: its setup field lists, per platform, what is missing and the exact command to run. Claude can write non-secret identifiers such as a page id, but you run the sign-in step yourself, in your terminal or the dashboard Setup page, so the token goes into your .env and never through the chat. The quickstart links the credential guide for each platform.
Approve your first live post by hand. It also pays to keep the mock entry in your config under a second name, such as pendpost-mock, with its own port and temp folder. A new prompt can then run against fake post ids first, which cost nothing when they go wrong.
Originally published on pendpost.com. pendpost is a free, open-source (MIT), local-first social media planner where an AI agent drafts posts behind a human approval gate.
來源:DEV Community · dev.to