@@ -12,7 +12,6 @@ import (
1212 "encoding/json"
1313 "fmt"
1414 "iter"
15- "log"
1615 "maps"
1716 "net/url"
1817 "path/filepath"
@@ -132,13 +131,18 @@ func (s *Server) RemovePrompts(names ...string) {
132131}
133132
134133// AddTool adds a [Tool] to the server, or replaces one with the same name.
135- // The tool's input schema must be non-nil.
136134// The Tool argument must not be modified after this call.
135+ //
136+ // The tool's input schema must be non-nil. For a tool that takes no input,
137+ // or one where any input is valid, set [Tool.InputSchema] to the empty schema,
138+ // &jsonschema.Schema{}.
137139func (s * Server ) AddTool (t * Tool , h ToolHandler ) {
138- // TODO(jba): This is a breaking behavior change. Add before v0.2.0?
139140 if t .InputSchema == nil {
140- log .Printf ("mcp: tool %q has a nil input schema. This will panic in a future release." , t .Name )
141- // panic(fmt.Sprintf("adding tool %q: nil input schema", t.Name))
141+ // This prevents the tool author from forgetting to write a schema where
142+ // one should be provided. If we papered over this by supplying the empty
143+ // schema, then every input would be validated and the problem wouldn't be
144+ // discovered until runtime, when the LLM sent bad data.
145+ panic (fmt .Sprintf ("adding tool %q: nil input schema" , t .Name ))
142146 }
143147 if err := addToolErr (s , t , h ); err != nil {
144148 panic (err )
0 commit comments