# X (Twitter) MCP server and API for agents

Search X posts by keyword, then follow a result to read its thread or the author's timeline. The glim.sh Twitter MCP server exposes two read-only tools. Both also have REST endpoints.

## Twitter API pricing on glim.sh

- Search posts with `glim_twitter_search` or `POST /api/v1/twitter/search` for $0.005 per call.
- Read a thread or profile with `glim_twitter_get` or `POST /api/v1/twitter/get` for $0.005 per call.

The REST examples use a glim.sh API key. You can also pay from a wallet without a key. See [Payments and authentication](https://glim.sh/docs/payments.md).

## Search X posts by author, keyword and date

Use `from:` to search one account and `min_faves:` to set a minimum like count. This request looks for recent posts from @cascade_fyi that mention x402. The default sort is `top`. Choose `latest` for newest first, or add `start_date` and `end_date` to limit the time range.

**Search posts with REST**

```
curl -X POST https://glim.sh/api/v1/twitter/search \
  -H "x-api-key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"from:cascade_fyi x402","sort":"latest"}'
```

**Search posts with MCP (tools/call parameters)**

```
{
  "name": "glim_twitter_search",
  "arguments": { "query": "from:cascade_fyi x402", "sort": "latest" }
}
```

## Read a tweet thread or a profile timeline

Pass a post URL to get the tweet and its thread context. Add `replies` or `quotes` to the `include` list to read responses alongside it. A profile URL returns the user and recent posts. For a profile, set `include_replies` to include replies in the timeline or `include_mentions` to fetch mentions.

**Read a thread with REST**

```
curl -X POST https://glim.sh/api/v1/twitter/get \
  -H "x-api-key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ref":"https://x.com/karpathy/status/1585841080431321088","include":["replies","quotes"]}'
```

**Read a profile with MCP (tools/call parameters)**

```
{
  "name": "glim_twitter_get",
  "arguments": { "ref": "https://x.com/cascade_fyi", "include_mentions": true }
}
```

## Connect the glim.sh MCP server for X

Add `https://glim.sh/mcp` to your MCP client. To expose just the Twitter search and get tools, use `https://glim.sh/mcp?tools=glim_twitter_search,glim_twitter_get`. See the [MCP quickstart](https://glim.sh/docs/quickstart.md) for client configuration.

- **Claude Code**: `claude mcp add -s user -t http glim https://glim.sh/mcp`
- **Codex**: `codex mcp add glim --url https://glim.sh/mcp`
- **OpenCode**: `opencode mcp add`
  Interactive: choose remote, paste https://glim.sh/mcp
- **Wallet**: `npx x402-proxy mcp add glim https://glim.sh/mcp`
  No account: your agent pays per call in USDC (x402) from a local wallet, auto-generated on first run.

## How does glim.sh compare with the official X MCP server?

The [official X MCP server](https://docs.x.com/tools/mcp) supports post search and account actions such as adding bookmarks with user authorization. Use glim.sh for read-only research without registering an X app.

Under [X API pricing](https://docs.x.com/x-api/getting-started/pricing), reads consume prepaid credits per resource returned. On glim.sh the unit is one search or get call, including when a search returns multiple posts.

## Good to know

- For another page of search results or a profile timeline, pass the returned `next_cursor` as `cursor` on the same request.
- Both MCP tools return compact text by default. Pass `format` set to `json` for structured data. Search results can include a `summary` of engagement and a `topics` breakdown.
- If you only have a numeric tweet ID, pass it as a quoted string in `ref`.
- Over REST, a `ref` that is not a post URL, numeric ID or profile URL (a bare handle, for example) returns HTTP `400` with a `suggestion`. An unknown post or user returns `404`.

## FAQ

### Do I need an X developer account or a Twitter API key?

No. Your client authenticates with glim.sh. Use a funded glim.sh account or pay per call with a wallet.

### Can my agent post or reply on X?

No. The two tools read posts, replies, quotes and profiles. Neither tool publishes a post or sends a message.

---

## All docs pages


**Get started**

- [Introduction](https://glim.sh/docs.md)
- [MCP quickstart](https://glim.sh/docs/quickstart.md)
- [REST API quickstart](https://glim.sh/docs/quickstart-rest.md)
- [JavaScript quickstart](https://glim.sh/docs/quickstart-javascript.md)
- [Python quickstart](https://glim.sh/docs/quickstart-python.md)
- [Payments & auth](https://glim.sh/docs/payments.md)
- [MPP (Tempo)](https://glim.sh/docs/mpp.md)

**Tools**

- [Twitter / X](https://glim.sh/docs/twitter.md)
- [Reddit](https://glim.sh/docs/reddit.md)
- [Web](https://glim.sh/docs/web.md)
- [GitHub](https://glim.sh/docs/github.md)
- [Amazon](https://glim.sh/docs/amazon.md)
- [YouTube](https://glim.sh/docs/youtube.md)
- [Telegram](https://glim.sh/docs/telegram.md)

**Reference**

- [Changelog](https://glim.sh/docs/changelog.md)
- [API reference](https://glim.sh/docs/api-reference)
- [OpenAPI spec](https://glim.sh/openapi.json)
