Cover image

Este proyecto muestra cómo usar el protocolo MCP con Azure OpenAi. Proporciona un ejemplo simple para interactuar con la API de Openai sin problemas a través de un servidor y un cliente MCP.

3 years

Works with Finder

3

Github Watches

3

Github Forks

3

Github Stars

OpenAI MCP Getting Started Example

This project showcases how to use the MCP protocol with OpenAI. It provides a simple example to interact with OpenAI's API seamlessly via an MCP server, host and clients.

MCP server supported features and capabilities

This sample provides an MCP server implementation that supports the following features:

Feature Completed
SSE
HTTP Streaming
AuthN/Z
Tools
Resources
Prompts
Sampling

Getting Started

To get started with this project, follow the steps below:

Prerequisites

  • Node.js and npm (version 22 or higher)
  • An OpenAI compatible endpoint:
    • An OpenAI API key
    • Or, a GitHub token, if you want to use the GitHub models: https://gh.io/models
    • Or, if you are using Azure OpenAI, you need to have an Azure OpenAI resource and the corresponding endpoint.

Installation

  1. Clone the repository:

    git clone https://github.com/manekinekko/openai-mcp-example.git
    cd openai-mcp-example
    
  2. Install the dependencies:

    npm install
    

Configuration

This sample supports the follwowing providers:

  • Azure OpenAI,
  • OpenAI,
  • GitHub Models.

Azure OpenAI

In order to use Keyless authentication, using Azure Managed Identity, you need to provide the AZURE_OPENAI_ENDPOINT environment variable in the .env file:

AZURE_OPENAI_ENDPOINT="https://<ai-foundry-openai-project>.openai.azure.com"
MODEL="gpt-4.1"

# Optional: If you want to use the API key authentication.
#AZURE_OPENAI_API_KEY=your_azure_openai_api_key

And make sure to using the Azure CLI to log in to your Azure account and follow the instructions to selection your subscription:

az login

OpenAI

To use the OpenAI API, you need to set your OPENAI_API_KEY key in the .env file:

OPENAI_API_KEY=your_openai_api_key
MODEL="gpt-4.1"

GitHub Models

To use the GitHub models, you need to set your GITHUB_TOKEN and GITHUB_MODEL in the .env file:

GITHUB_TOKEN=your_github_token
GITHUB_MODEL="openai/gpt-4.1"

Usage

  1. Run the MCP server:

    npm run server
    
  2. Run the MCP host in a separate terminal:

    npm run host
    

You should see a response like the following:

Authentication method: Azure OpenAI Entra ID (keyless)

MCP Host Started!
Connected to the following servers:
* math-server: http://localhost:4321/sse
Available tools:
- calculate_sum: Calculate the sum of two numbers
- calculate_product: Calculate the product of two numbers
- calculate_difference: Calculate the difference of two numbers
- calculate_division: Calculate the division of two numbers

Query: what is 40+2?
Agent:
[Thinking] Using tool "calculate_sum" with args "{\"a\":40,\"b\":2}"
[Thinking] Tool calculate_sum result: The sum of 40 and 2 is 42.
[Thinking] The result of 40 + 2 is 42.

Agent:
The result of 40 + 2 is 42.

Query:

Debugging and inspection

You can use the DEBUG environment variable to enable verbose logging for the OpenAI SDK:

DEBUG=true npm run host

In order to inspect the MCP servers, run the following command in a separate terminal, and follow the instructions:

npm run inspect

License

This project is licensed under the MIT License. See the LICENSE file for details.

