
shelwyn/mcp_with_python
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
This repository contains a built with FastAPI, a custom chatbot integrating MCP tools with Gemini-2.0-Flash, and a proxy to connect the server to .
概要
This repository contains a built with FastAPI, a custom chatbot integrating MCP tools with Gemini-2.0-Flash, and a proxy to connect the server to . The project leverages the to extend AI capabilities with tools for generating random user profiles, demonstrating a practical application of MCP in both standalone and integrated environments. This project uses GOOGLE GEMINI LLM, click there to get your free API keys: https://aistudio.google.com/ The fetches user data (name, country, age, etc.) from https://randomuser.me/api/ and exposes three tools: - get_random_user: Fetch a single random user profile. - get_multiple_users: Fetch multiple user profiles (1-10). - get_user_by_gender: Fetch a user profile by gender (male/female). The uses these tools via HTTP requests or falls back to Gemini-2.0-Flash for general queries. The bridges the HTTP server to Claude Desktop's stdio-based MCP interface, enabling tool usage within Claude.
README
以下は原文 README の抜粋です。原文を見る。
RandomUser MCP Server and Chatbot
This repository contains a RandomUser MCP Server built with FastAPI, a custom chatbot integrating MCP tools with Gemini-2.0-Flash, and a proxy to connect the server to Claude Desktop. The project leverages the Model Context Protocol (MCP) to extend AI capabilities with tools for generating random user profiles, demonstrating a practical application of MCP in both standalone and integrated environments.
This project uses GOOGLE GEMINI LLM, click there to get your free API keys: https://aistudio.google.com/
Overview
The RandomUser MCP Server fetches user data (name, country, age, etc.) from https://randomuser.me/api/ and exposes three tools:
get_random_user: Fetch a single random user profile.get_multiple_users: Fetch multiple user profiles (1-10).get_user_by_gender: Fetch a user profile by gender (male/female).
The Chatbot uses these tools via HTTP requests or falls back to Gemini-2.0-Flash for general queries. The Proxy bridges the HTTP server to Claude Desktop’s stdio-based MCP interface, enabling tool usage within Claude.
Features
- MCP Server: HTTP-based server with FastAPI, exposing tools via
/mcp/toolsand/mcp/call_tool. - Chatbot: Command-line interface blending MCP tools with Gemini-2.0-Flash responses.
- Claude Integration: Proxy script to connect the server to Claude Desktop.
- Extensible: Easy to add new tools or modify existing ones.
Prerequisites
- Python 3.8+
- Claude Desktop (optional, for MCP integration)
- Gemini API Key (for chatbot LLM functionality)
Installation
-
Clone the Repository:
git clone https://github.com/shelwyn/MCP_with_python.git cd MCP_with_python -
Install Dependencies:
pip install -r requirements.txt -
Set Up Environment: Create a
.envfile in the root directory:GEMINI_API_KEY=your_gemini_api_key_hereReplace
your_gemini_api_key_herewith your actual Gemini API key from Google.
File Structure
randomuser-mcp/
├── mcp_server.py # HTTP-based MCP server
├── chatbot.py # Custom chatbot with MCP and Gemini
├── proxy.py # Stdio-to-HTTP proxy for Claude Desktop
├── .env # Environment variables (not tracked)
├── requirements.txt # Project dependencies
├── claude_desktop_config.json # Claude Desktop MCP config (example)
└── README.md # This file
Usage
1. Running the MCP Server
Start the HTTP server:
python mcp_server.py
- Runs on http://localhost:8000
- Endpoints:
/mcp/sse,/mcp/tools,/mcp/call_tool
2. Running the Chatbot
Launch the chatbot:
python chatbot.py
Examples:
You: Get me a random user
Bot: Full Name: Mr John Doe
Country: United States
インストール
This server does not publish a one-line install command.
Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →設定
{
"mcpServers": {
"randomuser_proxy": {
"command": "python",
"args": ["C:/path/to/proxy.py"]
}
}
}