Agents And MCP
Use TweetAPI with AI coding agents in two ways: hosted MCP for live docs and read-only API access, and normal SDK/server-side code when the agent is integrating TweetAPI into your app.
Hosted MCP
Connect your agent client to:
https://mcp.tweetapi.com/mcp
Hosted MCP uses dashboard authorization. Adding the MCP server only saves the server
configuration in your agent client. Run the client's MCP login/auth command to open TweetAPI in
the browser, choose the API key that should back the connection, and approve tweetapi:read.
The client stores MCP tokens so the connection survives app and machine restarts.
Live MCP tools are read-only and limited to public customer-facing endpoints. Each live tool call is forwarded to the existing TweetAPI API and consumes normal API quota.
Quick Install
For Codex, run:
codex mcp add tweetapi --url https://mcp.tweetapi.com/mcp
codex mcp login tweetapi
For Claude Code, run:
claude mcp add --transport http --scope user tweetapi https://mcp.tweetapi.com/mcp
claude mcp login tweetapi
Run the commands separately. The add/install command will not open the browser by itself. The login/auth command opens TweetAPI so you can sign in, choose the API key that should back the MCP connection, and approve access.
What You Can Do
- Search current TweetAPI docs.
- Look up endpoint parameters before writing code.
- Run live read-only X/Twitter lookups from your agent chat.
- Use your normal TweetAPI quota and billing.
Requirements
- A TweetAPI account.
- A TweetAPI API key selected during the dashboard approval flow.
- Codex, Claude Code, or another agent client with remote HTTP MCP support.
Install In Codex
Run:
codex mcp add tweetapi --url https://mcp.tweetapi.com/mcp
codex mcp login tweetapi
Run these one at a time. The first command adds the MCP server. The second command opens TweetAPI
to approve MCP access. Choose an existing API key or create an MCP-specific key in the dashboard.
Restart Codex or open a new chat after adding and logging in. In Codex, run /mcp or ask the model
to list the TweetAPI MCP tools.
If you revoke the dashboard connection or delete the API key behind it, clear the stale local client session before reconnecting:
codex mcp logout tweetapi
codex mcp login tweetapi
Then fully restart Codex and start a new chat.
Install In Claude Code
Run:
claude mcp add --transport http --scope user tweetapi https://mcp.tweetapi.com/mcp
claude mcp login tweetapi
Run these one at a time. The first command adds the MCP server. The second command opens the TweetAPI dashboard approval prompt. Do not commit agent configuration files containing tokens or API keys to source control.
If you revoke the dashboard connection, remove the stored TweetAPI MCP auth/session in Claude Code
and run claude mcp login tweetapi again.
Test The Connection
After installing the MCP, start a new chat and ask:
List the TweetAPI MCP tools you can use. Then search the TweetAPI docs for the search endpoint and
explain the required parameters. Do not call any live TweetAPI tools yet.
To test live read-only access, ask:
Use TweetAPI MCP to fetch the public profile for username "tweetapi". Make exactly one live tool
call and show me which tool you used.
Live tool calls consume your normal TweetAPI request quota.
When To Use MCP
Use the hosted MCP when the model needs to inspect current TweetAPI docs, look up endpoint parameters, or make bounded read-only TweetAPI calls during a chat.
Use regular SDK or REST integration code when the model is changing your application. TweetAPI calls should run server-side and read the API key from your server environment.
Safe Agent Prompt
Use TweetAPI to add this feature to my app. Read the TweetAPI key from TWEETAPI_API_KEY on the
server. Do not put API keys, Twitter/X authToken, ct0, proxy credentials, or DM contents in source
code. Use the hosted TweetAPI MCP docs tools before choosing endpoint parameters.
Node.js Example
npm install tweetapi-node
import TweetAPI from "tweetapi-node";
const client = new TweetAPI({ apiKey: process.env.TWEETAPI_API_KEY! });
const result = await client.explore.search({
query: "tweetapi",
type: "Latest",
});
Python Example
pip install tweetapi
import os
from tweetapi import TweetAPI
client = TweetAPI(api_key=os.environ["TWEETAPI_API_KEY"])
result = client.search.search(query="tweetapi", type="Latest")