前言,mcp是一个新生的协议,和http,json一样没什么区别。推荐阅读一篇介绍和实操mcp协议的文章:[https://www.cnblogs.com/BNTang/p/18815937#!comments](https://word.jiejaitt.top/?golink=aHR0cHM6Ly93d3cuY25ibG9ncy5jb20vQk5UYW5nL3AvMTg4MTU5MzcjIWNvbW1lbnRz) 本文介绍阅读基于mcp协议的github sdk,借此对mcp协议产生更多的了解,阅读这个项目仅仅只是因为我对go语言和github比较熟悉而已。 ### 仓库地址如图所示: 可以看到基于的版本和仓库的重要文件。 ``` // Package server provides MCP (Model Control Protocol) server implementations. package server import ( "context" "encoding/json" "errors" "fmt" "sort" "sync" "github.com/mark3labs/mcp-go/mcp" ) // resourceEntry holds both a resource and its handler type resourceEntry struct { resource mcp.Resource handler ResourceHandlerFunc } // resourceTemplateEntry holds both a template and its handler type resourceTemplateEntry struct { template mcp.ResourceTemplate handler ResourceTemplateHandlerFunc } ``` Loading... 前言,mcp是一个新生的协议,和http,json一样没什么区别。推荐阅读一篇介绍和实操mcp协议的文章:[https://www.cnblogs.com/BNTang/p/18815937#!comments](https://word.jiejaitt.top/?golink=aHR0cHM6Ly93d3cuY25ibG9ncy5jb20vQk5UYW5nL3AvMTg4MTU5MzcjIWNvbW1lbnRz) 本文介绍阅读基于mcp协议的github sdk,借此对mcp协议产生更多的了解,阅读这个项目仅仅只是因为我对go语言和github比较熟悉而已。 ### 仓库地址如图所示: 可以看到基于的版本和仓库的重要文件。 ``` // Package server provides MCP (Model Control Protocol) server implementations. package server import ( "context" "encoding/json" "errors" "fmt" "sort" "sync" "github.com/mark3labs/mcp-go/mcp" ) // resourceEntry holds both a resource and its handler type resourceEntry struct { resource mcp.Resource handler ResourceHandlerFunc } // resourceTemplateEntry holds both a template and its handler type resourceTemplateEntry struct { template mcp.ResourceTemplate handler ResourceTemplateHandlerFunc } ``` 最后修改:2025 年 11 月 01 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