Overview
Build an autonomous agent that connects to Twitter/X, collects social data — mentions, keyword trends, engagement metrics — and generates analytics reports in your workspace.This example uses
@enescinar/twitter-mcp, a community-maintained MCP server — not an official Twitter/X product. Review the package source and permissions before providing your API credentials.Prerequisites
- A Twitter Developer Account with API access
- API Key, API Secret, Access Token, and Access Token Secret from the Developer Portal
- Node.js installed (for
npx)
Environment Variables
Installation
Example: Brand Sentiment Report
The agent searches for mentions of a brand or keyword, performs sentiment analysis, and generates a report with CSV data.Example: Competitor Monitoring Dashboard
The agent tracks multiple competitors and creates a comparative analysis report.Available Tools
Twitter MCP servers typically expose tools including:| Tool | Description |
|---|---|
search_tweets | Search for tweets by keyword or query |
post_tweet | Post a new tweet |
get_user_tweets | Get recent tweets from a user |
get_mentions | Get mentions of the authenticated user |
reply_to_tweet | Reply to a specific tweet |
get_tweet | Get details of a specific tweet |
Security Notes
- Use a dedicated Twitter app with read-only permissions for analytics agents.
- Store all API keys and tokens in
.env— never hardcode them. - Twitter API has rate limits — set appropriate
tool_call_limitto avoid hitting them. - Only grant write permissions if the agent needs to post or reply.

