Skip to content

Commit 86c4867

Browse files
committed
initial version of accepting args as json
1 parent f460785 commit 86c4867

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cmd/src/mcp.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"flag"
77
"fmt"
8+
"maps"
89
"strings"
910

1011
"github.com/sourcegraph/src-cli/internal/mcp"
@@ -76,6 +77,17 @@ func mcpMain(args []string) error {
7677
}
7778
mcp.DerefFlagValues(flags, vars)
7879

80+
if val, ok := vars["json"]; ok {
81+
if jsonVal, ok := val.(string); ok && len(jsonVal) > 0 {
82+
m := make(map[string]any)
83+
if err := json.Unmarshal([]byte(jsonVal), &m); err != nil {
84+
return err
85+
}
86+
maps.Copy(vars, m)
87+
}
88+
delete(vars, "json")
89+
}
90+
7991
if err := validateToolArgs(tool.InputSchema, args, vars); err != nil {
8092
return err
8193
}

0 commit comments

Comments
 (0)