Postkub MCP server

Give MCP clients scoped access to Postkub through a local stdio server that calls the same REST API as the CLI.

Updated

Open in ClaudeOpen in ChatGPT
On this page

The Postkub MCP server (package @postkub/mcp, command postkub-mcp) is a thin Model Context Protocol client of the Postkub REST API. Each tool call performs exactly one authorized REST request with the same scoped key, idempotency, and record lifecycle as the CLI — the host AI never gets a broader channel than the key allows.

Warning

The Postkub MCP server is in preview and is not yet installable from npm. Today it runs as a local stdio process from a Postkub source checkout against a local or development API. This page describes the planned public interface; tool names and inputs may still change before release.

How it works

The server is a local stdio process, not a hosted endpoint. Your MCP client launches it, hands it a scoped API key through environment variables, and speaks the standard MCP stdio protocol with it. On every tool call the server builds the same REST request the CLI would build and sends it to POSTKUB_API_URL.

  • It never touches your Postkub database, job queue, provider OAuth credentials, local files, or social networks directly. Everything goes through server-side authorization and tenant checks with the key's scopes.
  • There is no media byte-upload or filesystem tool. Posts attach ordered, publicly accessible HTTPS media URLs (mediaUrls), following the hosted media contract; humans upload files through the web UI.
  • Tool schemas are not hard-coded. At startup the server fetches the API's OpenAPI document and derives every tool's request and response schema from it, so the served document stays the single source of truth.

Note

At startup the server reads GET <POSTKUB_API_URL>/api/docs-json. That document is served by local and development API instances only — production does not serve it yet — so the MCP server currently works against a local or development API only.

Environment

VariableRequiredPurpose
POSTKUB_API_URLnoBase URL of the Postkub API. Defaults to http://127.0.0.1:4000. HTTPS is enforced for non-loopback hosts; plain HTTP is allowed for local development.
POSTKUB_API_KEYyesA scoped API key. Startup fails without it.
POSTKUB_TIMEOUT_MSnoPer-request REST deadline in milliseconds, 1–900000. Default 30000.

Client configuration

Run the server from a Postkub checkout (dependencies installed) and point your MCP client at it as a local stdio server:

POSTKUB_API_URL=http://localhost:4000 POSTKUB_API_KEY=<API_KEY> \
  pnpm --filter @postkub/mcp exec tsx src/main.ts

An MCP client configuration then looks like this:

{
  "mcpServers": {
    "postkub": {
      "command": "pnpm",
      "args": ["--filter", "@postkub/mcp", "exec", "tsx", "src/main.ts"],
      "env": {
        "POSTKUB_API_URL": "http://localhost:4000",
        "POSTKUB_API_KEY": "<API_KEY>"
      }
    }
  }
}

The command and args run inside the checkout directory — if your client supports a working-directory option, set it to the Postkub checkout; otherwise wrap the command in a shell that changes directory first. Inject the key through the client's environment mechanism, never into files inside the repository.

Warning

Planned: the registry install form (npx -y @postkub/mcp, launched as the postkub-mcp binary) will be documented here once the package passes testing and is published. It does not work today.

Tool catalog

Every REST tool maps to exactly one v1 operation, with the same scope the key needs for the equivalent CLI command:

ToolREST operationScopePurpose
whoamiGET /api/v1/meany valid keyInspect the principal, workspace, target IDs, and granted actions.
brands_listGET /api/v1/brandsbrand:readList Brands visible to the key.
accounts_listGET /api/v1/accountsaccount:readList connected social accounts.
accounts_schedule_getGET /api/v1/accounts/{id}/schedule-settingsaccount:readRead an account's timezone and weekly queue slots.
accounts_schedule_updatePATCH /api/v1/accounts/{id}/schedule-settingsaccount:scheduleUpdate the timezone and/or weekly slots.
capabilities_getGET /api/v1/accounts/{id}/capabilitiesaccount:readRead allowed actions and reasons for one account.
posts_listGET /api/v1/postspost:readList posts with Brand, account, status, and time filters.
posts_getGET /api/v1/posts/{id}post:readRead one post projection.
posts_createPOST /api/v1/postspost:createCreate a draft with hosted mediaUrls.
posts_updatePATCH /api/v1/posts/{id}post:updateEdit a draft (revision-guarded).
posts_deleteDELETE /api/v1/posts/{id}post:deleteDelete an unaccepted local draft.
posts_publishPOST /api/v1/posts/{id}/publishpost:publishAccept publish-now for selected accounts (202).
posts_schedulePOST /api/v1/posts/{id}/schedulepost:scheduleAccept explicit schedules or the next queue slot (202).
posts_cancelPOST /api/v1/posts/{id}/cancelpost:cancelCancel unstarted work for selected accounts.
posts_retryPOST /api/v1/posts/{id}/retrypost:publishRetry proven-no-effect failures.
posts_cover-retryPOST /api/v1/posts/{id}/cover-retrypost:publishRetry a failed video cover without re-uploading.
threads_listGET /api/v1/threadscomment:readList inbox threads.
threads_getGET /api/v1/threads/{id}comment:readRead one thread with its comments.
threads_updatePATCH /api/v1/threads/{id}thread:update / thread:resolveUpdate unread and/or handled state.
comments_listGET /api/v1/commentscomment:readList comments.
comments_replyPOST /api/v1/comments/{id}/repliescomment:replyAccept a durable reply (202).
insights_accountGET /api/v1/accounts/{id}/insightsinsight:readRead saved account metrics.
insights_postGET /api/v1/posts/{id}/insightsinsight:readRead saved post metrics.
activity_listGET /api/v1/activityactivity:readList scoped activity and sanitized failures.
replies_getGET /api/v1/replies/{id}comment:readRead reply execution status.
requests_getGET /api/v1/requests/{requestId}any valid keyRecover a mutation receipt.

