parent
dd79ca3d44
commit
c79a30ae0a
1 changed files with 29 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ import (
|
|||
"github.com/google/jsonschema-go/jsonschema"
|
||||
internaljson "github.com/modelcontextprotocol/go-sdk/internal/json"
|
||||
"github.com/modelcontextprotocol/go-sdk/internal/jsonrpc2"
|
||||
"github.com/modelcontextprotocol/go-sdk/internal/mcpgodebug"
|
||||
"github.com/modelcontextprotocol/go-sdk/internal/util"
|
||||
"github.com/modelcontextprotocol/go-sdk/jsonrpc"
|
||||
"github.com/yosida95/uritemplate/v3"
|
||||
|
|
@ -661,7 +662,23 @@ func (s *Server) capabilities() *ServerCapabilities {
|
|||
return caps
|
||||
}
|
||||
|
||||
// disablecompleteparamsvalidation is a compatibility parameter that restores
|
||||
// the previous behavior of [Server.complete], where required fields on
|
||||
// [CompleteParams] were not validated before dispatching to the completion
|
||||
// handler. See the documentation for the mcpgodebug package for instructions
|
||||
// how to enable it.
|
||||
// The option will be removed in a future version of the SDK.
|
||||
var disablecompleteparamsvalidation = mcpgodebug.Value("disablecompleteparamsvalidation")
|
||||
|
||||
func (s *Server) complete(ctx context.Context, req *CompleteRequest) (*CompleteResult, error) {
|
||||
if disablecompleteparamsvalidation != "1" {
|
||||
if req.Params.Ref == nil {
|
||||
return nil, fmt.Errorf("%w: missing required 'ref' field", jsonrpc2.ErrInvalidParams)
|
||||
}
|
||||
if req.Params.Argument.Name == "" {
|
||||
return nil, fmt.Errorf("%w: missing required 'argument.name' field", jsonrpc2.ErrInvalidParams)
|
||||
}
|
||||
}
|
||||
if s.opts.CompletionHandler == nil {
|
||||
return nil, jsonrpc2.ErrMethodNotFound
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue