MCP Server with Docker

MIT License
  • Linux
  • Apple

Integrations

  • Enables the MCP server to run inside Docker containers, providing tool access while maintaining isolation and portability.

  • Provides integration with OpenAI's API, allowing OpenAI models to access and use tools exposed by the MCP server for retrieving information like knowledge base data.

带有 Docker 的 MCP 服务器

该项目演示了如何将模型控制协议 (MCP) 与 OpenAI 的 API 集成,使 OpenAI 能够访问和使用在 Docker 中运行的 MCP 服务器公开的工具。

先决条件

  • 您的系统上安装了 Docker
  • Git(克隆存储库)

项目结构

  • server.py :使用工具实现的 MCP 服务器
  • client.py :连接服务器并调用代理的客户端
  • Dockerfile :构建 Docker 镜像的说明
  • requirements.txt :项目的 Python 依赖项

数据流解释

  1. 用户查询:用户向系统发送查询(例如,“我们公司的休假政策是什么?”)
  2. OpenAI API :OpenAI 从 MCP 服务器接收查询和可用工具
  3. 工具选择:OpenAI 根据查询决定使用哪些工具
  4. MCP Client :客户端接收OpenAI的工具调用请求,并转发给MCP服务器
  5. MCP 服务器:服务器执行请求的工具(例如,检索知识库数据)
  6. 响应流:工具结果通过 MCP 客户端流回 OpenAI
  7. 最终响应:OpenAI 生成包含工具数据的最终响应

使用 Docker 运行

步骤 1:构建 Docker 镜像

docker build -t mcp-server .

步骤 2:运行 Docker 容器

docker run -p 8050:8050 mcp-server

这将在 Docker 容器内启动 MCP 服务器并将其公开在端口 8050 上。

运行客户端

一旦服务器运行,您就可以在单独的终端中运行客户端:

python client.py

客户端将连接到服务器,列出可用的工具,并呼叫代理来回答查询。

故障排除

如果遇到连接问题:

  1. 检查服务器是否正在运行:使用docker ps确保 Docker 容器正在运行。
  2. 验证端口映射:使用docker ps或检查docker run命令的输出确保端口正确映射。
  3. 检查服务器日志:使用docker logs <container_id>查看服务器日志,看看是否有任何错误。
  4. 主机绑定:服务器已配置为绑定到0.0.0.0而不是127.0.0.1 ,以便从容器外部访问。如果仍然遇到问题,您可能需要检查防火墙设置。
  5. 网络问题:如果您在远程计算机上运行 Docker,请确保可以从客户端计算机访问该端口。

笔记

  • 该服务器配置为使用 SSE(服务器发送事件)传输并监听端口 8050。
  • 客户端通过http://localhost:8050/sse连接到服务器。
  • 启动客户端之前请确保服务器正在运行。
-
security - not tested
A
license - permissive license
-
quality - not tested

一个将模型控制协议与 OpenAI 的 API 相集成的项目,允许 OpenAI 访问和使用由 dockerized MCP 服务器公开的工具。

  1. Prerequisites
    1. Project Structure
      1. Data Flow Explanation
    2. Running with Docker
      1. Step 1: Build the Docker image
      2. Step 2: Run the Docker container
    3. Running the Client
      1. Troubleshooting
        1. Notes

          Related MCP Servers

          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol (MCP) server that lets you seamlessly use OpenAI's models right from Claude.
            Last updated -
            1
            24
            28
            JavaScript
            MIT License
            • Apple
          • -
            security
            A
            license
            -
            quality
            A simple MCP server for interacting with OpenAI assistants. This server allows other tools (like Claude Desktop) to create and interact with OpenAI assistants through the Model Context Protocol.
            Last updated -
            18
            Python
            MIT License
            • Apple
          • A
            security
            A
            license
            A
            quality
            Enables integration with OpenAI models through the MCP protocol, supporting concise and detailed responses for use with Claude Desktop.
            Last updated -
            1
            1
            Python
            MIT License
            • Apple
            • Linux
          • -
            security
            F
            license
            -
            quality
            A Model Context Protocol server implementation that enables connection between OpenAI APIs and MCP clients for coding assistance with features like CLI interaction, web API integration, and tool-based architecture.
            Last updated -
            9
            Python
            • Linux
            • Apple

          View all related MCP servers

          ID: yu6qfxkcxv