Skip to main content

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

Environment Variables

Get these credentials from the Twitter Developer Portal. Create a project and app, then generate your API keys and access tokens under the “Keys and tokens” tab.

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:

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_limit to avoid hitting them.
  • Only grant write permissions if the agent needs to post or reply.