Google ADK Integration

Give a Google ADK agent
a Twitter tool

Attach the OpenTweet MCP server with McpToolset for all 36 tools, or wrap the REST API in a FunctionTool for a single post action. Your ADK agent posts, schedules, and threads on X. No X developer account, no OAuth, no per-post billing.

Get your API key

7-day free trial. No X developer account needed.

What your ADK agent can do on X

Take the whole toolset through MCP, or wrap just the action you need.

Post now

create_tweet publishes immediately when the agent decides to.

Schedule

schedule_tweet and batch_schedule queue posts for later.

Threads

create_thread publishes a connected thread in one call.

MCP native

McpToolset pulls all 36 OpenTweet tools with zero tool code.

Analytics

Analytics tools let the agent read results and adapt.

No X API

No developer account, no OAuth, no token refresh to build.

Option 1: McpToolset, all 36 tools

ADK connects to remote MCP servers with McpToolset and StreamableHTTPConnectionParams. Point it at the hosted OpenTweet endpoint with your key in the Authorization header, and the agent gets create_tweet, create_thread, schedule_tweet, batch_schedule, create_article, evergreen and analytics tools.

from google.adk.agents import Agent
from google.adk.tools.mcp_tool import McpToolset, StreamableHTTPConnectionParams

opentweet = McpToolset(
    connection_params=StreamableHTTPConnectionParams(
        url="https://mcp.opentweet.io/mcp",
        headers={"Authorization": "Bearer ot_your_api_key"},
    )
)

agent = Agent(
    model="gemini-2.0-flash",
    name="x_poster",
    instruction="You post, schedule, and thread on X for the user.",
    tools=[opentweet],
)

# "Draft a 4-tweet thread about our launch and schedule it for 9am UTC tomorrow."

Full tool list and payloads are in the MCP docs.

Option 2: a FunctionTool over the REST API

When the agent only needs to post, wrap the OpenTweet REST call in a plain Python function and hand it to the model as a FunctionTool. The docstring becomes the tool description ADK shows the model.

import os, requests
from google.adk.agents import Agent
from google.adk.tools import FunctionTool

def post_tweet(text: str) -> dict:
    """Publish a tweet to X (Twitter) immediately."""
    res = requests.post(
        "https://opentweet.io/api/v1/posts",
        headers={"Authorization": f"Bearer {os.environ['OPENTWEET_API_KEY']}"},
        json={"text": text, "publish_now": True},
        timeout=30,
    )
    res.raise_for_status()
    return res.json()

agent = Agent(
    model="gemini-2.0-flash",
    name="x_poster",
    instruction="Write and post short tweets when asked.",
    tools=[FunctionTool(post_tweet)],
)

To schedule instead of posting now, send scheduled_date (ISO 8601) in place of publish_now. See the API docs for every field.

Perfect for

Gemini-powered content agents

A Gemini agent researches a topic and schedules a week of posts through batch_schedule.

Multi-agent workflows

A writer agent drafts, a reviewer agent approves, and the OpenTweet tool publishes the result.

Cloud Run deployments

Run the ADK agent on Cloud Run and let it post release and status updates on a schedule.

Ops and alerting bots

An agent watching your systems posts incident updates to X the moment they happen.

The same hosted MCP server also works with Claude Code, OpenAI Codex, and the Vercel AI SDK.

Frequently asked questions

How does a Google ADK agent post to Twitter?

Attach the OpenTweet MCP server to your agent with McpToolset and StreamableHTTPConnectionParams pointed at the hosted endpoint. The agent gets 36 tools for posting, scheduling, threads, articles, and analytics. Alternatively, wrap the OpenTweet REST API in a FunctionTool for a single post action.

MCPToolset or a FunctionTool, which should I use?

Use McpToolset when you want the full surface: scheduling, threads, batch scheduling, articles, and analytics arrive with zero tool code. Wrap the REST API in a FunctionTool when your agent only needs to post a tweet and you want tight control over the single function signature the model sees.

Do I need an X (Twitter) developer account?

No. OpenTweet manages the X connection, OAuth, and token refresh. Your ADK agent authenticates to OpenTweet with one ot_ bearer key, and OpenTweet posts to X. You never touch the pay-per-use X API or a developer application.

Which transport does the OpenTweet MCP server use?

Streamable HTTP. In ADK, connect with StreamableHTTPConnectionParams and pass the OpenTweet URL plus an Authorization header carrying your ot_ key. This is the modern remote-MCP transport ADK supports.

Can the agent schedule tweets instead of posting now?

Yes. The MCP toolset includes schedule_tweet and batch_schedule, so the model can queue posts for a future time. Threads and articles use create_thread and create_article. With the REST FunctionTool, send scheduled_date instead of publish_now.

What does it cost?

OpenTweet plans start at $11.99/month with a 7-day free trial. There is no per-post charge at normal volumes, unlike the pay-per-use X API. See the pricing page for current plans.

Ship an ADK agent that posts to X

Connect X, copy your key, and attach the toolset today.

Start your 7-day free trial