Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion mcp/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

package mcp

// TODO: expand the aliases
type (
CallToolRequest = ServerRequest[*CallToolParams]
CompleteRequest = ServerRequest[*CompleteParams]
Expand Down
10 changes: 5 additions & 5 deletions mcp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ func (s *Server) AddTool(t *Tool, h ToolHandler) {
func() bool { s.tools.add(st); return true })
}

// toolFor returns a shallow copy of t and a [ToolHandler] that wraps h.
// ToolFor returns a shallow copy of t and a [ToolHandler] that wraps h.
// If the tool's input schema is nil, it is set to the schema inferred from the In
// type parameter, using [jsonschema.For].
// If the tool's output schema is nil and the Out type parameter is not the empty
// interface, then the output schema is set to the schema inferred from Out.
//
// Most users will call [AddTool]. Use [toolFor] if you wish to wrap the ToolHandler
// before calling [Server.AddTool].
func toolFor[In, Out any](t *Tool, h ToolHandlerFor[In, Out]) (*Tool, ToolHandler) {
// Most users will call [AddTool]. Use [ToolFor] if you wish to modify the tool's
// schemas or wrap the ToolHandler before calling [Server.AddTool].
func ToolFor[In, Out any](t *Tool, h ToolHandlerFor[In, Out]) (*Tool, ToolHandler) {
tt, hh, err := toolForErr(t, h)
if err != nil {
panic(fmt.Sprintf("ToolFor: tool %q: %v", t.Name, err))
Expand Down Expand Up @@ -303,7 +303,7 @@ func setSchema[T any](sfield **jsonschema.Schema, rfield **jsonschema.Resolved)
// If the tool's output schema is nil and the Out type parameter is not the empty
// interface, then the copy's output schema is set to the schema inferred from Out.
func AddTool[In, Out any](s *Server, t *Tool, h ToolHandlerFor[In, Out]) {
s.AddTool(toolFor(t, h))
s.AddTool(ToolFor(t, h))
}

// RemoveTools removes the tools with the given names.
Expand Down