AgentStack
MCP verified Apache-2.0 Self-run

Mcp Server Go

mcp-isyaonoistu-mcp-server-go · by isYaoNoistu

MCP Server GO

No reviews yet
0 installs
4 views
0.0% view→install

Install

$ agentstack add mcp-isyaonoistu-mcp-server-go

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets Used
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Mcp Server Go? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

MCP Server (Go Edition)

一个基于Go语言实现的MCP (Model Context Protocol) 服务器,提供高性能的JSON-RPC 2.0接口,兼容Cherry Studio和Dify平台。

特性

  • 🚀 高性能: Go语言实现,性能比Python版本提升3-5倍
  • 🔌 双平台兼容: 同时支持 Cherry Studio 和 Dify 平台
  • 🧩 插件化架构: 工具模块化设计,易于扩展
  • ⚙️ 灵活配置: 支持 .env 文件和环境变量配置
  • 📊 Web管理界面: 提供工具管理、调用记录、统计分析
  • 🔒 状态持久化: 工具启用/禁用状态自动保存

系统要求

  • Go 1.21 或更高版本
  • 可选: Docker, Prometheus, Jenkins, MySQL (用于对应工具)

快速开始

1. 克隆项目

git clone https://github.com/isYaoNoistu/mcp-server-go.git
cd mcp-server-go

2. 安装依赖

go mod download

3. 配置环境

复制示例配置文件:

cp .env.example .env

编辑 .env 文件配置各工具参数:

# Server Configuration
PORT=8000
HOST=0.0.0.0
GIN_MODE=release

# Read File Tool
READ_FILE_PATH=/path/to/your/file.md

# Prometheus Tool (optional)
PROMETHEUS_API_URL=http://localhost:9090

# MySQL Tool (optional)
MYSQL_DEFAULT_HOST=localhost
MYSQL_DEFAULT_PORT=3306
MYSQL_DEFAULT_USER=root
MYSQL_DEFAULT_PASSWORD=password
MYSQL_DEFAULT_DATABASE=mydb

# Jenkins Tool (optional)
JENKINS_URL=http://localhost:8080
JENKINS_USER=admin
JENKINS_TOKEN=your_token

# Tool Control
ALLOW_AUTO_ENABLE_NEW_TOOLS=true
# TOOL_READ_FILE=1  # Enable specific tool
# TOOL_PROMETHEUS=0 # Disable specific tool

4. 运行服务器

go run main.go

或编译后运行:

go build -o mcp-server-go
./mcp-server-go

服务器将在 http://localhost:8000 启动。

使用说明

Web管理界面

访问 http://localhost:8000 打开Web管理界面,可以:

  • 查看所有工具列表
  • 启用/禁用工具
  • 查看调用记录
  • 查看统计数据
  • 配置工具参数

Cherry Studio 配置

  1. 打开 Cherry Studio 设置
  2. 导入 MCP 配置文件 cherry/cherry_mcp.json
  3. 修改配置中的服务器地址为 http://localhost:8000/mcp
  4. 保存配置
  5. 在对话中调用MCP工具

Dify 平台配置

  1. 在 Dify 中添加 MCP 服务器
  2. 服务器地址: http://localhost:8000/mcp
  3. 协议: JSON-RPC 2.0
  4. Dify 会自动调用 initializetools/list 方法
  5. 在工作流中使用MCP工具

API 接口

MCP Endpoint

POST /mcp

JSON-RPC 2.0 接口,支持以下方法:

  • initialize - 初始化服务器
  • tools/list - 列出所有可用工具
  • tools/call - 执行工具

示例请求:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/list",
  "params": {}
}

REST API

  • GET / - Web管理界面
  • GET /api/status - 服务器状态
  • GET /api/tools - 工具列表
  • POST /api/tools/toggle - 切换工具状态
  • POST /api/config/save - 保存配置
  • GET /api/records - 调用记录 (分页)
  • GET /api/stats - 统计数据

可用工具

当前实现的工具:

  • read_file - 文件读取工具
  • 🚧 prometheus_tools - Prometheus查询工具 (待实现)
  • 🚧 docker_tools - Docker管理工具 (待实现)
  • 🚧 jenkins_tools - Jenkins集成工具 (待实现)
  • 🚧 mysqlquerytools - MySQL查询工具 (待实现)
  • 🚧 filesquerytools - 文件查询工具 (待实现)
  • 🚧 systemchecktools - 系统检查工具 (待实现)

开发工具

添加新工具

  1. tools/ 目录下创建新包
  2. 实现 core.Tool 接口:
package mytool

import "github.com/isYaoNoistu/mcp-server-go/core"

type MyTool struct{}

func NewMyTool() core.Tool {
    return &MyTool{}
}

func (t *MyTool) Name() string {
    return "my_tool"
}

func (t *MyTool) Description() string {
    return "My custom tool"
}

func (t *MyTool) InputSchema() map[string]interface{} {
    return map[string]interface{}{
        "type": "object",
        "properties": map[string]interface{}{
            "param1": map[string]interface{}{
                "type": "string",
                "description": "Parameter 1",
            },
        },
        "required": []string{"param1"},
    }
}

func (t *MyTool) Aliases() []string {
    return []string{"mytool", "mt"}
}

func (t *MyTool) Run(params map[string]interface{}) (string, error) {
    // Implementation
    return "Tool executed successfully", nil
}
  1. tools/tools.go 中注册:
import "github.com/isYaoNoistu/mcp-server-go/tools/mytool"

func GetAllTools() []core.Tool {
    return []core.Tool{
        // ...existing tools
        mytool.NewMyTool(),
    }
}

运行测试

go test ./...

编译

# 本地编译
go build -o mcp-server-go

# 交叉编译 (Linux)
GOOS=linux GOARCH=amd64 go build -o mcp-server-go-linux

# 交叉编译 (Windows)
GOOS=windows GOARCH=amd64 go build -o mcp-server-go.exe

部署

systemd 服务

  1. 复制二进制文件到 /opt/mcp-server-go/
  2. 复制 .env 文件到 /opt/mcp-server-go/
  3. 复制 systemd 服务文件:
sudo cp systemd/mcp-server-go.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable mcp-server-go
sudo systemctl start mcp-server-go

Docker (即将支持)

docker build -t mcp-server-go .
docker run -p 8000:8000 --env-file .env mcp-server-go

项目结构

mcp-server-go/
├── main.go              # 入口文件
├── core/                # 核心模块
│   ├── types.go        # 类型定义
│   ├── protocol.go     # JSON-RPC协议
│   ├── state.go        # 状态管理
│   ├── records.go      # 调用记录
│   ├── registry.go     # 工具注册
│   └── api.go          # API路由
├── config/             # 配置管理
│   └── config.go
├── tools/              # 工具实现
│   ├── tools.go        # 工具注册
│   ├── readfile/
│   ├── prometheus/
│   ├── docker/
│   ├── jenkins/
│   ├── mysql/
│   ├── filesquery/
│   └── systemcheck/
└── web/                # Web界面
    └── static/

性能对比

| 指标 | Python版本 | Go版本 | 提升 | |------|-----------|--------|------| | 启动时间 | ~2.5s | ~0.3s | 8.3x | | 内存占用 | ~80MB | ~15MB | 5.3x | | QPS | ~500 | ~8000 | 16x | | 并发处理 | 受限 | 优秀 | - |

贡献

欢迎提交 Issue 和 Pull Request!

许可证

MIT License

致谢

本项目基于 Python 版本的 MCP Server 重构而来,感谢原项目作者。

Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.