FetchLayer fetchlayer.dev Sign in

Integration Guide

Twitter/X Agent Skill: Give Your AI Agent Live Twitter Access

Build a Twitter/X agent skill that lets Claude, Cursor, or your AI agent search tweets, fetch profiles, and read replies without API rate limits.

Written by Alex P.

  • twitter agent skill
  • AI agent
  • MCP
  • twitter scraping
  • X scraping
  • agent tools

If you’re searching for a Twitter/X agent skill, what you usually want is simple: give an AI agent the ability to search tweets, open profiles, inspect replies, and pull follower data on demand.

There are two practical ways to do that:

  1. Connect Twitter as an MCP tool so the agent can call it directly.
  2. Wrap a Twitter data API as a custom tool/function inside your own agent framework.

Both approaches work. The important part is choosing a data source that doesn’t fall apart the moment you need real coverage.


What a Twitter/X Agent Skill Actually Is

“Agent skill” is overloaded. Depending on the platform, it usually means one of these:

  • A tool your AI agent can call
  • An MCP server the agent can use
  • A function/action in an agent framework
  • A reusable prompt + tool bundle for a repeated workflow

For Twitter/X, the skill is usually some combination of:

  • Search tweets by keyword
  • Get tweet details and replies
  • Look up a user profile
  • Pull a user’s recent tweets
  • Get follower/following lists
  • Summarize or extract patterns from the results

The reasoning layer is the easy part. The hard part is the data layer.


Why X’s Official API Is a Bad Foundation

You can build a Twitter skill on top of X’s official API, but it’s a weak foundation for agents:

  • Pricing is steep. $100/month for Basic (10K posts/mo read), $5,000/month for Pro (1M posts/mo). No free tier for production use.
  • Rate limits are aggressive. Even on paid tiers, endpoints have strict per-15-minute caps.
  • OAuth is mandatory. You need a developer account, project setup, API key, secret, access token, and token secret.
  • No follower/following graph access on Basic tier. You need Pro or Enterprise for network endpoints.
  • Approval is not guaranteed. X can reject or suspend developer access.

That matters more for agents than it does for a quick script. Agents need predictable access to data when a user asks a question. If the tool returns rate-limited errors, partial threads, or can’t access follower data, the agent’s output degrades fast.


Best Setup: Twitter Skill via MCP

If your agent platform supports MCP, this is the cleanest setup.

FetchLayer exposes Twitter/X through an MCP server at https://mcp.fetchlayer.dev. Once connected, the agent can call Twitter tools directly without you building scraper infrastructure or dealing with X auth.

MCP config

{
  "mcpServers": {
    "fetchlayer": {
      "url": "https://mcp.fetchlayer.dev",
      "headers": {
        "Authorization": "Bearer sk-your-api-key"
      }
    }
  }
}

Once that is in place, your agent gets access to tools for:

  • Searching tweets by keyword (Top, Latest, People, Media, Lists)
  • Fetching tweet details by ID
  • Getting replies to any tweet
  • Looking up user profiles
  • Pulling a user’s recent tweets and replies
  • Getting follower/following lists
  • Fetching verified followers

Example prompts

Search X/Twitter for posts about "best applicant tracking software" from the last month and summarize the common complaints.
Get the profile and recent tweets from @levelsio. What topics does he tweet about most?
Open this tweet, read the full replies, and extract feature requests people keep repeating.
Find verified followers of @openai and tell me which companies and well-known founders are in that list.

This is the lowest-friction path if you’re using Cursor, Claude Desktop, Claude Code, Windsurf, VS Code, or another MCP-capable tool.


Alternative: Build the Skill as a Direct Tool

If your agent framework doesn’t support MCP, expose Twitter as a normal tool that hits the FetchLayer API.

Example tool implementation

async function searchTwitter({ query, product = 'Top', count = 10 }) {
  const res = await fetch('https://api.fetchlayer.dev/twitter/search', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.FETCHLAYER_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ query, product, count })
  });
  return res.json();
}

async function getTweetDetail({ tweetId }) {
  const res = await fetch('https://api.fetchlayer.dev/twitter/tweet-detail', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.FETCHLAYER_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ tweetId })
  });
  return res.json();
}

async function getUserProfile({ handle }) {
  const res = await fetch('https://api.fetchlayer.dev/twitter/user-profile-details', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.FETCHLAYER_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ handle })
  });
  return res.json();
}

Register these as tools in your agent framework (LangChain, Vercel AI SDK, CrewAI, custom loop, etc.) and the agent can use them like any other function.


Which Approach Should You Use?

MCP setup is best if your agent platform supports it. One config block, all 10 endpoints, no code.

Direct API tool is best if you’re building a custom agent loop or your framework doesn’t do MCP.

Both approaches use the same underlying API — the difference is how the tools are registered and called.


What’s Next