Skip to content

Tool Allow-Listing Fresh

By default, XMCP exposes all X API operations as tools. The X_API_TOOL_ALLOWLIST environment variable restricts which operations are available - the single most important control for limiting what an AI agent can do.

Why allow-list

flowchart TD
    A[XMCP starts] --> B{X_API_TOOL_ALLOWLIST set?}
    B -->|No| C[All 200+ operations become tools]
    B -->|Yes| D[Only listed operations become tools]
    C --> E[Agent can read AND write everything]
    D --> F[Agent limited to the allow-list]

A focused allow-list lets you, for example, grant read-only access while blocking post creation or deletion. This is the recommended posture for any agent you do not fully trust.

How to set it

Add a comma-separated list of operation names to your .env:

bash
X_API_TOOL_ALLOWLIST="createPosts,getUsersByUsername,searchPostsRecent,likePost"

Applied at startup

The allow-list is applied when the OpenAPI spec loads, so restart the server after changing it.

Common allow-list recipes

Read-only research agent

bash
X_API_TOOL_ALLOWLIST=getUsersByUsername,getUsersById,searchPostsRecent,getPostsById,getUsersPosts

Posting / engagement agent

bash
X_API_TOOL_ALLOWLIST=createPosts,likePost,repostPost,getUsersMe,searchPostsRecent

List management agent

bash
X_API_TOOL_ALLOWLIST=createLists,updateLists,addListsMember,removeListsMemberByUserId,getListsMembers

Minimal smoke test

bash
X_API_TOOL_ALLOWLIST=getUsersByUsername,createPosts,searchPostsRecent

Picking operation names

Every allow-list entry is an operation name from the OpenAPI spec - the same names XMCP uses to generate tools. Browse the full set in the Tool Catalog, grouped by resource (Posts, Users, Lists, Direct Messages, Media, Spaces, and more).

A few high-traffic examples:

OperationWhat it does
createPostsCreate a post
deletePostsDelete a post
searchPostsRecentSearch posts from the last 7 days
getUsersByUsernameLook up a user by handle
getUsersMeGet the authenticated user
likePost / unlikePostLike / unlike a post
repostPost / unrepostPostRepost / undo repost
followUser / unfollowUserFollow / unfollow

Verification checklist

  • [ ] X_API_TOOL_ALLOWLIST set with valid operation names
  • [ ] Server restarted after the change
  • [ ] Client now lists only the allowed tools
  • [ ] Write operations excluded if a read-only posture was intended

See also