Overview
What is Model Context Protocol (MCP) Server Project?
The Model Context Protocol (MCP) Server Project is a demonstration of integration between a client application and an MCP server, enabling AI-powered interactions with tool execution. It connects to Google's Gemini AI model and allows the AI to respond to queries and execute specialized tools like posting tweets or performing arithmetic.
How to use Model Context Protocol (MCP) Server Project?
Install Node.js v14+, then set up the server: cd server, npm install, configure .env with Twitter API credentials, run node index.js. Set up the client: cd client, npm install, configure .env with a Gemini API key, run node index.js. Start the server before the client, then type requests at the command-line prompt.
Key features of Model Context Protocol (MCP) Server Project
- AI chat interface powered by Google's Gemini model
- Tool execution via the MCP protocol
- Built-in tools:
addTwoNumbersandcreatePost(Twitter/X) - Communication over Server-Sent Events (SSE)
- Input validation with Zod schemas
- Uses Express web server and twitter-api-v2
Use cases of Model Context Protocol (MCP) Server Project
- Ask the AI to perform calculations (e.g., "What's 25 plus 17?")
- Instruct the AI to post a tweet automatically
- Demonstrate how MCP can extend an AI model’s capabilities
- Prototype tool‑augmented AI assistants
FAQ from Model Context Protocol (MCP) Server Project
What tools are available on the MCP server?
The server registers two tools: addTwoNumbers (addition) and createPost (posting a tweet to Twitter/X).
How does the AI decide to use a tool?
The client sends user queries to Google’s Gemini AI, which can decide to make a function call. The call is routed through the MCP client to the MCP server, which executes the tool and returns results.
What are the prerequisites to run this project?
You need Node.js v14 or higher, npm or yarn, Twitter/X API credentials (for the server), and a Google Gemini API key (for the client).
How do I set up the environment variables?
Two .env files are required: server/.env with Twitter API keys (TWITTER_API_KEY, TWITTER_API_KEY_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_TOKEN_SECRET) and client/.env with GEMINI_API_KEY.
What transport protocol does the MCP server use?
The client connects to the MCP server via Server-Sent Events (SSE).