mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-09 15:38:08 -05:00
fix: replace 'float' with 'number' in McpManifest (#985)
According to the json schema spec:There are two numeric types in JSON Schema: integer and number So 'float' is not with mcpcurl and mcphost Fixes #984, #797 --------- Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
This commit is contained in:
@@ -790,6 +790,15 @@ func (p *FloatParameter) Manifest() ParameterManifest {
|
||||
}
|
||||
}
|
||||
|
||||
// McpManifest returns the MCP manifest for the FloatParameter.
|
||||
// json schema only allow numeric types of 'integer' and 'number'.
|
||||
func (p *FloatParameter) McpManifest() ParameterMcpManifest {
|
||||
return ParameterMcpManifest{
|
||||
Type: "number",
|
||||
Description: p.Desc,
|
||||
}
|
||||
}
|
||||
|
||||
// NewBooleanParameter is a convenience function for initializing a BooleanParameter.
|
||||
func NewBooleanParameter(name string, desc string) *BooleanParameter {
|
||||
return &BooleanParameter{
|
||||
|
||||
@@ -1327,7 +1327,7 @@ func TestParamMcpManifest(t *testing.T) {
|
||||
{
|
||||
name: "float",
|
||||
in: tools.NewFloatParameter("foo-float", "bar"),
|
||||
want: tools.ParameterMcpManifest{Type: "float", Description: "bar"},
|
||||
want: tools.ParameterMcpManifest{Type: "number", Description: "bar"},
|
||||
},
|
||||
{
|
||||
name: "boolean",
|
||||
@@ -1385,6 +1385,7 @@ func TestMcpManifest(t *testing.T) {
|
||||
tools.NewStringParameterWithDefault("foo-string", "foo", "bar"),
|
||||
tools.NewStringParameter("foo-string2", "bar"),
|
||||
tools.NewIntParameter("foo-int2", "bar"),
|
||||
tools.NewFloatParameter("foo-float", "bar"),
|
||||
tools.NewArrayParameter("foo-array2", "bar", tools.NewStringParameter("foo-string", "bar")),
|
||||
tools.NewMapParameter("foo-map-int", "a map of ints", "integer"),
|
||||
tools.NewMapParameter("foo-map-any", "a map of any", ""),
|
||||
@@ -1395,6 +1396,7 @@ func TestMcpManifest(t *testing.T) {
|
||||
"foo-string": {Type: "string", Description: "bar"},
|
||||
"foo-string2": {Type: "string", Description: "bar"},
|
||||
"foo-int2": {Type: "integer", Description: "bar"},
|
||||
"foo-float": {Type: "number", Description: "bar"},
|
||||
"foo-array2": {
|
||||
Type: "array",
|
||||
Description: "bar",
|
||||
@@ -1411,7 +1413,7 @@ func TestMcpManifest(t *testing.T) {
|
||||
AdditionalProperties: true,
|
||||
},
|
||||
},
|
||||
Required: []string{"foo-string2", "foo-int2", "foo-array2", "foo-map-int", "foo-map-any"},
|
||||
Required: []string{"foo-string2", "foo-int2", "foo-float", "foo-array2", "foo-map-int", "foo-map-any"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user