Documentation
¶
Index ¶
- Constants
- type HeaderFunc
- type Invoker
- type MCPConnection
- type Registry
- func (r *Registry) AddInvoker(name string, fn Invoker, desc string, inputSchema map[string]any) error
- func (r *Registry) AddServer(ctx context.Context, server *mcps.Server) error
- func (r *Registry) ApplyToolDescriptions(descriptions map[string]string)
- func (r *Registry) Invoke(ctx context.Context, name string, params map[string]any) (map[string]any, error)
- func (r *Registry) LoadServers(ctx context.Context, sto stores.Storage) error
- func (r *Registry) RemoveServer(name string) error
- func (r *Registry) ToolsFor(ctx context.Context) []mcps.ToolDescriptor
- type RegistryOption
- type ResultLogs
Constants ¶
View Source
const ( ToolNameKBSearch = "kb_search" // 知识库搜索工具 ToolNameKBCreate = "kb_create" // 知识库创建工具 ToolNameFetch = "fetch" // 网页抓取工具 ToolNameMemoryList = "memory_list" // 记忆列表工具 ToolNameMemoryRecall = "memory_recall" // 记忆召回工具 ToolNameMemoryStore = "memory_store" // 记忆存储工具 ToolNameMemoryForget = "memory_forget" // 记忆删除工具 ToolNameStrataExec = "strata_exec" )
View Source
const (
DEFAULT_USER_AGENT_AUTONOMOUS = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HeaderFunc ¶ added in v0.2.4
type HeaderFunc = transport.HTTPHeaderFunc
type MCPConnection ¶
type MCPConnection struct {
Name string
URL string
TransType mcps.TransType
// contains filtered or unexported fields
}
MCPConnection represents a connection to an MCP server
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry(sto stores.Storage, opts ...RegistryOption) *Registry
NewRegistry 创建工具注册表
func (*Registry) AddInvoker ¶
func (r *Registry) AddInvoker(name string, fn Invoker, desc string, inputSchema map[string]any) error
AddInvoker 添加自定义工具 invoker name: 工具名称 fn: 工具调用函数 desc: 工具描述 inputSchema: 输入参数 schema
func (*Registry) ApplyToolDescriptions ¶ added in v0.2.3
ApplyToolDescriptions 应用 preset 中的自定义工具描述 descriptions: toolName -> description
func (*Registry) Invoke ¶
func (r *Registry) Invoke(ctx context.Context, name string, params map[string]any) (map[string]any, error)
Invoke 调用指定名称的工具
func (*Registry) LoadServers ¶
LoadServers 加载所有 Running 状态的 MCP Server
func (*Registry) RemoveServer ¶
RemoveServer 移除 MCP Server 连接
type RegistryOption ¶
type RegistryOption func(*Registry)
RegistryOption 用于配置 Registry 的可选参数
func WithClientInfo ¶
func WithClientInfo(name, version string) RegistryOption
WithClientInfo 设置 MCP 客户端信息
func WithHeaderFunc ¶ added in v0.2.4
func WithHeaderFunc(hf HeaderFunc) RegistryOption
type ResultLogs ¶
ResultLogs 是工具调用结果的日志类型别名
func (ResultLogs) String ¶
func (rl ResultLogs) String() string
String 实现 fmt.Stringer 接口,返回格式化的结果日志 格式为 {key: val[0:min(30,len(val)},如果值不是 string/slice/map,则为 key: ""
Click to show internal directories.
Click to hide internal directories.