From 15e0c9ef02bc2ac9b359f10ad48f31b03fcf9c62 Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Mon, 5 May 2025 15:31:09 -0400 Subject: [PATCH] internal/mcp: move jsonschema out of mcp/internal The jsonschema package is part of of the API of the mcp package, so it should not be internal. Change-Id: I9520797837329fc2cda09c2f46ec4d48d031b9d3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/669996 LUCI-TryBot-Result: Go LUCI Reviewed-by: Robert Findley --- internal/protocol/protocol.go | 2 +- {internal/jsonschema => jsonschema}/annotations.go | 0 {internal/jsonschema => jsonschema}/infer.go | 0 {internal/jsonschema => jsonschema}/infer_test.go | 2 +- {internal/jsonschema => jsonschema}/resolve.go | 0 {internal/jsonschema => jsonschema}/resolve_test.go | 0 {internal/jsonschema => jsonschema}/schema.go | 0 {internal/jsonschema => jsonschema}/schema_test.go | 0 .../jsonschema => jsonschema}/testdata/draft2020-12/README.md | 0 .../testdata/draft2020-12/additionalProperties.json | 0 .../jsonschema => jsonschema}/testdata/draft2020-12/allOf.json | 0 .../jsonschema => jsonschema}/testdata/draft2020-12/anyOf.json | 0 .../testdata/draft2020-12/boolean_schema.json | 0 .../jsonschema => jsonschema}/testdata/draft2020-12/const.json | 0 .../testdata/draft2020-12/contains.json | 0 .../testdata/draft2020-12/dependentRequired.json | 0 .../testdata/draft2020-12/dependentSchemas.json | 0 .../jsonschema => jsonschema}/testdata/draft2020-12/enum.json | 0 .../testdata/draft2020-12/exclusiveMaximum.json | 0 .../testdata/draft2020-12/exclusiveMinimum.json | 0 .../testdata/draft2020-12/if-then-else.json | 0 .../testdata/draft2020-12/infinite-loop-detection.json | 0 .../jsonschema => jsonschema}/testdata/draft2020-12/items.json | 0 .../testdata/draft2020-12/maxContains.json | 0 .../testdata/draft2020-12/maxItems.json | 0 .../testdata/draft2020-12/maxLength.json | 0 .../testdata/draft2020-12/maxProperties.json | 0 .../testdata/draft2020-12/maximum.json | 0 .../testdata/draft2020-12/minContains.json | 0 .../testdata/draft2020-12/minItems.json | 0 .../testdata/draft2020-12/minLength.json | 0 .../testdata/draft2020-12/minProperties.json | 0 .../testdata/draft2020-12/minimum.json | 0 .../testdata/draft2020-12/multipleOf.json | 0 .../jsonschema => jsonschema}/testdata/draft2020-12/not.json | 0 .../jsonschema => jsonschema}/testdata/draft2020-12/oneOf.json | 0 .../testdata/draft2020-12/pattern.json | 0 .../testdata/draft2020-12/patternProperties.json | 0 .../testdata/draft2020-12/prefixItems.json | 0 .../testdata/draft2020-12/properties.json | 0 .../testdata/draft2020-12/propertyNames.json | 0 .../testdata/draft2020-12/required.json | 0 .../jsonschema => jsonschema}/testdata/draft2020-12/type.json | 0 .../testdata/draft2020-12/unevaluatedItems.json | 0 .../testdata/draft2020-12/unevaluatedProperties.json | 0 .../testdata/draft2020-12/uniqueItems.json | 0 {internal/jsonschema => jsonschema}/util.go | 0 {internal/jsonschema => jsonschema}/util_test.go | 0 {internal/jsonschema => jsonschema}/validate.go | 0 {internal/jsonschema => jsonschema}/validate_test.go | 0 mcp/mcp_test.go | 2 +- mcp/prompt.go | 2 +- mcp/tool.go | 2 +- mcp/tool_test.go | 2 +- 54 files changed, 6 insertions(+), 6 deletions(-) rename {internal/jsonschema => jsonschema}/annotations.go (100%) rename {internal/jsonschema => jsonschema}/infer.go (100%) rename {internal/jsonschema => jsonschema}/infer_test.go (97%) rename {internal/jsonschema => jsonschema}/resolve.go (100%) rename {internal/jsonschema => jsonschema}/resolve_test.go (100%) rename {internal/jsonschema => jsonschema}/schema.go (100%) rename {internal/jsonschema => jsonschema}/schema_test.go (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/README.md (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/additionalProperties.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/allOf.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/anyOf.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/boolean_schema.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/const.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/contains.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/dependentRequired.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/dependentSchemas.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/enum.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/exclusiveMaximum.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/exclusiveMinimum.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/if-then-else.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/infinite-loop-detection.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/items.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/maxContains.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/maxItems.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/maxLength.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/maxProperties.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/maximum.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/minContains.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/minItems.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/minLength.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/minProperties.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/minimum.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/multipleOf.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/not.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/oneOf.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/pattern.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/patternProperties.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/prefixItems.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/properties.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/propertyNames.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/required.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/type.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/unevaluatedItems.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/unevaluatedProperties.json (100%) rename {internal/jsonschema => jsonschema}/testdata/draft2020-12/uniqueItems.json (100%) rename {internal/jsonschema => jsonschema}/util.go (100%) rename {internal/jsonschema => jsonschema}/util_test.go (100%) rename {internal/jsonschema => jsonschema}/validate.go (100%) rename {internal/jsonschema => jsonschema}/validate_test.go (100%) diff --git a/internal/protocol/protocol.go b/internal/protocol/protocol.go index 126816c..800ed88 100644 --- a/internal/protocol/protocol.go +++ b/internal/protocol/protocol.go @@ -9,7 +9,7 @@ package protocol import ( "encoding/json" - "github.com/modelcontextprotocol/go-sdk/internal/jsonschema" + "github.com/modelcontextprotocol/go-sdk/jsonschema" ) // Optional annotations for the client. The client can use annotations to inform diff --git a/internal/jsonschema/annotations.go b/jsonschema/annotations.go similarity index 100% rename from internal/jsonschema/annotations.go rename to jsonschema/annotations.go diff --git a/internal/jsonschema/infer.go b/jsonschema/infer.go similarity index 100% rename from internal/jsonschema/infer.go rename to jsonschema/infer.go diff --git a/internal/jsonschema/infer_test.go b/jsonschema/infer_test.go similarity index 97% rename from internal/jsonschema/infer_test.go rename to jsonschema/infer_test.go index f60f16b..e99a273 100644 --- a/internal/jsonschema/infer_test.go +++ b/jsonschema/infer_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - "github.com/modelcontextprotocol/go-sdk/internal/jsonschema" + "github.com/modelcontextprotocol/go-sdk/jsonschema" ) func forType[T any]() *jsonschema.Schema { diff --git a/internal/jsonschema/resolve.go b/jsonschema/resolve.go similarity index 100% rename from internal/jsonschema/resolve.go rename to jsonschema/resolve.go diff --git a/internal/jsonschema/resolve_test.go b/jsonschema/resolve_test.go similarity index 100% rename from internal/jsonschema/resolve_test.go rename to jsonschema/resolve_test.go diff --git a/internal/jsonschema/schema.go b/jsonschema/schema.go similarity index 100% rename from internal/jsonschema/schema.go rename to jsonschema/schema.go diff --git a/internal/jsonschema/schema_test.go b/jsonschema/schema_test.go similarity index 100% rename from internal/jsonschema/schema_test.go rename to jsonschema/schema_test.go diff --git a/internal/jsonschema/testdata/draft2020-12/README.md b/jsonschema/testdata/draft2020-12/README.md similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/README.md rename to jsonschema/testdata/draft2020-12/README.md diff --git a/internal/jsonschema/testdata/draft2020-12/additionalProperties.json b/jsonschema/testdata/draft2020-12/additionalProperties.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/additionalProperties.json rename to jsonschema/testdata/draft2020-12/additionalProperties.json diff --git a/internal/jsonschema/testdata/draft2020-12/allOf.json b/jsonschema/testdata/draft2020-12/allOf.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/allOf.json rename to jsonschema/testdata/draft2020-12/allOf.json diff --git a/internal/jsonschema/testdata/draft2020-12/anyOf.json b/jsonschema/testdata/draft2020-12/anyOf.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/anyOf.json rename to jsonschema/testdata/draft2020-12/anyOf.json diff --git a/internal/jsonschema/testdata/draft2020-12/boolean_schema.json b/jsonschema/testdata/draft2020-12/boolean_schema.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/boolean_schema.json rename to jsonschema/testdata/draft2020-12/boolean_schema.json diff --git a/internal/jsonschema/testdata/draft2020-12/const.json b/jsonschema/testdata/draft2020-12/const.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/const.json rename to jsonschema/testdata/draft2020-12/const.json diff --git a/internal/jsonschema/testdata/draft2020-12/contains.json b/jsonschema/testdata/draft2020-12/contains.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/contains.json rename to jsonschema/testdata/draft2020-12/contains.json diff --git a/internal/jsonschema/testdata/draft2020-12/dependentRequired.json b/jsonschema/testdata/draft2020-12/dependentRequired.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/dependentRequired.json rename to jsonschema/testdata/draft2020-12/dependentRequired.json diff --git a/internal/jsonschema/testdata/draft2020-12/dependentSchemas.json b/jsonschema/testdata/draft2020-12/dependentSchemas.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/dependentSchemas.json rename to jsonschema/testdata/draft2020-12/dependentSchemas.json diff --git a/internal/jsonschema/testdata/draft2020-12/enum.json b/jsonschema/testdata/draft2020-12/enum.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/enum.json rename to jsonschema/testdata/draft2020-12/enum.json diff --git a/internal/jsonschema/testdata/draft2020-12/exclusiveMaximum.json b/jsonschema/testdata/draft2020-12/exclusiveMaximum.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/exclusiveMaximum.json rename to jsonschema/testdata/draft2020-12/exclusiveMaximum.json diff --git a/internal/jsonschema/testdata/draft2020-12/exclusiveMinimum.json b/jsonschema/testdata/draft2020-12/exclusiveMinimum.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/exclusiveMinimum.json rename to jsonschema/testdata/draft2020-12/exclusiveMinimum.json diff --git a/internal/jsonschema/testdata/draft2020-12/if-then-else.json b/jsonschema/testdata/draft2020-12/if-then-else.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/if-then-else.json rename to jsonschema/testdata/draft2020-12/if-then-else.json diff --git a/internal/jsonschema/testdata/draft2020-12/infinite-loop-detection.json b/jsonschema/testdata/draft2020-12/infinite-loop-detection.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/infinite-loop-detection.json rename to jsonschema/testdata/draft2020-12/infinite-loop-detection.json diff --git a/internal/jsonschema/testdata/draft2020-12/items.json b/jsonschema/testdata/draft2020-12/items.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/items.json rename to jsonschema/testdata/draft2020-12/items.json diff --git a/internal/jsonschema/testdata/draft2020-12/maxContains.json b/jsonschema/testdata/draft2020-12/maxContains.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/maxContains.json rename to jsonschema/testdata/draft2020-12/maxContains.json diff --git a/internal/jsonschema/testdata/draft2020-12/maxItems.json b/jsonschema/testdata/draft2020-12/maxItems.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/maxItems.json rename to jsonschema/testdata/draft2020-12/maxItems.json diff --git a/internal/jsonschema/testdata/draft2020-12/maxLength.json b/jsonschema/testdata/draft2020-12/maxLength.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/maxLength.json rename to jsonschema/testdata/draft2020-12/maxLength.json diff --git a/internal/jsonschema/testdata/draft2020-12/maxProperties.json b/jsonschema/testdata/draft2020-12/maxProperties.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/maxProperties.json rename to jsonschema/testdata/draft2020-12/maxProperties.json diff --git a/internal/jsonschema/testdata/draft2020-12/maximum.json b/jsonschema/testdata/draft2020-12/maximum.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/maximum.json rename to jsonschema/testdata/draft2020-12/maximum.json diff --git a/internal/jsonschema/testdata/draft2020-12/minContains.json b/jsonschema/testdata/draft2020-12/minContains.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/minContains.json rename to jsonschema/testdata/draft2020-12/minContains.json diff --git a/internal/jsonschema/testdata/draft2020-12/minItems.json b/jsonschema/testdata/draft2020-12/minItems.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/minItems.json rename to jsonschema/testdata/draft2020-12/minItems.json diff --git a/internal/jsonschema/testdata/draft2020-12/minLength.json b/jsonschema/testdata/draft2020-12/minLength.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/minLength.json rename to jsonschema/testdata/draft2020-12/minLength.json diff --git a/internal/jsonschema/testdata/draft2020-12/minProperties.json b/jsonschema/testdata/draft2020-12/minProperties.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/minProperties.json rename to jsonschema/testdata/draft2020-12/minProperties.json diff --git a/internal/jsonschema/testdata/draft2020-12/minimum.json b/jsonschema/testdata/draft2020-12/minimum.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/minimum.json rename to jsonschema/testdata/draft2020-12/minimum.json diff --git a/internal/jsonschema/testdata/draft2020-12/multipleOf.json b/jsonschema/testdata/draft2020-12/multipleOf.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/multipleOf.json rename to jsonschema/testdata/draft2020-12/multipleOf.json diff --git a/internal/jsonschema/testdata/draft2020-12/not.json b/jsonschema/testdata/draft2020-12/not.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/not.json rename to jsonschema/testdata/draft2020-12/not.json diff --git a/internal/jsonschema/testdata/draft2020-12/oneOf.json b/jsonschema/testdata/draft2020-12/oneOf.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/oneOf.json rename to jsonschema/testdata/draft2020-12/oneOf.json diff --git a/internal/jsonschema/testdata/draft2020-12/pattern.json b/jsonschema/testdata/draft2020-12/pattern.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/pattern.json rename to jsonschema/testdata/draft2020-12/pattern.json diff --git a/internal/jsonschema/testdata/draft2020-12/patternProperties.json b/jsonschema/testdata/draft2020-12/patternProperties.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/patternProperties.json rename to jsonschema/testdata/draft2020-12/patternProperties.json diff --git a/internal/jsonschema/testdata/draft2020-12/prefixItems.json b/jsonschema/testdata/draft2020-12/prefixItems.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/prefixItems.json rename to jsonschema/testdata/draft2020-12/prefixItems.json diff --git a/internal/jsonschema/testdata/draft2020-12/properties.json b/jsonschema/testdata/draft2020-12/properties.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/properties.json rename to jsonschema/testdata/draft2020-12/properties.json diff --git a/internal/jsonschema/testdata/draft2020-12/propertyNames.json b/jsonschema/testdata/draft2020-12/propertyNames.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/propertyNames.json rename to jsonschema/testdata/draft2020-12/propertyNames.json diff --git a/internal/jsonschema/testdata/draft2020-12/required.json b/jsonschema/testdata/draft2020-12/required.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/required.json rename to jsonschema/testdata/draft2020-12/required.json diff --git a/internal/jsonschema/testdata/draft2020-12/type.json b/jsonschema/testdata/draft2020-12/type.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/type.json rename to jsonschema/testdata/draft2020-12/type.json diff --git a/internal/jsonschema/testdata/draft2020-12/unevaluatedItems.json b/jsonschema/testdata/draft2020-12/unevaluatedItems.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/unevaluatedItems.json rename to jsonschema/testdata/draft2020-12/unevaluatedItems.json diff --git a/internal/jsonschema/testdata/draft2020-12/unevaluatedProperties.json b/jsonschema/testdata/draft2020-12/unevaluatedProperties.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/unevaluatedProperties.json rename to jsonschema/testdata/draft2020-12/unevaluatedProperties.json diff --git a/internal/jsonschema/testdata/draft2020-12/uniqueItems.json b/jsonschema/testdata/draft2020-12/uniqueItems.json similarity index 100% rename from internal/jsonschema/testdata/draft2020-12/uniqueItems.json rename to jsonschema/testdata/draft2020-12/uniqueItems.json diff --git a/internal/jsonschema/util.go b/jsonschema/util.go similarity index 100% rename from internal/jsonschema/util.go rename to jsonschema/util.go diff --git a/internal/jsonschema/util_test.go b/jsonschema/util_test.go similarity index 100% rename from internal/jsonschema/util_test.go rename to jsonschema/util_test.go diff --git a/internal/jsonschema/validate.go b/jsonschema/validate.go similarity index 100% rename from internal/jsonschema/validate.go rename to jsonschema/validate.go diff --git a/internal/jsonschema/validate_test.go b/jsonschema/validate_test.go similarity index 100% rename from internal/jsonschema/validate_test.go rename to jsonschema/validate_test.go diff --git a/mcp/mcp_test.go b/mcp/mcp_test.go index 9c2b765..0452fac 100644 --- a/mcp/mcp_test.go +++ b/mcp/mcp_test.go @@ -16,8 +16,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - "github.com/modelcontextprotocol/go-sdk/internal/jsonschema" "github.com/modelcontextprotocol/go-sdk/internal/protocol" + "github.com/modelcontextprotocol/go-sdk/jsonschema" ) type hiParams struct { diff --git a/mcp/prompt.go b/mcp/prompt.go index 7ccf646..62d0a45 100644 --- a/mcp/prompt.go +++ b/mcp/prompt.go @@ -11,9 +11,9 @@ import ( "reflect" "slices" - "github.com/modelcontextprotocol/go-sdk/internal/jsonschema" "github.com/modelcontextprotocol/go-sdk/internal/protocol" "github.com/modelcontextprotocol/go-sdk/internal/util" + "github.com/modelcontextprotocol/go-sdk/jsonschema" ) // A PromptHandler handles a call to prompts/get. diff --git a/mcp/tool.go b/mcp/tool.go index 02748bb..e225952 100644 --- a/mcp/tool.go +++ b/mcp/tool.go @@ -9,9 +9,9 @@ import ( "encoding/json" "slices" - "github.com/modelcontextprotocol/go-sdk/internal/jsonschema" "github.com/modelcontextprotocol/go-sdk/internal/protocol" "github.com/modelcontextprotocol/go-sdk/internal/util" + "github.com/modelcontextprotocol/go-sdk/jsonschema" ) // A ToolHandler handles a call to tools/call. diff --git a/mcp/tool_test.go b/mcp/tool_test.go index ed7a44e..bb8cb48 100644 --- a/mcp/tool_test.go +++ b/mcp/tool_test.go @@ -11,7 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/modelcontextprotocol/go-sdk/mcp" - "github.com/modelcontextprotocol/go-sdk/internal/jsonschema" + "github.com/modelcontextprotocol/go-sdk/jsonschema" ) // testToolHandler is used for type inference in TestMakeTool.