mirror of
https://github.com/chaitin/SafeLine.git
synced 2025-11-25 03:15:15 +08:00
fix: int64
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -6,4 +6,5 @@
|
||||
build.sh
|
||||
compose.yml
|
||||
__pycache__
|
||||
.cursor
|
||||
.cursor
|
||||
.vscode
|
||||
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/chaitin/SafeLine/mcp_server/internal/api"
|
||||
@@ -11,7 +12,10 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := config.Load("config.yaml"); err != nil {
|
||||
configPath := flag.String("config", "config.yaml", "path to config file")
|
||||
flag.Parse()
|
||||
|
||||
if err := config.Load(*configPath); err != nil {
|
||||
panic(fmt.Errorf("failed to load config: %v", err))
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,6 @@ func RegisterTool[T any, R any](s *MCPServer, tool Tool[T, R]) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
t := mcp.NewTool(tool.Name(),
|
||||
opts...,
|
||||
)
|
||||
|
||||
@@ -44,7 +44,7 @@ func SchemaToOptions(schema any) ([]mcp.ToolOption, error) {
|
||||
}
|
||||
|
||||
switch field.Type.Kind() {
|
||||
case reflect.Int:
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Float32, reflect.Float64:
|
||||
if defaultTag != "" {
|
||||
if defaultValue, err := strconv.Atoi(defaultTag); err == nil {
|
||||
opts = append(opts, mcp.DefaultNumber(float64(defaultValue)))
|
||||
@@ -112,7 +112,7 @@ func SchemaToOptions(schema any) ([]mcp.ToolOption, error) {
|
||||
var items map[string]any
|
||||
|
||||
switch elemType.Kind() {
|
||||
case reflect.Int:
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Float32, reflect.Float64:
|
||||
items = map[string]any{
|
||||
"type": "number",
|
||||
}
|
||||
|
||||
@@ -22,6 +22,24 @@ func TestSchemaToOptions(t *testing.T) {
|
||||
mcp.WithNumber("a", mcp.Required(), mcp.Description("number a")),
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "test number int64",
|
||||
args: struct {
|
||||
A int64 `json:"a" desc:"number a" required:"true"`
|
||||
}{},
|
||||
want: mcp.NewTool("test number int64",
|
||||
mcp.WithNumber("a", mcp.Required(), mcp.Description("number a")),
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "test number float64",
|
||||
args: struct {
|
||||
A float64 `json:"a" desc:"number a" required:"true"`
|
||||
}{},
|
||||
want: mcp.NewTool("test number float64",
|
||||
mcp.WithNumber("a", mcp.Required(), mcp.Description("number a")),
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "test number default",
|
||||
args: struct {
|
||||
|
||||
Reference in New Issue
Block a user