Skip to main content
Glama
xippios-x-mcp

xippios-x-mcp

by xippios

xippios-x

Typed Python client, MCP server and FastAPI routes for X API v2, part of the xippios SDK family. Names and semantics follow the upstream documentation; every response carries its metadata (source, endpoint, retrieved_at, request).

Scope

Of X API v2 the package wraps thirteen reads, with the app's Bearer Token, in four groups of its OpenAPI document (docs/upstream/): Users, Posts, Lists and Usage. Each but one has a task: users by username and by id, a user's posts, posts by id, the recent search, the post counts over the archive and over the last seven days, the Lists that a user owns, a List's posts and its members, the project's usage and the credit balance. A documented choice that a caller of a task cannot make stands here with its public issue:

  • The fields and the expansions of an answer. The tasks fix user.fields, post.fields, list.fields and usage.fields; get_users and get_users_by_ids take the one expansion most_recent_post_id, and no other task takes expansions, a List's owner_id among them; media.fields, poll.fields, place.fields and the counts' search_count.fields are never sent. pagination_token of the search and the counts, X's second name for their next_token, is left out with them (https://github.com/xippios/sdk-x/issues/62).

  • The url of a List's members, other accounts, which get_list_members does not ask for (https://github.com/xippios/sdk-x/issues/23).

  • The Lists that a user follows, the one read without a task: its wrapper get_users_followed_lists stands, but X answered the recorded request with HTTP 403, client-not-enrolled, at the app's level of access (https://github.com/xippios/sdk-x/issues/92).

The package leaves out these reads of the four groups, and all of the other groups:

What the package adds is the check of a call before its request, the pace of one request a second and errors that say what X refused. It writes no query, ranks and stores no post and collects no pages: a conversation is the caller's own search_recent_posts("conversation_id:<id>").

Related MCP server: x-mcp-ai

Install

uv add xippios-x            # client only
uv add "xippios-x[mcp]"     # + MCP server
uv add "xippios-x[http]"    # + FastAPI router

Set X_API_KEY in the environment to your X app's Bearer Token, which X also calls the App only Access Token (Developer Console, Keys and tokens), not the console's API Key, the OAuth 1.0a consumer key. Nothing is read from files.

30-second example

from xippios.x import tasks

users = tasks.get_users(["USDA", "FAO"])  # 0.010 USD a user found
usda = next(user for user in users.data.data if user.username == "USDA")

page = tasks.get_user_posts(usda.id, max_results=10)  # 0.005 USD a post returned
for post in page.data.data or []:
    print(post.created_at, post.public_metrics.like_count, post.text)
print(page.meta.retrieved_at, page.meta.request, page.data.meta.result_count)

older = tasks.get_user_posts(usda.id, pagination_token=page.data.meta.next_token)

Every task returns one page as X sends it, in result.data; a call that returns data spends X credits at the prices of X's pricing page, which each task's docstring names (the page states none for get_usage and get_usage_credits). Paging is the caller's, with the next_token of the previous page's meta. What identifies an answer, usernames, id or query, is positional, and every other argument goes by name. A task sends its one request once, since X bills a read: no error is retried, and RateLimitError.retry_after says how many seconds to wait before the next call.

get_users returns the users found in data and a problem in errors for each username that X does not find, also where it finds none, get_users_by_ids likewise for each user id, and get_posts the posts found and a problem for each id that it does not find; get_user_posts, get_user_owned_lists and get_list_posts raise NotFoundError for a user or a List that X lacks, while get_list_members returns X's page for a List that X lacks, as X sends it. get_user_posts and get_list_posts raise AuthError with X's words for a user or a List whose posts X withholds, a protected user or a private List say. A call that the package refuses before its request raises InvalidRequestError, whose text ends with Nothing was sent.. meta.published_at and meta.vintage stay empty: X states no release time and no release identifier for a page, and each post carries its own created_at.

The thirteen wrappers of xippios.x.api are async and return core's Answer: X's page in payload and the time at which the client got it in retrieved_at, which a task gives as meta.retrieved_at.

