Documentation
¶
Index ¶
- Constants
- type ClientCapabilities
- type ClientInfo
- type Connection
- type Content
- type FileCodeBoxMCPServer
- type InitializeRequest
- type InitializeResult
- type JSONRPCMessage
- func NewJSONRPCError(id interface{}, code int, message string, data interface{}) *JSONRPCMessage
- func NewJSONRPCNotification(method string, params interface{}) *JSONRPCMessage
- func NewJSONRPCRequest(id interface{}, method string, params interface{}) *JSONRPCMessage
- func NewJSONRPCResponse(id interface{}, result interface{}) *JSONRPCMessage
- type LogLevel
- type LoggingCapability
- type LoggingMessageNotification
- type MCPManager
- func (m *MCPManager) ApplyConfig(enableMCP bool, port string) error
- func (m *MCPManager) GetStatus() MCPStatus
- func (m *MCPManager) IsRunning() bool
- func (m *MCPManager) RestartMCPServer(port string) error
- func (m *MCPManager) StartMCPServer(port string) error
- func (m *MCPManager) StopMCPServer() error
- type MCPStatus
- type PromptsCapability
- type RPCError
- type Resource
- type ResourceContents
- type ResourceReader
- type ResourcesCapability
- type ResourcesListRequest
- type ResourcesListResult
- type ResourcesReadRequest
- type ResourcesReadResult
- type RootsCapability
- type SamplingCapability
- type Server
- func (s *Server) AddResource(resource Resource, reader ResourceReader)
- func (s *Server) AddTool(tool Tool, handler ToolHandler)
- func (s *Server) IsInitialized() bool
- func (s *Server) LogMessage(level LogLevel, data interface{}, logger string)
- func (s *Server) ServeStdio() error
- func (s *Server) ServeTCP(addr string) error
- func (s *Server) SetInstructions(instructions string)
- type ServerCapabilities
- type ServerInfo
- type Tool
- type ToolCallRequest
- type ToolCallResult
- type ToolHandler
- type ToolsCapability
- type ToolsListRequest
- type ToolsListResult
Constants ¶
const ( ParseError = -32700 InvalidRequest = -32600 MethodNotFound = -32601 InvalidParams = -32602 InternalError = -32603 )
Standard JSON-RPC error codes
const MCPVersion = "2024-11-05"
MCP 协议版本
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientCapabilities ¶
type ClientCapabilities struct {
Roots *RootsCapability `json:"roots,omitempty"`
Sampling *SamplingCapability `json:"sampling,omitempty"`
Experimental map[string]interface{} `json:"experimental,omitempty"`
}
ClientCapabilities 客户端能力
type ClientInfo ¶
ClientInfo 客户端信息
type Connection ¶
type Connection struct {
ID string
Reader *bufio.Scanner
Writer io.Writer
Context context.Context
Cancel context.CancelFunc
Metadata map[string]interface{}
}
Connection 连接对象
type Content ¶
type Content struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Data string `json:"data,omitempty"`
URI string `json:"uri,omitempty"`
}
Content 内容
type FileCodeBoxMCPServer ¶
type FileCodeBoxMCPServer struct {
*Server
// contains filtered or unexported fields
}
FileCodeBoxMCPServer FileCodeBox MCP 服务器
func NewFileCodeBoxMCPServer ¶
func NewFileCodeBoxMCPServer( manager *config.ConfigManager, repositoryManager *repository.RepositoryManager, storageManager *storage.StorageManager, shareService *services.ShareService, adminService *services.AdminService, userService *services.UserService, ) *FileCodeBoxMCPServer
NewFileCodeBoxMCPServer 创建 FileCodeBox MCP 服务器
type InitializeRequest ¶
type InitializeRequest struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities ClientCapabilities `json:"capabilities"`
ClientInfo ClientInfo `json:"clientInfo"`
Meta map[string]interface{} `json:"meta,omitempty"`
}
InitializeRequest 初始化请求
type InitializeResult ¶
type InitializeResult struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities ServerCapabilities `json:"capabilities"`
ServerInfo ServerInfo `json:"serverInfo"`
Instructions string `json:"instructions,omitempty"`
}
InitializeResult 初始化结果
type JSONRPCMessage ¶
type JSONRPCMessage struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id,omitempty"`
Method string `json:"method,omitempty"`
Params interface{} `json:"params,omitempty"`
Result interface{} `json:"result,omitempty"`
Error *RPCError `json:"error,omitempty"`
}
JSONRPCMessage JSON-RPC 2.0 消息
func NewJSONRPCError ¶
func NewJSONRPCError(id interface{}, code int, message string, data interface{}) *JSONRPCMessage
NewJSONRPCError 创建 JSON-RPC 错误响应
func NewJSONRPCNotification ¶
func NewJSONRPCNotification(method string, params interface{}) *JSONRPCMessage
NewJSONRPCNotification 创建 JSON-RPC 通知
func NewJSONRPCRequest ¶
func NewJSONRPCRequest(id interface{}, method string, params interface{}) *JSONRPCMessage
NewJSONRPCRequest 创建 JSON-RPC 请求
func NewJSONRPCResponse ¶
func NewJSONRPCResponse(id interface{}, result interface{}) *JSONRPCMessage
NewJSONRPCResponse 创建 JSON-RPC 响应
func (*JSONRPCMessage) MarshalJSON ¶
func (msg *JSONRPCMessage) MarshalJSON() ([]byte, error)
MarshalJSON 自定义 JSON 序列化
type LoggingMessageNotification ¶
type LoggingMessageNotification struct {
Level LogLevel `json:"level"`
Data interface{} `json:"data"`
Logger string `json:"logger,omitempty"`
Meta map[string]interface{} `json:"meta,omitempty"`
}
LoggingMessageNotification 日志消息通知
type MCPManager ¶
type MCPManager struct {
// contains filtered or unexported fields
}
MCPManager MCP 服务器管理器
func NewMCPManager ¶
func NewMCPManager( manager *config.ConfigManager, daoManager *repository.RepositoryManager, storageManager *storage.StorageManager, shareService *services.ShareService, adminService *services.AdminService, userService *services.UserService, ) *MCPManager
NewMCPManager 创建新的 MCP 管理器
func (*MCPManager) ApplyConfig ¶
func (m *MCPManager) ApplyConfig(enableMCP bool, port string) error
ApplyConfig 应用配置更改
func (*MCPManager) RestartMCPServer ¶
func (m *MCPManager) RestartMCPServer(port string) error
RestartMCPServer 重启 MCP 服务器
func (*MCPManager) StartMCPServer ¶
func (m *MCPManager) StartMCPServer(port string) error
StartMCPServer 启动 MCP 服务器
func (*MCPManager) StopMCPServer ¶
func (m *MCPManager) StopMCPServer() error
StopMCPServer 停止 MCP 服务器
type MCPStatus ¶ added in v1.7.1
type MCPStatus struct {
Running bool `json:"running"`
Timestamp string `json:"timestamp"`
ServerInfo ServerInfo `json:"server_info,omitempty"`
}
MCPStatus MCP服务器状态
type PromptsCapability ¶
type PromptsCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
PromptsCapability 提示能力
type RPCError ¶
type RPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
RPCError JSON-RPC 错误
type Resource ¶
type Resource struct {
URI string `json:"uri"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
MimeType string `json:"mimeType,omitempty"`
}
Resource 资源定义
type ResourceContents ¶
type ResourceContents struct {
URI string `json:"uri"`
MimeType string `json:"mimeType,omitempty"`
Text string `json:"text,omitempty"`
Blob string `json:"blob,omitempty"` // Base64 encoded
}
ResourceContents 资源内容
type ResourceReader ¶
type ResourceReader func(ctx context.Context, uri string) (*ResourcesReadResult, error)
ResourceReader 资源读取器函数
type ResourcesCapability ¶
type ResourcesCapability struct {
Subscribe bool `json:"subscribe,omitempty"`
ListChanged bool `json:"listChanged,omitempty"`
}
ResourcesCapability 资源能力
type ResourcesListRequest ¶
type ResourcesListRequest struct {
Cursor string `json:"cursor,omitempty"`
}
ResourcesListRequest 资源列表请求
type ResourcesListResult ¶
type ResourcesListResult struct {
Resources []Resource `json:"resources"`
NextCursor *string `json:"nextCursor,omitempty"`
}
ResourcesListResult 资源列表结果
type ResourcesReadRequest ¶
type ResourcesReadRequest struct {
URI string `json:"uri"`
}
ResourcesReadRequest 资源读取请求
type ResourcesReadResult ¶
type ResourcesReadResult struct {
Contents []ResourceContents `json:"contents"`
}
ResourcesReadResult 资源读取结果
type RootsCapability ¶
type RootsCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
RootsCapability 根目录能力
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server MCP 服务器
func (*Server) AddResource ¶
func (s *Server) AddResource(resource Resource, reader ResourceReader)
AddResource 添加资源
func (*Server) LogMessage ¶
LogMessage 发送日志消息到客户端
func (*Server) SetInstructions ¶
SetInstructions 设置服务器说明
type ServerCapabilities ¶
type ServerCapabilities struct {
Logging *LoggingCapability `json:"logging,omitempty"`
Prompts *PromptsCapability `json:"prompts,omitempty"`
Resources *ResourcesCapability `json:"resources,omitempty"`
Tools *ToolsCapability `json:"tools,omitempty"`
Experimental map[string]interface{} `json:"experimental,omitempty"`
}
ServerCapabilities 服务器能力
type ServerInfo ¶
ServerInfo 服务器信息
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
InputSchema map[string]interface{} `json:"inputSchema"`
}
Tool 工具定义
type ToolCallRequest ¶
type ToolCallRequest struct {
Name string `json:"name"`
Arguments map[string]interface{} `json:"arguments,omitempty"`
}
ToolCallRequest 工具调用请求
type ToolCallResult ¶
type ToolCallResult struct {
Content []Content `json:"content"`
IsError bool `json:"isError,omitempty"`
}
ToolCallResult 工具调用结果
type ToolHandler ¶
type ToolHandler func(ctx context.Context, arguments map[string]interface{}) (*ToolCallResult, error)
ToolHandler 工具处理器函数
type ToolsCapability ¶
type ToolsCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
ToolsCapability 工具能力
type ToolsListRequest ¶
type ToolsListRequest struct {
Cursor string `json:"cursor,omitempty"`
}
ToolsListRequest 工具列表请求
type ToolsListResult ¶
type ToolsListResult struct {
Tools []Tool `json:"tools"`
NextCursor *string `json:"nextCursor,omitempty"`
}
ToolsListResult 工具列表结果