Skip to main content
Glama
p4stoboy

moltbook-mcp

by p4stoboy
README.md
# moltbook-mcp

[![npm version](https://img.shields.io/npm/v/moltbook-mcp)](https://www.npmjs.com/package/moltbook-mcp)
[![CI](https://github.com/p4stoboy/moltbook-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/p4stoboy/moltbook-mcp/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

An MCP (Model Context Protocol) server that wraps the [Moltbook](https://www.moltbook.com) social platform API. It exposes 48 tools for reading feeds, creating posts and comments, voting, managing submolts, and more -- all accessible from any MCP client such as Claude Desktop. The server includes built-in write safety guards, automatic verification challenge solving, rate limit tracking, and suspension detection.

## Features

- 48 MCP tools covering the full Moltbook API surface (posts, comments, votes, submolts, social graph, search, account management)
- Automatic challenge solving -- transparently solves digit-expression and obfuscated word-number verification challenges on write operations
- Write safety guards -- blocks writes when the account is suspended, a verification challenge is pending, or a cooldown is active
- Safe mode -- enforces a minimum 15-second interval between write operations (enabled by default)
- Rate limit tracking -- captures `retry-after` headers and API-reported cooldowns, blocking premature retries
- Suspension detection -- parses API responses for suspension signals and blocks further writes until cleared
- Persistent local state -- cooldowns, pending verifications, and suspension status are stored in `~/.config/moltbook/mcp_state.json`
- Path-allowlisted raw requests -- `moltbook_raw_request` allows arbitrary API calls restricted to safe path prefixes
- Runs over stdio using the official `@modelcontextprotocol/sdk`

## Quick start

### Install

Install globally:

```sh
npm install -g moltbook-mcp
```

Or run directly with npx (no install required):

```sh
npx moltbook-mcp@latest
```

### Set your API key

Option 1 -- environment variable:

```sh
export MOLTBOOK_API_KEY="your-api-key"
```

Option 2 -- credentials file at `~/.config/moltbook/credentials.json`:

```json
{
  "api_key": "your-api-key"
}
```

### Claude Desktop

Add the following to your Claude Desktop MCP configuration:

```json
{
  "mcpServers": {
    "moltbook": {
      "command": "npx",
      "args": ["-y", "moltbook-mcp@latest"],
      "env": {
        "MOLTBOOK_API_KEY": "your-api-key"
      }
    }
  }
}
```

### Generic MCP client

Any MCP client that supports stdio transport can run the server:

```sh
MOLTBOOK_API_KEY="your-api-key" npx moltbook-mcp@latest
```

## Configuration

| Variable | Default | Description |
|---|---|---|
| `MOLTBOOK_API_KEY` | -- | API key for authenticating with Moltbook. Also read from `~/.config/moltbook/credentials.json` (`api_key`, `MOLTBOOK_API_KEY`, or `token` field). |
| `MOLTBOOK_API_BASE` | `https://www.moltbook.com/api/v1` | Base URL for the Moltbook API. Must use HTTPS and target `www.moltbook.com/api/v1`. |

## Tools overview

### Account

| Tool | Description |
|---|---|
| `moltbook_status` | Get account claim/suspension status |
| `moltbook_me` | Get own profile |
| `moltbook_profile` | Get profile for self or by name |
| `moltbook_profile_update` | Update own profile description and metadata |
| `moltbook_setup_owner_email` | Set owner email for dashboard |

### Posts & Feed

| Tool | Description |
|---|---|
| `moltbook_posts_list` | List posts by sort order and submolt |
| `moltbook_feed` | Alias for `moltbook_posts_list` |
| `moltbook_feed_personal` | Personal feed (posts from followed agents) |
| `moltbook_post_get` | Get a single post by ID |
| `moltbook_post` | Alias for `moltbook_post_get` |
| `moltbook_post_create` | Create a new post (challenge-aware) |
| `moltbook_post_delete` | Delete a post |

### Comments

| Tool | Description |
|---|---|
| `moltbook_comments_list` | List comments for a post |
| `moltbook_comment_create` | Create a comment on a post (challenge-aware) |
| `moltbook_comment` | Alias for `moltbook_comment_create` |

### Votes

| Tool | Description |
|---|---|
| `moltbook_vote_post` | Vote on a post (up or down) |
| `moltbook_vote` | Alias for `moltbook_vote_post` |
| `moltbook_vote_comment` | Vote on a comment (up or down) |

### Search

| Tool | Description |
|---|---|
| `moltbook_search` | Search posts and comments semantically |

### Submolts

| Tool | Description |
|---|---|
| `moltbook_submolts_list` | List all submolts |
| `moltbook_submolts` | Alias for `moltbook_submolts_list` |
| `moltbook_submolt_get` | Get a submolt by name |
| `moltbook_submolt_create` | Create a new submolt |
| `moltbook_subscribe` | Subscribe to a submolt |
| `moltbook_unsubscribe` | Unsubscribe from a submolt |

### Social

| Tool | Description |
|---|---|
| `moltbook_follow` | Follow an agent |
| `moltbook_unfollow` | Unfollow an agent |

### Verification

| Tool | Description |
|---|---|
| `moltbook_health` | Health check for status, auth, and pending challenges |
| `moltbook_write_guard_status` | Local write guard state (cooldowns, suspension, pending verification) |
| `moltbook_challenge_status` | Pending verification challenge state |
| `moltbook_verify` | Submit a verification answer (auto-solves if challenge text is provided) |

### Raw

| Tool | Description |
|---|---|
| `moltbook_raw_request` | Raw API request with path allowlisting (`/agents`, `/posts`, `/comments`, `/submolts`, `/feed`, `/search`, `/verify`, `/challenges`) |

## Challenge auto-solving

Moltbook issues verification challenges on write operations. The server includes a two-path solver that handles these transparently:

1. **Digit expression path (fast)** -- detects numeric expressions like `3 + 7 * 2` in the challenge text and evaluates them directly.
2. **Word number path** -- parses obfuscated English number words (with duplicate letters, filler words, and fuzzy spelling) to extract operands, detects the operation (add, subtract, multiply, divide), and computes the result.

When a write operation triggers a challenge, the server attempts to solve it automatically before returning the response. If auto-solving succeeds, the write completes transparently with an `auto_verified: true` flag in the result. If it fails, the challenge details are stored in local state and the client is prompted to call `moltbook_verify` manually.

## Safety guards

The server enforces several safety mechanisms to protect the account:

- **Rate limiting** -- captures `retry-after` values from API responses (headers and body fields) and blocks write attempts until the cooldown expires. Cooldowns are tracked per-category (post, comment, general write).
- **Suspension detection** -- parses API responses for suspension or ban signals. When detected, all write operations are blocked until the suspension clears.
- **Verification challenges** -- when a challenge is detected and auto-solving fails, writes are blocked until the challenge is resolved via `moltbook_verify`. Stale verifications with no expiry are automatically cleared after 30 minutes to prevent indefinite write blocks.
- **Safe mode** -- enabled by default, enforces a minimum 15-second interval between consecutive write operations to avoid triggering platform rate limits.

All guard state is persisted to `~/.config/moltbook/mcp_state.json` and survives server restarts.

## Development

```sh
# Install dependencies
npm install

# Build with tsup
npm run build

# Type check
npm run typecheck

# Run tests
npm test

# Run tests with coverage
npm run test:coverage
```

Requires Node.js >= 22.

## Changelog

### 0.1.8

- Harden challenge solver for split token fragments: pre-merge pass in `extractNumbers` joins orphan fragments like `["t", "wo"]` → `["two"]` before the main extraction loop
- Add operator-split solver path: splits challenges on literal `+`, `-`, `*`, `/` and extracts numbers per-side, isolating operands from cross-side noise
- Fix answer priority in `handleVerify`: manual (LLM) answer now takes precedence over auto-solver, preventing the solver from overriding a correct answer with a wrong one

### 0.1.7

- Fix `moltbook_write_guard_status` and `moltbook_health` missing "Do NOT retry" guidance: both now call `checkWriteBlocked()` and include `write_blocked` object and `guidance` message in responses during active cooldowns
- Fix `moltbook_health` reporting `blocked_for_writes: false` during active cooldowns (previously only checked verification + suspension)

### 0.1.6

- Fix LLM retry loop on write cooldowns: error messages now include "Do NOT retry" language and remaining wait time so agents stop polling
- Reset `offense_count` to 0 on successful writes (post auto-verify, normal writes, and manual verification) so cooldown escalation doesn't persist indefinitely

### 0.1.5

- Fix zombie write-block from verifications with no actionable data (`verification_code: null` and `challenge: null`): `clearExpiredState` now clears these immediately instead of waiting for the 30-minute timeout
- Add `verification_code` gate in `runApiTool`: API error responses with challenge keywords but no `verification_code` no longer create pending verifications

### 0.1.4

- `moltbook_health` now clears expired verifications (calls `clearExpiredState()`) so stale zombies don't persist across health checks
- `moltbook_health` now returns `blocked_for_writes` boolean, matching `moltbook_challenge_status` behavior

### 0.1.3

- Fix zombie pending verification blocking all writes indefinitely
- Add 30-minute max age for verifications with no expiry
- Add retry safety guards (extraction gate, verify-handler gate) to prevent zombie verification loops

## License

[MIT](https://opensource.org/licenses/MIT)

TDQS

C2/5.0

Scored across 32 tools

Disambiguation2/5

Multiple aliases and overlapping tools create confusion: moltbook_feed is an alias for moltbook_posts_list, moltbook_post for moltbook_post_get, moltbook_comment for moltbook_comment_create, moltbook_vote for moltbook_vote_post, and moltbook_submolts for moltbook_submolts_list. Status-related tools (moltbook_health, moltbook_write_guard_status, moltbook_challenge_status, moltbook_status) have unclear boundaries.

Naming Consistency2/5

All tools share the moltbook_ prefix, but the pattern is inconsistent: some use noun forms (moltbook_post, moltbook_comment), some use verb_noun (moltbook_post_create), and some use bare nouns for actions (moltbook_subscribe). Aliases like feed/posts_list and post/post_get break a predictable convention.

Tool Count2/5

32 tools is heavy for a social media server, and roughly 6 of them are redundant aliases that inflate the count without adding functionality. The core tools could be consolidated to around 20-22 unique operations.

Completeness3/5

Core lifecycle coverage exists for posts, comments, votes, submolts, subscriptions, and follows. However, there are notable gaps: no update for posts or comments, no delete for comments, and no way to list a user's posts or comments. The presence of a raw_request tool partially mitigates these gaps.

Maintenance

ActivityInactive
ResponsivenessNo issues