相关推荐

  • av
  • Ejecute sin esfuerzo LLM Backends, API, frontends y servicios con un solo comando.

  • 1Panel-dev
  • 🔥 1Panel proporciona una interfaz web intuitiva y un servidor MCP para administrar sitios web, archivos, contenedores, bases de datos y LLM en un servidor de Linux.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 llM 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Resumen de los mejores recursos del mundo.

  • rulego
  • ⛓️Rulego es un marco de motor de regla de orquestación de componentes de alta generación de alto rendimiento, de alto rendimiento y de alto rendimiento para GO.

  • sigoden
  • Cree fácilmente herramientas y agentes de LLM utilizando funciones Plain Bash/JavaScript/Python.

  • hkr04
  • SDK liviano C ++ MCP (Protocolo de contexto del modelo)

  • RockChinQ
  • 😎简单易用、🧩丰富生态 - 大模型原生即时通信机器人平台 | 适配 Qq / 微信(企业微信、个人微信) / 飞书 / 钉钉 / Discord / Telegram / Slack 等平台 | 支持 Chatgpt 、 Deepseek 、 DiFy 、 Claude 、 Gemini 、 Xai 、 PPIO 、 Ollama 、 LM Studio 、阿里云百炼、火山方舟、 Siliconflow 、 Qwen 、 Moonshot 、 Chatglm 、 SillyTraven 、 MCP 等 LLM 的机器人 / Agente | Plataforma de bots de mensajería instantánea basada en LLM, admite Discord, Telegram, WeChat, Lark, Dingtalk, QQ, Slack

  • dmayboroda
  • Trapo conversacional local con contenedores configurables

  • modelscope
  • Iniciar aplicaciones de múltiples agentes empoderadas con Building LLM de manera más fácil.

  • evilsocket
  • El kit de desarrollo de agentes simples.

    Reviews

    2.6 (8)
    Avatar
    user_yVOHrj1N
    2025-04-24

    Azure-openai-mcp-example by manekinekko is a fantastic solution for integrating OpenAI capabilities into your applications seamlessly. The documentation is clear and concise, making it easy to get started. The sample code provided is extremely helpful for understanding how to implement and customize the functionalities. Highly recommended for developers looking to leverage AI in their projects!

    Avatar
    user_0TzYPtV2
    2025-04-24

    I've been using azure-openai-mcp-example by manekinekko and it has significantly improved my workflow. The documentation is clear, making it easy to set up and start. This tool leverages the power of Azure and OpenAI seamlessly, helping me enhance productivity and efficiency in my projects. Highly recommended for anyone looking to integrate AI into their applications effortlessly.

    Avatar
    user_4L9RXhz1
    2025-04-24

    As a dedicated user of azure-openai-mcp-example, I must say it's an exceptional product by manekinekko. The seamless integration and user-friendly interface make it incredibly effective for my projects. It's a game-changer, especially in handling and processing openai APIs effortlessly. Highly recommended!

    Avatar
    user_KcudFbxD
    2025-04-24

    As a dedicated user of the azure-openai-mcp-example, I must say it's a game-changer! The integration is seamless, and the performance meets all my needs effortlessly. Kudos to manekinekko for crafting such a user-friendly and efficient solution. Highly recommend it for anyone looking to optimize their MCP applications!

    Avatar
    user_KpGe7h84
    2025-04-24

    I've been using azure-openai-mcp-example by manekinekko, and it has been a game changer for my projects. This well-documented and easy-to-use application integrates Azure and OpenAI seamlessly, providing incredible functionality and performance. Highly recommend for anyone looking to enhance their development workflow!

    Avatar
    user_Fy6APfnr
    2025-04-24

    As a dedicated user of the Azure OpenAI MCP example by manekinekko, I find this tool incredibly useful for integrating advanced AI capabilities into my applications. The seamless setup and comprehensive documentation make it accessible for developers of all skill levels. The robust functionality and reliability have significantly enhanced my project's performance. Highly recommend!

    Avatar
    user_dW3f5q02
    2025-04-24

    I have been using the azure-openai-mcp-example by manekinekko for a while now, and I am thoroughly impressed. The seamless integration and user-friendly interface make it an invaluable tool for developers. The comprehensive documentation and welcoming messages provide a smooth onboarding experience. Highly recommend it to anyone in need of a reliable and efficient solution.

    Avatar
    user_y2956Aqs
    2025-04-24

    The azure-openai-mcp-example by manekinekko is an impressive and user-friendly application. It seamlessly integrates with Azure and OpenAI, providing robust functionalities that are both practical and efficient. Highly recommended for anyone looking to simplify their AI and cloud interactions.