MCP

{
  "mcpServers": {
    "x": {
      "command": "uvx",
      "args": ["--from", "xippios-x[mcp]", "xippios-x-mcp"],
      "env": { "X_API_KEY": "..." }
    }
  }
}

xippios-x-mcp serves stdio; --http serves streamable HTTP instead. Tools are read-only and named x_<verb>_<noun>; every call that returns data spends X credits, and each tool's description gives its price (the pricing page states none for x_get_usage and x_get_usage_credits). A tool returns one page, which its result cap holds whole for Latin-script text: up to 100 posts in 140,000 bytes, 100 users or 100 members of a List in 160,000, about 65 users with their most recent posts, and 64 KB for 100 Lists of a user, in any script, and for the counts, which a month of hourly buckets fits. A page of mostly non-Latin text or with long posts, whose whole text comes in note_post, or minute counts over more than about 14 hours, can be cut, with a note on how to see the rest.

Status

Upstream operation

Task function

MCP tool

Status

GET /2/users/by (getUsersByUsernames)

get_users(usernames, expansions)

x_get_users

alpha; 0.010 USD a user, 0.005 USD more with expansions

GET /2/users (getUsersByIds)

get_users_by_ids(ids, expansions)

x_get_users_by_ids

alpha; 0.010 USD a user, 0.005 USD more with expansions

GET /2/users/{id}/tweets (getUsersPosts)

get_user_posts(id, max_results, pagination_token, start_time, end_time, since_id, until_id, exclude)

x_get_user_posts

alpha; 0.005 USD a post

GET /2/tweets (getPostsByIds)

get_posts(ids)

x_get_posts

alpha; 0.005 USD a post

GET /2/tweets/search/recent (searchPostsRecent)

search_recent_posts(query, max_results, next_token, start_time, end_time, since_id, until_id, sort_order)

x_search_recent_posts

alpha; 0.005 USD a post; query of 512 characters at most

GET /2/tweets/counts/all (getPostsCountsAll)

count_posts(query, granularity, next_token, start_time, end_time, since_id, until_id)

x_count_posts

alpha; 0.010 USD a request; query of 1,024 characters at most

GET /2/tweets/counts/recent (getPostsCountsRecent)

count_recent_posts(query, granularity, next_token, start_time, end_time, since_id, until_id)

x_count_recent_posts

alpha; 0.005 USD a request; query of 512 characters at most

GET /2/users/{id}/owned_lists (getUsersOwnedLists)

get_user_owned_lists(id, max_results, pagination_token)

x_get_user_owned_lists

alpha; 0.005 USD a List

GET /2/lists/{id}/tweets (getListsPosts)

get_list_posts(id, max_results, pagination_token)

x_get_list_posts

alpha; 0.005 USD a post

GET /2/lists/{id}/members (getListsMembers)

get_list_members(id, max_results, pagination_token)

x_get_list_members

alpha; 0.010 USD a member, counted as a user

GET /2/usage/tweets (getUsage)

get_usage(days)

x_get_usage

alpha; no price stated

GET /2/usage/credits (getUsageCredits)

get_usage_credits()

x_get_usage_credits

alpha; no price stated

Prices are those of X's pricing page in the snapshot that docs/upstream/FETCHED.md dates (docs/upstream/pages/pricing.md); a post or user read again the same UTC day is not billed again, a counts request always is. A List of a user is billed as List: Read. The page does not say how a List's posts and members are billed, so they are counted as posts and users, the upper bound.

Upstream terms and attribution

