AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
MCP verified MIT Self-run

Puck

mcp-ticktockbent-puck · by TickTockBent

X/Twitter MCP Connector — Lord, what fools these mortals be!

No reviews yet
0 installs
24 views
0.0% view→install

Install

$ agentstack add mcp-ticktockbent-puck

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/mcp-ticktockbent-puck)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
4mo ago

Declared compatibility

Claude CodeClaude DesktopCursorWindsurf

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Puck? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Puck

X/Twitter MCP Connector

"Lord, what fools these mortals be!"


Puck is an MCP server that exposes the X (Twitter) API v2 as tools. It handles OAuth 2.0 PKCE with automatic token rotation, rate limit tracking, image uploads, and thread construction so consuming applications don't have to.

Named for the mischievous sprite from Shakespeare's A Midsummer Night's Dream — quick, everywhere at once, short utterances that cause outsized reactions.

Quick Start

1. X Developer Setup

  1. Create a project at developer.x.com
  2. Select Basic tier ($200/mo) or higher — Free tier is insufficient for meaningful use
  3. Create an OAuth 2.0 App with Type: "Web App" (for PKCE flow)
  4. Add http://localhost:3000/oauth/callback as a redirect URI
  5. Note your Client ID (public) — no client secret needed for PKCE

2. MCP Configuration

Add Puck to your MCP client configuration:

{
  "mcpServers": {
    "puck": {
      "command": "npx",
      "args": ["@ticktockbent/puck"],
      "env": {
        "PUCK_CLIENT_ID": "your_oauth2_client_id"
      }
    }
  }
}

3. First Run

On first connection, Puck opens your browser for X OAuth consent. Once authorized, tokens are encrypted and stored locally at ~/.puck/tokens.json. Access tokens refresh automatically (2-hour expiry with rotating refresh tokens). Subsequent runs authenticate silently.

Environment Variables

