Documentation
¶
Index ¶
- type FastMCP
- func (f *FastMCP) GetCapabilities() protocol.ServerCapabilities
- func (f *FastMCP) GetServerInfo() protocol.ServerInfo
- func (f *FastMCP) HandleMessage(ctx context.Context, data []byte) ([]byte, error)
- func (f *FastMCP) Prompt(name, description string) *PromptBuilder
- func (f *FastMCP) Resource(uri, name, description string) *ResourceBuilder
- func (f *FastMCP) SendNotification(method string, params interface{}) error
- func (f *FastMCP) Server() *MCPServer
- func (f *FastMCP) SetNotificationHandler(handler func(method string, params interface{}) error)
- func (f *FastMCP) SimpleStructuredTool(name, description string, outputSchema protocol.JSONSchema, ...) error
- func (f *FastMCP) SimpleStructuredToolWithText(name, description string, outputSchema protocol.JSONSchema, ...) error
- func (f *FastMCP) SimpleTextPrompt(name, description string, ...) error
- func (f *FastMCP) SimpleTextResource(uri, name, description string, ...) error
- func (f *FastMCP) SimpleTextTool(name, description string, ...) error
- func (f *FastMCP) Tool(name, description string) *ToolBuilder
- type MCPServer
- func (s *MCPServer) GetCapabilities() protocol.ServerCapabilities
- func (s *MCPServer) GetServerInfo() protocol.ServerInfo
- func (s *MCPServer) HandleMessage(ctx context.Context, message *protocol.JSONRPCMessage) (*protocol.JSONRPCMessage, error)
- func (s *MCPServer) RegisterPrompt(name, description string, arguments []protocol.PromptArgument, ...) error
- func (s *MCPServer) RegisterResource(uri, name, description, mimeType string, handler ResourceHandler) error
- func (s *MCPServer) RegisterTool(name, description string, inputSchema protocol.JSONSchema, handler ToolHandler, ...) error
- func (s *MCPServer) SendNotification(method string, params interface{}) error
- func (s *MCPServer) SetNotificationHandler(handler func(method string, params interface{}) error)
- func (s *MCPServer) UnregisterPrompt(name string) error
- func (s *MCPServer) UnregisterResource(uri string) error
- func (s *MCPServer) UnregisterTool(name string) error
- type PromptBuilder
- type PromptHandler
- type PromptRegistration
- type ResourceBuilder
- type ResourceHandler
- type ResourceRegistration
- type Server
- type ToolBuilder
- func (tb *ToolBuilder) Handle(handler ToolHandler) error
- func (tb *ToolBuilder) HandleWithValidation(handler ToolHandler) error
- func (tb *ToolBuilder) WithBoolParam(name, description string, required bool) *ToolBuilder
- func (tb *ToolBuilder) WithInputSchema(schema protocol.JSONSchema) *ToolBuilder
- func (tb *ToolBuilder) WithIntParam(name, description string, required bool) *ToolBuilder
- func (tb *ToolBuilder) WithNumberParam(name, description string, required bool) *ToolBuilder
- func (tb *ToolBuilder) WithOutputSchema(schema protocol.JSONSchema) *ToolBuilder
- func (tb *ToolBuilder) WithStringParam(name, description string, required bool) *ToolBuilder
- func (tb *ToolBuilder) WithStructOutputSchema(v interface{}) *ToolBuilder
- func (tb *ToolBuilder) WithStructSchema(v interface{}) *ToolBuilder
- type ToolHandler
- type ToolOptions
- type ToolRegistration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FastMCP ¶
type FastMCP struct {
// contains filtered or unexported fields
}
func NewFastMCP ¶
func (*FastMCP) GetCapabilities ¶
func (f *FastMCP) GetCapabilities() protocol.ServerCapabilities
func (*FastMCP) GetServerInfo ¶
func (f *FastMCP) GetServerInfo() protocol.ServerInfo
func (*FastMCP) HandleMessage ¶
func (*FastMCP) Prompt ¶
func (f *FastMCP) Prompt(name, description string) *PromptBuilder
Prompt 提示模板链式API
func (*FastMCP) Resource ¶
func (f *FastMCP) Resource(uri, name, description string) *ResourceBuilder
Resource 资源链式API
func (*FastMCP) SendNotification ¶
func (*FastMCP) SetNotificationHandler ¶
func (*FastMCP) SimpleStructuredTool ¶ added in v1.1.0
func (f *FastMCP) SimpleStructuredTool(name, description string, outputSchema protocol.JSONSchema, handler func(ctx context.Context, args map[string]interface{}) (interface{}, error)) error
SimpleStructuredTool 创建返回结构化数据的简单工具 (MCP 2025-06-18)
func (*FastMCP) SimpleStructuredToolWithText ¶ added in v1.1.0
func (f *FastMCP) SimpleStructuredToolWithText(name, description string, outputSchema protocol.JSONSchema, handler func(ctx context.Context, args map[string]interface{}) (string, interface{}, error)) error
SimpleStructuredToolWithText 创建返回文本和结构化数据的工具
func (*FastMCP) SimpleTextPrompt ¶
func (*FastMCP) SimpleTextResource ¶
func (*FastMCP) SimpleTextTool ¶
func (*FastMCP) Tool ¶
func (f *FastMCP) Tool(name, description string) *ToolBuilder
type MCPServer ¶
type MCPServer struct {
// contains filtered or unexported fields
}
func (*MCPServer) GetCapabilities ¶
func (s *MCPServer) GetCapabilities() protocol.ServerCapabilities
GetCapabilities 获取服务器能力
func (*MCPServer) GetServerInfo ¶
func (s *MCPServer) GetServerInfo() protocol.ServerInfo
GetServerInfo 获取服务器信息
func (*MCPServer) HandleMessage ¶
func (s *MCPServer) HandleMessage(ctx context.Context, message *protocol.JSONRPCMessage) (*protocol.JSONRPCMessage, error)
HandleMessage 处理JSON-RPC消息
func (*MCPServer) RegisterPrompt ¶
func (s *MCPServer) RegisterPrompt(name, description string, arguments []protocol.PromptArgument, handler PromptHandler) error
RegisterPrompt 注册提示模板
func (*MCPServer) RegisterResource ¶
func (s *MCPServer) RegisterResource(uri, name, description, mimeType string, handler ResourceHandler) error
RegisterResource 注册资源
func (*MCPServer) RegisterTool ¶
func (s *MCPServer) RegisterTool(name, description string, inputSchema protocol.JSONSchema, handler ToolHandler, opts ...ToolOptions) error
RegisterTool 注册工具,支持可选的输出模式
func (*MCPServer) SendNotification ¶
SendNotification 发送通知
func (*MCPServer) SetNotificationHandler ¶
SetNotificationHandler 设置通知处理器
func (*MCPServer) UnregisterPrompt ¶
UnregisterPrompt 注销提示模板
func (*MCPServer) UnregisterResource ¶
UnregisterResource 注销资源
func (*MCPServer) UnregisterTool ¶
UnregisterTool 注销工具
type PromptBuilder ¶
type PromptBuilder struct {
// contains filtered or unexported fields
}
func (*PromptBuilder) Handle ¶
func (pb *PromptBuilder) Handle(handler PromptHandler) error
Handle 注册提示模板处理器
func (*PromptBuilder) WithArgument ¶
func (pb *PromptBuilder) WithArgument(name, description string, required bool) *PromptBuilder
WithArgument 添加参数
type PromptHandler ¶
type PromptRegistration ¶
type PromptRegistration struct {
Prompt protocol.Prompt
Handler PromptHandler
}
type ResourceBuilder ¶
type ResourceBuilder struct {
// contains filtered or unexported fields
}
func (*ResourceBuilder) Handle ¶
func (rb *ResourceBuilder) Handle(handler ResourceHandler) error
Handle 注册资源处理器
func (*ResourceBuilder) WithMimeType ¶
func (rb *ResourceBuilder) WithMimeType(mimeType string) *ResourceBuilder
WithMimeType 设置MIME类型
type ResourceHandler ¶
type ResourceHandler func(ctx context.Context) (*protocol.ReadResourceResult, error)
type ResourceRegistration ¶
type ResourceRegistration struct {
Resource protocol.Resource
Handler ResourceHandler
}
type Server ¶
type Server interface {
RegisterTool(name, description string, inputSchema protocol.JSONSchema, handler ToolHandler) error
UnregisterTool(name string) error
RegisterResource(uri, name, description, mimeType string, handler ResourceHandler) error
UnregisterResource(uri string) error
RegisterPrompt(name, description string, arguments []protocol.PromptArgument, handler PromptHandler) error
UnregisterPrompt(name string) error
GetServerInfo() protocol.ServerInfo
GetCapabilities() protocol.ServerCapabilities
HandleMessage(ctx context.Context, message *protocol.JSONRPCMessage) (*protocol.JSONRPCMessage, error)
SendNotification(method string, params interface{}) error
}
type ToolBuilder ¶
type ToolBuilder struct {
// contains filtered or unexported fields
}
func (*ToolBuilder) Handle ¶
func (tb *ToolBuilder) Handle(handler ToolHandler) error
Handle 注册工具处理器
func (*ToolBuilder) HandleWithValidation ¶
func (tb *ToolBuilder) HandleWithValidation(handler ToolHandler) error
HandleWithValidation 带验证的工具处理器
func (*ToolBuilder) WithBoolParam ¶
func (tb *ToolBuilder) WithBoolParam(name, description string, required bool) *ToolBuilder
WithBoolParam 添加布尔参数
func (*ToolBuilder) WithInputSchema ¶
func (tb *ToolBuilder) WithInputSchema(schema protocol.JSONSchema) *ToolBuilder
WithInputSchema 设置自定义输入schema
func (*ToolBuilder) WithIntParam ¶
func (tb *ToolBuilder) WithIntParam(name, description string, required bool) *ToolBuilder
WithIntParam 添加整数参数
func (*ToolBuilder) WithNumberParam ¶
func (tb *ToolBuilder) WithNumberParam(name, description string, required bool) *ToolBuilder
WithNumberParam 添加数字参数(支持整数和浮点数)
func (*ToolBuilder) WithOutputSchema ¶ added in v1.1.0
func (tb *ToolBuilder) WithOutputSchema(schema protocol.JSONSchema) *ToolBuilder
WithOutputSchema 设置输出模式 (MCP 2025-06-18)
func (*ToolBuilder) WithStringParam ¶
func (tb *ToolBuilder) WithStringParam(name, description string, required bool) *ToolBuilder
func (*ToolBuilder) WithStructOutputSchema ¶ added in v1.1.0
func (tb *ToolBuilder) WithStructOutputSchema(v interface{}) *ToolBuilder
WithStructOutputSchema 使用结构体自动生成输出模式
func (*ToolBuilder) WithStructSchema ¶
func (tb *ToolBuilder) WithStructSchema(v interface{}) *ToolBuilder
WithStructSchema 使用结构体自动生成schema
type ToolHandler ¶
type ToolOptions ¶ added in v1.1.0
type ToolOptions struct {
OutputSchema protocol.JSONSchema // 可选的输出模式 (MCP 2025-06-18)
}
ToolOptions 工具注册选项
type ToolRegistration ¶
type ToolRegistration struct {
Tool protocol.Tool
Handler ToolHandler
}