Four discovery tools complete the surface:

ToolPurpose
threads_resolveMark a thread handled — a convenience wrapper over threads_update that sends handled: true (needs thread:resolve).
list_schemasList every derived REST tool with its operation, method, path, and required action.
describe_schemaReturn one operation's input parameters, request body, responses, and error schemas from the served OpenAPI document.
get_contextReturn Postkub's canonical agent guidance topics (the same topics as postkub context), one topic at a time or all at once.

Field projection

Read tools accept an optional fields string with the same syntax as the CLI's --fields: comma-separated dot paths (items.id), brace expansion (items.{id,status}), or all. The projection is validated against the served response schemas before any request is sent, so an unknown path fails fast with an INVALID_FIELDS error instead of shrinking the response silently.

Results and errors

Every tool returns machine-readable structuredContent of the form { "status": <HTTP status>, "body": <response JSON>, "idempotencyKey": "<uuid, writes only>" }, plus the same payload as text content.

  • Success: the HTTP status is 2xx and isError is absent. A 202 means Postkub accepted the intent — not that a social network completed the work.
  • REST rejection: HTTP 400–499 sets isError: true and carries the normalized error envelope in body. See errors.
  • Transport failure: status 0 with isError: true and code REQUEST_FAILED. The outcome is unknown — the result still echoes the idempotencyKey that was sent, so the host can call requests_get and replay the identical request with the same key. Never retry an uncertain write with a new key (idempotency).
  • Local validation: input that does not match the served operation schema fails before any network call with isError: true and codes INVALID_TOOL_INPUT, VALIDATION_ERROR, or INVALID_FIELDS.

For writes, the server generates a UUID Idempotency-Key when the tool input omits idempotencyKey, and always returns the key it used in structuredContent.

Example prompts

Ask the host AI naturally; it selects the tool:

Call whoami and summarize the Brand IDs, account IDs, and actions my key can use.
Create a draft with posts_create: brandId "brd_9x2k", text "Launch recap",
socialAccountIds ["acc_2gf8xh"], and mediaUrls ["https://cdn.example.com/recap.jpg"].
Schedule that draft into the next free queue slot for each account, then show me
the post ID, revision, and the exact fireAtUtc the API reserved.
The publish call returned status 0. Keep its idempotencyKey, call requests_get with
it, and tell me what happened before doing anything else.

Media must be a direct, public HTTPS URL that stays readable until publication completes — never a local path, a file upload, or a viewer/share page.

Troubleshooting

SymptomWhat to do
postkub-mcp startup failed: POSTKUB_API_KEY is requiredInject a scoped key through the client's environment settings; the server refuses to start without one.
Startup fails with an OpenAPI fetch errorCheck POSTKUB_API_URL and that <POSTKUB_API_URL>/api/docs-json responds. The startup fetch deadline is 5 seconds, and only local/development API instances serve the document today.
INVALID_TOOL_INPUTCall describe_schema for the tool's operation and match the served field names.
INVALID_FIELDSRemove the unknown projection path or inspect the response schema with describe_schema.
Status 0 on a writeKeep the returned idempotencyKey, call requests_get with it, and only then decide whether to replay with the same key.
Provider capability error on an accepted-shaped callCall capabilities_get; the operation exists but that account cannot perform the action yet.
Media rejectedUse ordered, direct, public HTTPS URLs in mediaUrls; see hosted media.