mcp

package
v0.1.36 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client MCP API客户端 (Model Context Protocol)

func NewClient

func NewClient(baseURL string) *Client

NewClient 创建MCP API客户端

func (*Client) CallTool

func (c *Client) CallTool(ctx context.Context, name string, arguments map[string]interface{}) (*MCPResponse, error)

CallTool 调用工具

func (*Client) ListResources

func (c *Client) ListResources(ctx context.Context) (*MCPResponse, error)

ListResources 列出可用资源

func (*Client) ListTools

func (c *Client) ListTools(ctx context.Context) (*MCPResponse, error)

ListTools 列出可用工具

func (*Client) ReadResource

func (c *Client) ReadResource(ctx context.Context, uri string) (*MCPResponse, error)

ReadResource 读取资源

func (*Client) SendMCPRequest

func (c *Client) SendMCPRequest(ctx context.Context, req *MCPRequest) (*MCPResponse, error)

SendMCPRequest 发送MCP请求

type MCPError

type MCPError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

MCPError MCP错误

type MCPRequest

type MCPRequest struct {
	Method string                 `json:"method"`
	Params map[string]interface{} `json:"params,omitempty"`
}

MCPRequest MCP请求

type MCPResponse

type MCPResponse struct {
	ID     string                 `json:"id,omitempty"`
	Result map[string]interface{} `json:"result,omitempty"`
	Error  *MCPError              `json:"error,omitempty"`
}

MCPResponse MCP响应

Jump to

Keyboard shortcuts

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