| Variable | Required | Description | |----------|----------|-------------| | PUCK_CLIENT_ID | Yes | X OAuth 2.0 Client ID | | PUCK_REDIRECT_URI | No | OAuth callback URI (default: http://localhost:3000/oauth/callback) | | PUCK_TOKEN_PATH | No | Token storage location (default: ~/.puck/tokens.json) | | PUCK_API_TIER | No | API tier: free, basic, pro, enterprise (default: basic) | | PUCK_LOG_LEVEL | No | Logging level (default: info) |

Tools

Authentication

| Tool | Description | |------|-------------| | puck_auth_status | Check authentication state, username, scopes, token expiry, and API tier | | puck_auth_logout | Revoke tokens and clear stored credentials | | puck_rate_status | Show current rate limit state across all tracked endpoint groups |

Posts

| Tool | Description | |------|-------------| | puck_post_create | Create a post (supports text, polls, reply settings, quote tweets, media) | | puck_post_edit | Edit a post within the 30-minute / 5-edit window | | puck_post_delete | Delete a post | | puck_post_get | Get a post by ID with full field expansion | | puck_post_lookup | Batch lookup posts by IDs (up to 100) |

Threads

| Tool | Description | |------|-------------| | puck_thread_create | Create a thread from an array of post objects (handles chained reply IDs automatically) | | puck_thread_get | Get all posts in a thread by conversation ID |

Media

| Tool | Description | |------|-------------| | puck_media_upload | Upload images (JPG, PNG, WebP, up to 4 files, max 5MB each) with optional alt text | | puck_media_status | Check processing status of an uploaded media item |

Timelines

| Tool | Description | |------|-------------| | puck_timeline_user | Get a user's posts by user ID or @username | | puck_timeline_mentions | Get the authenticated user's mentions |

Architecture

src/
├── index.ts              # MCP server entry point (stdio transport)
├── types.ts              # TypeScript interfaces and X API types
├── auth/
│   ├── oauth2-pkce.ts    # OAuth 2.0 PKCE flow, browser consent, token exchange
│   ├── token-manager.ts  # Proactive refresh, rotation handling, deduplication
│   └── storage.ts        # Encrypted token storage (~/.puck/)
├── client/
│   ├── x-api.ts          # X API v2 client wrapper (all calls route through here)
│   ├── rate-limiter.ts   # Per-endpoint rate limit tracking from response headers
│   ├── media.ts          # Image upload pipeline
│   └── fields.ts         # Field/expansion constants for v2 response shaping
├── tools/
│   ├── auth.ts           # Auth status, logout, rate status tools
│   ├── posts.ts          # Post CRUD and thread construction
│   ├── media.ts          # Media upload tools
│   └── timelines.ts      # Timeline and mentions tools
└── util/
    ├── character-count.ts # Accurate post length calculation (URLs=23, emoji=2)
    ├── pagination.ts      # Pagination helper
    └── errors.ts          # Typed error classes and normalizer

Key Design Decisions

  • Stateless — No caching of API responses. Each tool call hits the X API directly. Rate limit state is the sole exception.
  • Single account — One X account per server instance. Run multiple instances for multiple accounts.
  • V2 only — No v1.1 endpoints. The entire API surface uses api.x.com/2/.
  • Response-header rate limiting — Rate limits are tracked from x-rate-limit-* response headers. No pre-seeding, no guessing. Only blocks when headers confirm the window is exhausted.
  • Proactive token refresh — Access tokens expire every 2 hours. Puck refreshes when <15 minutes remain rather than waiting for a 401.
  • Atomic token persistence — Refresh tokens are single-use with rotation. Puck writes to a temp file then fs.renameSync() to prevent the "lost refresh token" failure mode.
  • Thread partial failure recovery — If a thread fails mid-creation, the successfully posted portion is returned with failure metadata.
  • Encrypted storage — Tokens at rest are AES-256-CBC encrypted using a machine-specific derived key.

Error Handling

All tools return consistent error shapes:

{
  "error": "rate_limited",
  "message": "POST /2/tweets rate limit reached (100/window). Resets at 2026-02-25T15:30:00Z.",
  "retryAfter": 340,
  "endpoint": "POST /2/tweets"
}

| Error Code | Meaning | |------------|---------| | not_found | Post or user doesn't exist | | rate_limited | Endpoint rate limit hit (includes retryAfter) | | auth_failed | Token expired/revoked and refresh failed | | auth_required | Not authenticated | | forbidden | Insufficient permissions or tier | | invalid_request | Bad parameters | | content_too_long | Post exceeds 280 characters | | media_failed | Media upload or processing failed | | api_error | X API error (details included) |

OAuth Scopes (Phase 1)

| Scope | Purpose | |-------|---------| | tweet.read | Read posts and timelines | | tweet.write | Create and delete posts | | users.read | User profiles (required by most endpoints) | | media.write | Upload media | | offline.access | Receive refresh tokens |

Future phases will request additional scopes as features are added.

Testing Without API Access

X does not offer a sandbox environment for the core API. Here are your options for testing:

Unit tests (no API needed):

npm test

All 57 unit tests run against mocked data with zero API calls.

Mock server (no API needed): Mockoon provides a pre-built X API v2 mock that runs locally. Point twitter-api-v2 at http://localhost:your-port for integration testing without credentials.

Free tier (limited, may be discontinued): The Free tier ($0) allows OAuth authentication, POST /2/tweets (create), and DELETE /2/tweets/:id (delete) — but no read endpoints. You can verify the OAuth flow works and that posts are created/deleted. As of February 2026, X is transitioning to pay-per-use and the free tier may no longer be available.

VCR/cassette recording (one-time API access): Record real API responses once, replay them in tests forever. This is the approach used by Tweepy and other major Twitter libraries. If you have even temporary API access, this is the gold standard.

Recommended approach: Use unit tests + Mockoon for development. Do a single manual smoke test with real credentials before shipping.

Development

# Install dependencies
npm install

# Build
npm run build

# Watch mode
npm run dev

# Run tests
npm test

# Manual smoke test (requires real X API credentials)
PUCK_CLIENT_ID=your_id node dist/index.js

Development Phases

| Phase | Status | Scope | |-------|--------|-------| | 1 | Done | OAuth, post CRUD, threads, image upload, timelines, rate limiting | | 2 | Planned | Video/GIF upload, engagement (likes, retweets, bookmarks), search | | 3 | Planned | Home timeline, DMs, user lookup, follow/mute | | 4 | Planned | Filtered streaming, trends, full-archive search |

License

MIT

References

Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.