mcpserver

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDocsGetTool

func NewDocsGetTool(baseDir string) (tools.Tool, error)

func NewDocsSearchTool

func NewDocsSearchTool(baseDir string) (tools.Tool, error)

Types

type Config

type Config struct {
	Registry       *tools.Registry
	Executor       *tools.Executor
	ContextFactory func(ctx context.Context) *tools.ToolContext
}

Config MCP Server 配置

type DocsGetTool

type DocsGetTool struct {
	// contains filtered or unexported fields
}

func (*DocsGetTool) Description

func (t *DocsGetTool) Description() string

func (*DocsGetTool) Execute

func (t *DocsGetTool) Execute(ctx context.Context, input map[string]any, tc *tools.ToolContext) (any, error)

func (*DocsGetTool) InputSchema

func (t *DocsGetTool) InputSchema() map[string]any

func (*DocsGetTool) Name

func (t *DocsGetTool) Name() string

func (*DocsGetTool) Prompt

func (t *DocsGetTool) Prompt() string

type DocsSearchTool

type DocsSearchTool struct {
	// contains filtered or unexported fields
}

func (*DocsSearchTool) Description

func (t *DocsSearchTool) Description() string

func (*DocsSearchTool) Execute

func (t *DocsSearchTool) Execute(ctx context.Context, input map[string]any, tc *tools.ToolContext) (any, error)

func (*DocsSearchTool) InputSchema

func (t *DocsSearchTool) InputSchema() map[string]any

func (*DocsSearchTool) Name

func (t *DocsSearchTool) Name() string

func (*DocsSearchTool) Prompt

func (t *DocsSearchTool) Prompt() string

type DocsToolConfig

type DocsToolConfig struct {
	BaseDir string
}

DocsToolConfig 配置 docs_get/docs_search 工具

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server 实现了一个简单的 MCP HTTP Server, 使用 JSON-RPC 2.0 协议: - tools/list: 列出所有可用工具 - tools/call: 调用指定工具

该实现与 pkg/sandbox/cloud.MCPClient 使用的协议兼容, 可作为本地 MCP 服务端, 被 examples/mcp 或其他 MCP 客户端调用。

func New

func New(cfg *Config) (*Server, error)

New 创建一个 MCP Server 实例

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler 返回一个 http.Handler, 处理 MCP JSON-RPC 请求。

典型挂载方式:

mux.Handle("/mcp", mcpSrv.Handler())

Jump to

Keyboard shortcuts

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