SM

shelwyn/mcp_with_python

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

5 stars 5 forks 品質 56 トレンド 13

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/tools and /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

  1. Clone the Repository:

    git clone https://github.com/shelwyn/MCP_with_python.git
    cd MCP_with_python
    
  2. Install Dependencies:

    pip install -r requirements.txt
    
  3. Set Up Environment: Create a .env file in the root directory:

    GEMINI_API_KEY=your_gemini_api_key_here
    

    Replace your_gemini_api_key_here with 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

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
GitHub で README 全文を見る

インストール

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"] } } }