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_searchorPOST /api/v1/twitter/searchfor $0.005 per call. - Read a thread or profile with
glim_twitter_getorPOST /api/v1/twitter/getfor $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.
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.
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"}'{
"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.
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"]}'{
"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 for client configuration.
$ claude mcp add -s user -t http glim https://glim.sh/mcp$ codex mcp add glim --url https://glim.sh/mcp$ opencode mcp add$ npx x402-proxy mcp add glim https://glim.sh/mcpHow does glim.sh compare with the official X MCP server?
The official X MCP server 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, 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_cursorascursoron the same request. - Both MCP tools return compact text by default. Pass
formatset tojsonfor structured data. Search results can include asummaryof engagement and atopicsbreakdown. - If you only have a numeric tweet ID, pass it as a quoted string in
ref. - Over REST, a
refthat is not a post URL, numeric ID or profile URL (a bare handle, for example) returns HTTP400with asuggestion. An unknown post or user returns404.
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.