Data comes from X API v2 (https://x.com) under the X Developer Agreement and the X Developer Policy, which bind every app that uses it; this package adds no rights to it. Documentation snapshot and its attribution: docs/upstream/FETCHED.md.

Workflows

ci.yml runs ruff, its format check, mypy, pytest and pre-commit on Python 3.12, 3.13 and 3.14, requires a changelog entry of every pull request but Dependabot's and refuses a fixture file over 256 KiB that a pull request adds or changes. It runs on every pull request and, called by publish.yml, once for a release, and its job ci is the check the organization's ruleset requires. It is handed no secret, and no variable switches it off.

publish.yml is the release train (conventions §12): on a push to main whose pyproject.toml names a version that has no tag yet and has its section in CHANGELOG.md, it runs ci.yml, refuses a core pinned to git, tags the merge commit, builds the package and, once a reviewer of the environment pypi approves the run, publishes it to PyPI by trusted publishing. Every push to main and a dispatch start it, and a push that brings no release ends quietly. It is handed no secret: the step that tells a release is handed the job's token as GH_TOKEN, the tag goes with the job's token and PyPI trusts the workflow itself. Its job tag holds the one checkout of the repository that keeps its credentials, since it pushes the tag with the job's token; every other checkout sets persist-credentials: false (conventions §13). No variable switches it off.

live.yml runs every live test against the upstream with --tb=short --assert=plain, so its public log holds neither a failing test's arguments nor the values an assertion compared. It runs every night at 01:24 UTC and on demand, never on a pull request. Each test fails on an empty page. The nightly run spends one billable call, the test whose turn it is by the day's number, so that each of the ten tasks that X bills runs once in ten nights, and reads the usage and the credit balance, for which X's pricing page states no price; the nine other tests skip there, and every test runs on demand. Its pytest step alone is handed XIPPIOS_LIVE_TESTS and, each from the secret of the same name, X_API_KEY, so the checkout, setup-uv and uv sync see none. A variable WORKFLOW_LIVE of off, the repository's over the organization's, switches it off.

conventions.yml calls the organization's review of a pull request against the documents listed under Documents below, the check conventions / conventions, when a pull request opens, is pushed to, reopens or is edited, and on a push to main or a dispatch the review of the range of commits, range / range. It hands the review the organization's secret of the model's key, by name. A variable WORKFLOW_CONVENTIONS of off, the repository's over the organization's, switches both off.

adr-index.yml calls the organization's check of the ADR index, adr-index / adr-index, which runs scripts/adr_index.py --check, when a pull request opens, is pushed to or reopens. It hands over nothing, and the called workflow reads its switch itself: a variable WORKFLOW_ADR_INDEX of off, the repository's over the organization's, skips the check.

Documents

  • sdk-core: docs/conventions.md — the conventions every xippios source package follows: its layout, names, results, tests and releases.

  • sdk-core: docs/adr.md — the index of the family's architecture decisions, which the conventions cite.

  • sdk-core: docs/definition-of-done.md — what a change satisfies before its pull request is opened.

  • sdk-core: docs/review-checklist.md — what the review of a pull request checks, in order.

  • sdk-x: docs/adr.md — the index of this package's own decisions, generated from the records in docs/adr/.

  • sdk-x: docs/upstream/FETCHED.md — the snapshot of the upstream documentation, the reference for names, parameters and semantics.

  • sdk-x: docs/upstream/OBSERVED.md — what X does but never documents, each note with its request and its date.

Licence

Apache-2.0. See LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A read-only X/Twitter MCP server that enables data retrieval for user profiles, tweets, and social graphs using OAuth 2.0 Bearer Token authentication. It supports searching recent tweets, viewing timelines, and tracking engagement metrics like followers, likes, and retweets.
      3
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables MCP clients to interact with the X (Twitter) API v2 through 41 typed tools for reading, searching, engaging, publishing, and managing content, with policy-based access control and session credit budgets to prevent overspending.
      41
      51 npm
      1
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Enables access to the X API v2 through MCP, covering 175 of 190 published operations with tools for browsing, calling, posting, searching, and managing posts.
      7
      11 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables read-only access to X API v2 data through official xurl OAuth credentials, with structured tools for posts, users, timelines, search, conversations, media metadata, and account credit status. It returns consistent JSON envelopes with pagination and classified errors while excluding write actions and secondary token storage.
      7
      MIT