mcp: allow any value for schemas (#517)
As discussed at length in https://github.com/modelcontextprotocol/go-sdk/issues/518, coupling our schema fields to jsonschema.Schema limits our user's ability to use a different schema package, and makes it impossible for our client to talk to some backends. This CL relaxes the type of `*jsonschema.Schema` fields to be of type `any`, which is a breaking change but is unlikely to affect most server code. (It *is* a nontrivial change for clients). Fixes https://github.com/modelcontextprotocol/go-sdk/issues/518
This commit is contained in:
parent
5f05f8a43a
commit
964574b818
1 changed files with 201 additions and 47 deletions
14
mcp/util.go
14
mcp/util.go
|
|
@ -6,6 +6,7 @@ package mcp
|
|||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
func assert(cond bool, msg string) {
|
||||
|
|
@ -27,3 +28,16 @@ func randText() string {
|
|||
}
|
||||
return string(src)
|
||||
}
|
||||
|
||||
// remarshal marshals from to JSON, and then unmarshals into to, which must be
|
||||
// a pointer type.
|
||||
func remarshal(from, to any) error {
|
||||
data, err := json.Marshal(from)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := json.Unmarshal(data, to); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue