Documentation
¶
Index ¶
- Variables
- func RegisterTools(server *mcp.Server, handler Handler, middleware ...Middleware) error
- type CreatePetRequest
- type EchoInput
- type EchoOutput
- type GetPetInput
- type HTTPOptions
- type Handler
- type Middleware
- type Pet
- type PetKind
- type SearchInput
- type SearchInputFilter
- type SearchInputSort
- type SearchResult
- type Server
- type ServerOption
- type ToolError
- type ToolHandlerFunc
- type UnimplementedHandler
- func (UnimplementedHandler) CreatePet(context.Context, CreatePetRequest) (Pet, error)
- func (UnimplementedHandler) Echo(context.Context, EchoInput) (EchoOutput, error)
- func (UnimplementedHandler) GetPet(context.Context, GetPetInput) (Pet, error)
- func (UnimplementedHandler) Search(context.Context, SearchInput) (SearchResult, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotImplemented = ToolError{Code: "not_implemented", Message: "tool not implemented"}
Functions ¶
func RegisterTools ¶
func RegisterTools(server *mcp.Server, handler Handler, middleware ...Middleware) error
RegisterTools adds every generated tool to an existing SDK server. Call it during startup; names in this specification replace existing tools with the same name.
Types ¶
type CreatePetRequest ¶
type EchoOutput ¶
type EchoOutput struct {
Message string `json:"message"`
}
type GetPetInput ¶
type GetPetInput struct {
PetID string `json:"pet_id"`
}
type HTTPOptions ¶
HTTPOptions configures the Streamable HTTP endpoint.
type Handler ¶
type Handler interface {
CreatePet(context.Context, CreatePetRequest) (Pet, error)
Echo(context.Context, EchoInput) (EchoOutput, error)
GetPet(context.Context, GetPetInput) (Pet, error)
Search(context.Context, SearchInput) (SearchResult, error)
}
type Middleware ¶
type Middleware func(ToolHandlerFunc) ToolHandlerFunc
type SearchInput ¶
type SearchInput struct {
Filter *SearchInputFilter `json:"filter,omitempty"`
Limit *int64 `json:"limit,omitempty"`
// Case-insensitive name substring.
Query string `json:"query"`
Sort *SearchInputSort `json:"sort,omitempty"`
}
type SearchInputFilter ¶
type SearchInputFilter struct {
IDs *[]string `json:"ids,omitempty"`
}
type SearchInputSort ¶
type SearchInputSort string
const ( SearchInputSortRelevance SearchInputSort = "relevance" SearchInputSortCreatedAt SearchInputSort = "created_at" )
type SearchResult ¶
type SearchResult struct {
Pets []Pet `json:"pets"`
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) HTTPHandler ¶
func (s *Server) HTTPHandler(opts *HTTPOptions) http.Handler
HTTPHandler creates an endpoint to mount once on an existing HTTP router. A nil options value uses SDK defaults (stateful sessions and SSE responses).
type ServerOption ¶
type ServerOption func(*serverConfig)
func WithLogger ¶
func WithLogger(logger *slog.Logger) ServerOption
func WithMiddleware ¶
func WithMiddleware(middleware ...Middleware) ServerOption
WithMiddleware runs middleware in declaration order, after input validation.
type ToolError ¶
func NewToolError ¶
type ToolHandlerFunc ¶
ToolHandlerFunc receives a tool name and its decoded generated input type. Return the tool's generated output type on success.
type UnimplementedHandler ¶
type UnimplementedHandler struct{}
func (UnimplementedHandler) CreatePet ¶
func (UnimplementedHandler) CreatePet(context.Context, CreatePetRequest) (Pet, error)
func (UnimplementedHandler) Echo ¶
func (UnimplementedHandler) Echo(context.Context, EchoInput) (EchoOutput, error)
func (UnimplementedHandler) GetPet ¶
func (UnimplementedHandler) GetPet(context.Context, GetPetInput) (Pet, error)
func (UnimplementedHandler) Search ¶
func (UnimplementedHandler) Search(context.Context, SearchInput) (SearchResult, error)
Click to show internal directories.
Click to hide internal directories.