揭秘 MCP-Go:一个适合初学者学习 MCP 协议的开源项目

揭秘 MCP-Go:一个适合初学者学习 MCP 协议的开源项目

前言,mcp是一个新生的协议,和http,json一样没什么区别。推荐阅读一篇介绍和实操mcp协议的文章:https://www.cnblogs.com/BNTang/p/18815937#!comments

本文介绍阅读基于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
}
 
© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容