MCP_Server_Model_Twitter

Ujjwal3115/MCP_Server_Model_Twitter

3.2

If you are the rightful owner of MCP_Server_Model_Twitter and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This project demonstrates a simple client-server application using the Model Context Protocol (MCP) with Google Gemini AI and Twitter API integration.

Tools
  1. addTwoNumbers

    Adds two numbers.

  2. createPost

    Posts a status to X (formerly Twitter).

MCP Server Example

This project demonstrates a simple client-server application using the Model Context Protocol (MCP) with Google Gemini AI and Twitter API integration.

Features

  • Server: Exposes tools via MCP, including:
    • addTwoNumbers: Adds two numbers.
    • createPost: Posts a status to X (formerly Twitter).
  • Client: Connects to the MCP server, lists available tools, and interacts with Gemini AI to call tools.

Prerequisites

  • Node.js v18 or higher
  • npm
  • Twitter Developer credentials (for posting to X)
  • Google Gemini API key

Setup

  1. Clone the repository

    git clone <your-repo-url>
    cd <repo-folder>
    
  2. Install dependencies

    cd server
    npm install
    cd ../client
    npm install
    
  3. Environment Variables Create a .env file in both server/ and client/ directories with the following variables: cles server/.env

    TWITTER_API_KEY=your_twitter_api_key
    TWITTER_API_SECRET=your_twitter_api_secret
    TWITTER_ACCESS_TOKEN=your_twitter_access_token
    TWITTER_ACCESS_TOKEN_SECRET=your_twitter_access_token_secret
    

    client/.env

    GEMINI_API_KEY=your_gemini_api_key
    

Running the Project

  1. Start the server

    cd server
    node indexs.js
    

    The server will run at http://localhost:3001.

  2. Start the client In a new terminal:

    cd client
    node indexc.js
    
  3. Usage

    • The client will connect to the server and prompt you for input.
    • You can ask questions or trigger tool calls (e.g., add two numbers, post a status to X).

Project Structure

client/
  indexc.js
  package.json
server/
  indexs.js
  mcp.tool.js
  package.json

Notes

  • Ensure your Twitter and Gemini API credentials are valid.
  • The server must be running before starting the client.
  • For production, secure your environment variables and API keys.

License

MIT