go-mcp-demo

module
v0.0.0-...-19dd40e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2025 License: Apache-2.0

README

go-mcp-demo

a demo to learn how to use mcp in go

项目结构

  • 直接将hertz HTTP server用于host接收外部请求
  • mcp-host与mcp-server通过streamableHTTP通信
  • mcp-host与ollama通过http通信

quick start

  • copy config.example.yaml to config.yaml (config.stdio.yaml同理)
  • windows需要安装makefile相关工具

stdio

make stdio # windows需要修改config.stdio.yaml中的mcp.stdio.server_cmd 为./bin/mcp-server.exe

http单点通信

  • registry.provider为none
  • mcp.transport为http
  • mcp.http.base_url为mcp_server的url
本地启动
make mcp_local
make host #在另一个终端运行
docker启动(network=host模式)
make docker-run-mcp_local
make docker-run-host

基于consul集群启动

本地启动
make env
make host
make mcp_local#在另一个终端运行
make mcp_remote#在另一个终端运行
docker启动(network=host模式)
make env
make docker-run-host
make docker-run-mcp_local
make docker-run-mcp_remote

通过使用API管理平台(apifox/postman等)导入swagger/openapi.yaml,配置环境为host url,访问接口进行对话

记忆临时通过map来保存在内存中,重启host会丢失

Directories

Path Synopsis
api
mw
cmd
host command
mcp_local command
mcp_remote command
mcp_stdio command
internal
mcp
pkg
base/db
Package db 提供了一个基于 GORM Gen 的事务管理包装器
Package db 提供了一个基于 GORM Gen 的事务管理包装器
errno
This file is designed to define any error code
This file is designed to define any error code
jwt
Code generated by thrift-gen-http-swagger.
Code generated by thrift-gen-http-swagger.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL