Skip to content

Commit 9c4d349

Browse files
authored
go.mod: upgrade to jsonschema v0.4.2 (#732)
Visible changes: - Inference on structs populates PropertyOrder - An empty map for Schema.Properties marshals as "{}"
1 parent 27b3354 commit 9c4d349

5 files changed

Lines changed: 58 additions & 31 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.23.0
55
require (
66
github.com/golang-jwt/jwt/v5 v5.2.2
77
github.com/google/go-cmp v0.7.0
8-
github.com/google/jsonschema-go v0.3.0
8+
github.com/google/jsonschema-go v0.4.2
99
github.com/yosida95/uritemplate/v3 v3.0.2
1010
golang.org/x/oauth2 v0.30.0
1111
golang.org/x/tools v0.34.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeD
22
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
33
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
44
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
5-
github.com/google/jsonschema-go v0.3.0 h1:6AH2TxVNtk3IlvkkhjrtbUc4S8AvO0Xii0DxIygDg+Q=
6-
github.com/google/jsonschema-go v0.3.0/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
5+
github.com/google/jsonschema-go v0.4.2 h1:tmrUohrwoLZZS/P3x7ex0WAVknEkBZM46iALbcqoRA8=
6+
github.com/google/jsonschema-go v0.4.2/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
77
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
88
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
99
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=

mcp/server_test.go

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -812,10 +812,34 @@ func TestToolForSchemas(t *testing.T) {
812812

813813
var (
814814
falseSchema = &schema{Not: &schema{}}
815-
inSchema = &schema{Type: "object", AdditionalProperties: falseSchema, Properties: map[string]*schema{"p": {Type: "integer"}}}
816-
inSchema2 = &schema{Type: "object", AdditionalProperties: falseSchema, Properties: map[string]*schema{"p": {Type: "string"}}}
817-
outSchema = &schema{Type: "object", AdditionalProperties: falseSchema, Properties: map[string]*schema{"b": {Type: "boolean"}}}
818-
outSchema2 = &schema{Type: "object", AdditionalProperties: falseSchema, Properties: map[string]*schema{"b": {Type: "integer"}}}
815+
inSchema = &schema{
816+
Type: "object",
817+
AdditionalProperties: falseSchema,
818+
Properties: map[string]*schema{"p": {Type: "integer"}},
819+
PropertyOrder: []string{"p"},
820+
}
821+
inSchema2 = &schema{
822+
Type: "object",
823+
AdditionalProperties: falseSchema,
824+
Properties: map[string]*schema{"p": {Type: "string"}},
825+
}
826+
inSchema3 = &schema{
827+
Type: "object",
828+
AdditionalProperties: falseSchema,
829+
Properties: map[string]*schema{}, // empty map is preserved
830+
}
831+
outSchema = &schema{
832+
Type: "object",
833+
AdditionalProperties: falseSchema,
834+
Properties: map[string]*schema{"b": {Type: "boolean"}},
835+
PropertyOrder: []string{"b"},
836+
}
837+
outSchema2 = &schema{
838+
Type: "object",
839+
AdditionalProperties: falseSchema,
840+
Properties: map[string]*schema{"b": {Type: "integer"}},
841+
PropertyOrder: []string{"b"},
842+
}
819843
)
820844

821845
// Infer both schemas.
@@ -829,6 +853,8 @@ func TestToolForSchemas(t *testing.T) {
829853
testToolForSchema[in, any](t, &Tool{}, `{"p":"x"}`, 0, inSchema, nil, `want "integer"`)
830854
// Tool sets input schema: that is what's used.
831855
testToolForSchema[in, any](t, &Tool{InputSchema: inSchema2}, `{"p":3}`, 0, inSchema2, nil, `want "string"`)
856+
// Tool sets input schema, empty properties map.
857+
testToolForSchema[in, any](t, &Tool{InputSchema: inSchema3}, `{}`, 0, inSchema3, nil, "")
832858
// Tool sets output schema: that is what's used, and validation happens.
833859
testToolForSchema[in, any](t, &Tool{OutputSchema: outSchema2}, `{"p":3}`, out{true},
834860
inSchema, outSchema2, `want "integer"`)
@@ -850,6 +876,7 @@ func TestToolForSchemas(t *testing.T) {
850876
"AsOf": {Type: "string"},
851877
"Source": {Type: "string"},
852878
},
879+
PropertyOrder: []string{"Summary", "AsOf", "Source"},
853880
},
854881
"")
855882
}

mcp/testdata/conformance/server/spec-sep-973-additional-metadata.txtar

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ infoWithIcon
9292
"description": "return resourceLink content with Icon",
9393
"inputSchema": {
9494
"type": "object",
95-
"required": [
96-
"In"
97-
],
9895
"properties": {
9996
"In": {
10097
"type": "string",
10198
"description": "the input"
10299
}
103100
},
101+
"required": [
102+
"In"
103+
],
104104
"additionalProperties": false
105105
},
106106
"name": "contentTool",
@@ -110,14 +110,14 @@ infoWithIcon
110110
"description": "say hi",
111111
"inputSchema": {
112112
"type": "object",
113-
"required": [
114-
"Name"
115-
],
116113
"properties": {
117114
"Name": {
118115
"type": "string"
119116
}
120117
},
118+
"required": [
119+
"Name"
120+
],
121121
"additionalProperties": false
122122
},
123123
"name": "greetWithIcon",

mcp/testdata/conformance/server/tools.txtar

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ inc
6969
"description": "say hi",
7070
"inputSchema": {
7171
"type": "object",
72-
"required": [
73-
"Name"
74-
],
7572
"properties": {
7673
"Name": {
7774
"type": "string"
7875
}
7976
},
77+
"required": [
78+
"Name"
79+
],
8080
"additionalProperties": false
8181
},
8282
"name": "greet"
@@ -95,70 +95,70 @@ inc
9595
"name": "inc",
9696
"outputSchema": {
9797
"type": "object",
98-
"required": [
99-
"y"
100-
],
10198
"properties": {
10299
"y": {
103100
"type": "integer"
104101
}
105102
},
103+
"required": [
104+
"y"
105+
],
106106
"additionalProperties": false
107107
}
108108
},
109109
{
110110
"inputSchema": {
111111
"type": "object",
112-
"required": [
113-
"In"
114-
],
115112
"properties": {
116113
"In": {
117114
"type": "string",
118115
"description": "the input"
119116
}
120117
},
118+
"required": [
119+
"In"
120+
],
121121
"additionalProperties": false
122122
},
123123
"name": "structured",
124124
"outputSchema": {
125125
"type": "object",
126-
"required": [
127-
"Out"
128-
],
129126
"properties": {
130127
"Out": {
131128
"type": "string",
132129
"description": "the output"
133130
}
134131
},
132+
"required": [
133+
"Out"
134+
],
135135
"additionalProperties": false
136136
}
137137
},
138138
{
139139
"inputSchema": {
140140
"type": "object",
141-
"required": [
142-
"Now"
143-
],
144141
"properties": {
145142
"Now": {
146143
"type": "string"
147144
}
148145
},
146+
"required": [
147+
"Now"
148+
],
149149
"additionalProperties": false
150150
},
151151
"name": "tomorrow",
152152
"outputSchema": {
153153
"type": "object",
154-
"required": [
155-
"Tomorrow"
156-
],
157154
"properties": {
158155
"Tomorrow": {
159156
"type": "string"
160157
}
161158
},
159+
"required": [
160+
"Tomorrow"
161+
],
162162
"additionalProperties": false
163163
}
164164
}

0 commit comments

Comments
 (0)