MCP ExplorerExplorer

Mcp Client By Openai

@gyyzzzon a year ago
1 MIT
FreeCommunity
AI Systems
A personal project to learn MCP by implementing an MCP client using OpenAI API.

Overview

What is Mcp Client By Openai

mcp_client_by_openai is a project designed for personal learning and practice of the Model Context Protocol (MCP). It implements an MCP client that utilizes the OpenAI API.

Use cases

Use cases for mcp_client_by_openai include developing AI-driven applications, conducting experiments with language models, and building prototypes that leverage OpenAI’s capabilities.

How to use

To use mcp_client_by_openai, first install the ‘uv’ package as per the official documentation. Then, initialize the project, set up a virtual environment, and add the OpenAI MCP integration. Configure the environment variables in a .env file and set up the MCP server parameters in a config.json file before running the main.py script.

Key features

Key features of mcp_client_by_openai include integration with OpenAI’s API, customizable environment configurations, and support for various MCP server setups.

Where to use

mcp_client_by_openai can be used in fields such as artificial intelligence, machine learning, and software development, particularly for projects that require interaction with OpenAI’s models.

Content

MCP_client_with_openai

此项目用于个人学习实践MCP(Modle Context Protocol),本项目实现了一个使用openai api的mcp-client

快速开始

首先安装uv,官方文档:https://docs.astral.sh/uv/,

执行以下内容:

uv init MCP_client_by_openai
cd MCP_client_by_openai
uv venv
source .venv/bin/activate

uv add mcp openai

复制main.py到项目文件夹

模型配置

创建.env文件加载OPENAI_API_KEY、BASE_URL、MODEL等环境变量,例如:

❯ cat .env
OPENAI_API_KEY=<your_openai_api_key>
BASE_URL="https://api.deepseek.com"
MODEL="deepseek-chat"

**注意:**请将.evn加入.gitignore

mcp_server运行配置

通过config.json执行运行的mcp服务端启动命令参数及环境变量

❯ cat config.json.example
{
  "mcpServers": {
    "mcp-clickhouse": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-clickhouse",
        "--python",
        "3.13",
        "mcp-clickhouse"
      ],
      "env": {
        "CLICKHOUSE_HOST": "<clickhouse-host>",
        "CLICKHOUSE_PORT": "<clickhouse-port>",
        "CLICKHOUSE_USER": "<clickhouse-user>",
        "CLICKHOUSE_PASSWORD": "<clickhouse-password>",
        "CLICKHOUSE_SECURE": "true",
        "CLICKHOUSE_VERIFY": "true",
        "CLICKHOUSE_CONNECT_TIMEOUT": "30",
        "CLICKHOUSE_SEND_RECEIVE_TIMEOUT": "30"
      }
    }
  }
}

注意:请将config.json加入.gitignore

配置好以上信息后执行

uv run main.py

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers