Skip to main content
Glama
baryhuang

MCP Server - Twitter NoAuth

twitter_post_tweet

Publish tweets directly using a Twitter OAuth2 access token and text content. Integrate with the MCP Server - Twitter NoAuth to enable Twitter API operations without local credential setup.

Instructions

Post a new tweet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe tweet text content
twitter_access_tokenYesTwitter OAuth2 access token

Implementation Reference

  • Core handler function in TwitterClient that performs the HTTP POST to Twitter API v2 /tweets endpoint to create a new tweet, using the provided access token and text.
    def post_tweet(self, text: str) -> str:
        """Post a new tweet
        
        Args:
            text: The tweet text content
        """
        try:
            if not self.access_token:
                return json.dumps({
                    "error": "No valid access token provided. Please refresh your token first.",
                    "status": "error"
                })
            
            logger.debug(f"Posting tweet with text: {text[:30]}...")
            
            # Twitter API v2 create tweet endpoint
            url = f"{self.api_base_url}/tweets"
            
            headers = {
                "Authorization": f"Bearer {self.access_token}",
                "Content-Type": "application/json"
            }
            
            # Create request body
            data = {
                "text": text
            }
            
            response = requests.post(url, headers=headers, json=data)
            response.raise_for_status()
            
            # Return the raw JSON response
            return json.dumps(response.json())
            
        except requests.exceptions.RequestException as e:
            logger.error(f"API request error: {str(e)}")
            return json.dumps({"error": str(e), "status": "error"})
        except Exception as e:
            logger.error(f"Exception in post_tweet: {str(e)}")
            return json.dumps({"error": str(e), "status": "error"})
  • Registers the 'twitter_post_tweet' tool with the MCP server in the list_tools handler, including name, description, and input schema.
    types.Tool(
        name="twitter_post_tweet",
        description="Post a new tweet",
        inputSchema={
            "type": "object",
            "properties": {
                "twitter_access_token": {"type": "string", "description": "Twitter OAuth2 access token"},
                "text": {"type": "string", "description": "The tweet text content"}
            },
            "required": ["twitter_access_token", "text"]
        },
    ),
  • Dispatch logic in the main @server.call_tool() handler that extracts arguments, validates 'text', instantiates TwitterClient, calls post_tweet, and returns the result.
    elif name == "twitter_post_tweet":
        text = arguments.get("text")
        
        if not text:
            raise ValueError("text is required for twitter_post_tweet")
        
        results = twitter.post_tweet(text=text)
        return [types.TextContent(type="text", text=results)]
  • Pydantic-like input schema definition for the tool, specifying required parameters: twitter_access_token and text.
    inputSchema={
        "type": "object",
        "properties": {
            "twitter_access_token": {"type": "string", "description": "Twitter OAuth2 access token"},
            "text": {"type": "string", "description": "The tweet text content"}
        },
        "required": ["twitter_access_token", "text"]
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Post a new tweet' implies a write operation, but it doesn't disclose critical traits such as rate limits, authentication requirements (beyond what's in the schema), potential side effects (e.g., tweet visibility), or error handling. The description is minimal and lacks necessary context for safe and effective use.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description 'Post a new tweet' is extremely concise—a single, front-loaded sentence with zero wasted words. It efficiently communicates the core action without unnecessary elaboration, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a write operation (posting a tweet) with no annotations and no output schema, the description is incomplete. It doesn't cover behavioral aspects like authentication needs, rate limits, or what the tool returns (e.g., tweet ID or success status). For a mutation tool, this leaves significant gaps in understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with clear documentation for both parameters ('text' and 'twitter_access_token'). The description adds no additional meaning beyond what the schema provides, such as format details or constraints. Baseline score of 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Post a new tweet' clearly states the action (post) and resource (tweet), making the purpose immediately understandable. It distinguishes from siblings like 'twitter_reply_to_tweet' by specifying a new tweet rather than a reply, though it doesn't explicitly contrast with other siblings like 'twitter_search_tweets'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing authentication via twitter_access_token), exclusions, or comparisons to siblings like 'twitter_reply_to_tweet' for replying or 'twitter_get_user_tweets' for reading. Usage is implied but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/baryhuang/mcp-twitter-noauth'

If you have feedback or need assistance with the MCP directory API, please join our Discord server