Token导航 LogoToken导航TokenDH.com
Gin For MCP logo
AI代理未说明官方级别未说明来源级核验

Gin For MCP

MCP Server

基于Gin框架的MCP协议服务实现,支持Protocol Buffers序列化和Swagger文档自动生成,适用于需要高效通信和API管理的开发场景。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
API集成AI代理工作流自动化

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

wxp212

提供方

wxp212

最后核验

2026/5/17 20:23

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

🚀 Gin-for-MCP

基于 Gin 框架的 MCP (Model Context Protocol) 服务示例

](https://go.dev/) ![Gin Framework](https://github.com/gin-gonic/gin) ![Protocol Buffers](https://protobuf.dev/) ![License](LICENSE)

English | 中文


📖 项目简介

这是一个使用 Gin 框架构建的 HTTP 服务,集成了 Protocol BuffersMCP (Model Context Protocol),并通过 Swagger 自动生成 API 文档。项目展示了如何快速搭建一个支持 MCP 协议的 RESTful API 服务。

✨ 主要特性

  • 🎯 Gin 框架 - 高性能的 Go Web 框架
  • 📝 Protocol Buffers - 高效的序列化协议
  • 🔄 自动代码生成 - 从 Proto 文件生成 Gin HTTP 处理器
  • 📚 Swagger 文档 - 自动生成 OpenAPI 规范文档
  • 🔌 MCP 集成 - 支持 Model Context Protocol 服务暴露
  • SSE 支持 - Server-Sent Events 实时通信

🛠️ 技术栈


📦 前置要求

在开始之前,请确保已安装以下工具:

  • Go 1.24+ (下载)
  • Protocol Buffers Compiler (protoc) (安装指南)
  • Python 3 (用于 Swagger 文件处理)
  • swagger-mcp CLI 工具

安装 swagger-mcp

go install github.com/danishjsheikh/swagger-mcp@latest

或参考 swagger-mcp 官方文档 进行安装。


🚀 快速开始

1️⃣ 克隆项目

git clone 
cd gin-for-mcp

2️⃣ 安装依赖

go mod download

3️⃣ 生成 API 代码和 Swagger 文档

make api

此命令会:

  • 从 Proto 文件生成 Go 代码
  • 生成 Gin HTTP 处理器
  • 生成 OpenAPI/Swagger 文档 (mcp.swagger.json)

4️⃣ 运行服务

go run .

服务将在 http://localhost:8080 启动。

5️⃣ 启动 MCP 服务(可选)

在新的终端窗口中运行:

swagger-mcp --specUrl file://./mcp.swagger.json --sse -sseAddr=:28080

MCP 服务将在 http://localhost:28080 启动,支持 SSE 通信。


📝 API 端点

方法端点描述
GET/test/v1/name获取当前存储的名称
POST/test/v1/name设置新的名称

示例请求

获取名称

curl http://localhost:8080/test/v1/name

设置名称

curl -X POST http://localhost:8080/test/v1/name \
  -H "Content-Type: application/json" \
  -d '{"name": "新名称"}'

📂 项目结构

gin-for-mcp/
├── api/
│   └── test/
│       └── v1/
│           ├── test.proto        # Protocol Buffers 定义
│           ├── test.pb.go        # 生成的 Proto Go 代码
│           └── test_gin.pb.go   # 生成的 Gin HTTP 处理器
├── main.go                       # 主程序入口
├── go.mod                        # Go 模块依赖
├── go.sum                        # 依赖校验文件
├── Makefile                      # 构建脚本
├── mcp.swagger.json             # Swagger API 文档
└── README.md                     # 项目文档

🔧 开发指南

修改 API

  1. 编辑 api/test/v1/test.proto 文件
  2. 运行 make api 重新生成代码
  3. main.go 中实现新的服务方法
  4. 重启服务

添加新服务

  1. api/ 目录下创建新的 proto 文件
  2. 更新 Makefile 以包含新的 proto 文件
  3. 实现服务接口
  4. main.go 中注册新服务

📖 相关资源


📄 许可证

本项目采用 MIT 许可证。详见 LICENSE 文件。


Made with ❤️ using Gin and Go


🌍 English Version

📖 Introduction

A Gin-based HTTP service integrating Protocol Buffers and MCP (Model Context Protocol) with automatic Swagger API documentation generation. This project demonstrates how to quickly build a RESTful API service supporting the MCP protocol.

✨ Key Features

  • 🎯 Gin Framework - High-performance Go web framework
  • 📝 Protocol Buffers - Efficient serialization protocol
  • 🔄 Code Generation - Auto-generate Gin HTTP handlers from Proto files
  • 📚 Swagger Docs - Automatic OpenAPI specification generation
  • 🔌 MCP Integration - Model Context Protocol service exposure
  • SSE Support - Server-Sent Events for real-time communication

🚀 Quick Start

  1. Generate API code and Swagger docs:
   make api
  1. Run the server:
   go run .

Server starts at http://localhost:8080

  1. Start MCP service (optional):
   swagger-mcp --specUrl file://./mcp.swagger.json --sse -sseAddr=:28080

MCP service starts at http://localhost:28080

  1. More details: swagger-mcp

📝 API Endpoints

MethodEndpointDescription
GET/test/v1/nameGet the current stored name
POST/test/v1/nameSet a new name

📂 Project Structure

gin-for-mcp/
├── api/test/v1/          # Proto definitions and generated code
├── main.go               # Main application entry
├── Makefile              # Build automation
├── mcp.swagger.json      # Swagger API documentation
└── README.md             # Project documentation

⬆ Back to Top

目录标签

目录标签

API集成AI代理工作流自动化Makefile本地部署Gin框架ProtocolBuffersRESTfulAPISwagger文档MCP协议

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP