Cover image
Try Now
2025-04-02

Un modèle de modèle pour créer des projets de serveur et client MCP

3 years

Works with Finder

1

Github Watches

0

Github Forks

0

Github Stars

MCP Hello World Example

This project demonstrates a simple implementation of the Model Context Protocol (MCP) using a Flask server and OpenAI integration. It showcases how to create an MCP server that provides a number addition function and a client that can use this function through OpenAI's function calling capabilities.

Components

Server (server.py)

  • A Flask-based MCP server that implements:
    • A simple addition function (add_numbers)
    • MCP protocol endpoints for function listing and execution
    • JSON schema definition for the addition function
    • Runs on http://localhost:8080

Client (client.py)

  • Integrates with OpenAI's API and the MCP server
  • Demonstrates:
    • Fetching available functions from the MCP server
    • Converting MCP functions to OpenAI function specifications
    • Making function calls through OpenAI's chat completions
    • Processing and displaying results

Prerequisites

  • Python 3.x
  • OpenAI API key

Installation

  1. Clone the repository
  2. Install dependencies:
pip install -r requirements.txt

Configuration

  1. Set your OpenAI API key:
export OPENAI_API_KEY="your-api-key-here"

Usage

  1. Start the MCP server:
python server.py
  1. In a separate terminal, run the client:
python client.py

The client will:

  1. Connect to the MCP server
  2. Fetch available functions
  3. Start a conversation with OpenAI's model
  4. Demonstrate function calling by adding two numbers (42 and 17)
  5. Display the results

Project Structure

.
├── README.md           # Project documentation
├── requirements.txt    # Python dependencies
├── server.py          # MCP server implementation
└── client.py          # OpenAI client implementation

Dependencies

  • python-dotenv: Environment variable management
  • openai: OpenAI API client
  • flask: Web server framework
  • requests: HTTP client library

Example Output

When running the client, you'll see:

  1. Available MCP functions listing
  2. Model's decision to use the addition function
  3. Function execution results
  4. Final response from the model

Contributing

Feel free to submit issues and enhancement requests!

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://appia.in
  • Siri Shortcut Finder – your go-to place for discovering amazing Siri Shortcuts with ease

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • J. DE HARO OLLE
  • Especialista en juegos de palabras en varios idiomas.

  • apappascs
  • Découvrez la collection la plus complète et la plus à jour de serveurs MCP sur le marché. Ce référentiel sert de centre centralisé, offrant un vaste catalogue de serveurs MCP open-source et propriétaires, avec des fonctionnalités, des liens de documentation et des contributeurs.

  • ShrimpingIt
  • Manipulation basée sur Micropython I2C de l'exposition GPIO de la série MCP, dérivée d'Adafruit_MCP230XX

  • jae-jae
  • MCP Server pour récupérer le contenu de la page Web à l'aide du navigateur sans tête du dramwright.

  • HiveNexus
  • Un bot de chat IA pour les petites et moyennes équipes, soutenant des modèles tels que Deepseek, Open AI, Claude et Gemini. 专为中小团队设计的 Ai 聊天应用 , 支持 Deepseek 、 Open Ai 、 Claude 、 Gemini 等模型。

  • ravitemer
  • Un puissant plugin Neovim pour gérer les serveurs MCP (Protocole de contexte modèle)

  • patruff
  • Pont entre les serveurs Olllama et MCP, permettant aux LLM locaux d'utiliser des outils de protocole de contexte de modèle

  • Sysc4lls
  • Lecteur de documentation IDA (Sort-of) MCP Server

    Reviews

    5 (1)
    Avatar
    user_orDGMHvt
    2025-04-16

    As a dedicated user of MCP-template, I highly recommend this tool for anyone looking to streamline their workflow. Created by wubbyweb, it offers an easy-to-use interface and seamless integration with your development environment. You can find everything you need at the provided GitHub link. It's an invaluable resource for enhancing productivity and efficiency.