parent
dd79ca3d44
commit
c79a30ae0a
3 changed files with 29 additions and 0 deletions
|
|
@ -50,6 +50,12 @@ Options listed below were added and will be removed in the 1.9.0 version of the
|
|||
restoring the previous behavior. The default behavior was changed so that
|
||||
the client always attempts to surface the underlying JSON-RPC error.
|
||||
|
||||
- `disablecompleteparamsvalidation` added. If set to `1`, `Server.complete`
|
||||
will not validate that the required `ref` and `argument.name` fields on
|
||||
`CompleteParams` are present, restoring the previous behavior of dispatching
|
||||
the request to the completion handler unconditionally. The default behavior
|
||||
was changed to reject malformed requests with `-32602` (Invalid Params).
|
||||
|
||||
### 1.6.1
|
||||
|
||||
Options listed below were added and will be removed in the 1.8.0 version of the SDK.
|
||||
|
|
|
|||
|
|
@ -49,6 +49,12 @@ Options listed below were added and will be removed in the 1.9.0 version of the
|
|||
restoring the previous behavior. The default behavior was changed so that
|
||||
the client always attempts to surface the underlying JSON-RPC error.
|
||||
|
||||
- `disablecompleteparamsvalidation` added. If set to `1`, `Server.complete`
|
||||
will not validate that the required `ref` and `argument.name` fields on
|
||||
`CompleteParams` are present, restoring the previous behavior of dispatching
|
||||
the request to the completion handler unconditionally. The default behavior
|
||||
was changed to reject malformed requests with `-32602` (Invalid Params).
|
||||
|
||||
### 1.6.1
|
||||
|
||||
Options listed below were added and will be removed in the 1.8.0 version of the SDK.
|
||||
|
|
|
|||
|
|
@ -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