Skip to content

Commit 9b2e031

Browse files
committed
internal/mcp: disable schema validation
Schema validation is causing breakage for some usage inide of Google. While this may be a downstream bug, it is blocking the import of x/tools into Google. Disable it for now, to unblock the import. No tests failed when schema validation is removed. We need to add more tests before re-enabling this feature. Change-Id: I72905a93bfb0a2d81bae467d903f027e71719487 Reviewed-on: https://go-review.googlesource.com/c/tools/+/684935 Reviewed-by: Jonathan Amsterdam <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 134edd9 commit 9b2e031

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

internal/mcp/server.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919

2020
jsonrpc2 "golang.org/x/tools/internal/jsonrpc2_v2"
2121
"golang.org/x/tools/internal/mcp/internal/util"
22-
"golang.org/x/tools/internal/mcp/jsonschema"
2322
)
2423

2524
const DefaultPageSize = 1000
@@ -138,13 +137,14 @@ func (s *Server) addToolsErr(tools ...*ServerTool) error {
138137
st.rawHandler = newRawHandler(st)
139138
// Resolve the schemas, with no base URI. We don't expect tool schemas to
140139
// refer outside of themselves.
141-
if st.Tool.InputSchema != nil {
142-
r, err := st.Tool.InputSchema.Resolve(&jsonschema.ResolveOptions{ValidateDefaults: true})
143-
if err != nil {
144-
return err
145-
}
146-
st.inputResolved = r
147-
}
140+
// TODO(rfindley): re-enable schema validation. See note in [ServerTool].
141+
// if st.Tool.InputSchema != nil {
142+
// r, err := st.Tool.InputSchema.Resolve(&jsonschema.ResolveOptions{ValidateDefaults: true})
143+
// if err != nil {
144+
// return err
145+
// }
146+
// st.inputResolved = r
147+
// }
148148

149149
// TODO: uncomment when output schemas drop.
150150
// if st.Tool.OutputSchema != nil {

internal/mcp/tool.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ type ServerTool struct {
3333
// Set in NewServerTool or Server.AddToolsErr.
3434
rawHandler rawToolHandler
3535
// Resolved tool schemas. Set in Server.AddToolsErr.
36-
inputResolved, outputResolved *jsonschema.Resolved
36+
// TODO(rfindley): re-enable schema validation. For now, it is causing breakage in Google.
37+
// inputResolved, outputResolved *jsonschema.Resolved
3738
}
3839

3940
// NewServerTool is a helper to make a tool using reflection on the given type parameters.
@@ -79,7 +80,8 @@ func newServerToolErr[In, Out any](name, description string, handler ToolHandler
7980
t.rawHandler = func(ctx context.Context, ss *ServerSession, rparams *CallToolParamsFor[json.RawMessage]) (*CallToolResult, error) {
8081
var args In
8182
if rparams.Arguments != nil {
82-
if err := unmarshalSchema(rparams.Arguments, t.inputResolved, &args); err != nil {
83+
// TODO(rfindley): re-enable schema validation. See note in [ServerTool].
84+
if err := unmarshalSchema(rparams.Arguments, nil, &args); err != nil {
8385
return nil, err
8486
}
8587
}
@@ -117,7 +119,8 @@ func newRawHandler(st *ServerTool) rawToolHandler {
117119
// Unmarshal the args into what should be a map.
118120
var args map[string]any
119121
if rparams.Arguments != nil {
120-
if err := unmarshalSchema(rparams.Arguments, st.inputResolved, &args); err != nil {
122+
// TODO(rfindley): re-enable schema validation. See note in [ServerTool].
123+
if err := unmarshalSchema(rparams.Arguments, nil, &args); err != nil {
121124
return nil, err
122125
}
123126
}

0 commit comments

Comments
 (0)