weibaohui
MCP Serverweibaohuipublic

openai sdk mcp

基于 Go 的 OpenAI SDK 和多客户端协议 (MCP) 集成,支持动态服务器管理。

Repository Info

0
Stars
0
Forks
0
Watchers
0
Issues
Go
Language
-
License

About This Server

基于 Go 的 OpenAI SDK 和多客户端协议 (MCP) 集成,支持动态服务器管理。

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

openai-sdk-mcp

一个基于Go语言的OpenAI SDK与MCP(Multi-Client Protocol)集成项目,支持多服务器连接管理和OpenAI API调用功能。

功能特性

  • OpenAI API集成:支持自定义API密钥和BaseURL配置
  • MCP服务器管理:
    • 支持多服务器并发连接
    • 服务器配置动态管理
    • 连接状态监控
  • 内置功能模块:
    • 计算模块:支持基础数学运算
    • 随机数模块:生成随机数并进行计算

安装

go get github.com/weibaohui/openai-sdk-mcp

使用示例

// 初始化OpenAI客户端
openaiConfig := OpenAIConfig{
    APIKey:  os.Getenv("OPENAI_API_KEY"),
    BaseURL: os.Getenv("OPENAI_BASE_URL"),
}

// 创建MCP管理器
host := NewMCPHost()
defer host.Close()

// 添加服务器配置
servers := []ServerConfig{
    {
        Name:    "server1",
        URL:     "http://localhost:9292/sse",
        Enabled: true,
    },
}

// 添加并连接服务器
ctx := context.Background()
for _, server := range servers {
    if err := host.AddServer(server); err != nil {
        log.Printf("Failed to add server %s: %v", server.Name, err)
        continue
    }
    if err := host.ConnectServer(ctx, server.Name); err != nil {
        log.Printf("Failed to connect to server %s: %v", server.Name, err)
        continue
    }
}

// 处理请求
content, result, err := host.ProcessWithOpenAI(ctx, "请计算22+33的结果")

项目结构

.
├── client/         # 客户端实现
│   └── client.go   # OpenAI客户端和MCP服务器管理
├── server/         # 服务器端实现
│   ├── calc/       # 计算模块
│   └── random/     # 随机数模块
├── go.mod          # Go模块定义
└── README.md       # 项目文档

依赖

  • github.com/mark3labs/mcp-go v0.14.1
  • github.com/sashabaranov/go-openai v1.38.0

许可证

MIT License

Quick Start

1

Clone the repository

git clone https://github.com/weibaohui/openai-sdk-mcp
2

Install dependencies

cd openai-sdk-mcp
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownerweibaohui
Repoopenai-sdk-mcp
LanguageGo
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation