Skip to content

Commit 3997770

Browse files
committed
use more explict address bind
1 parent 49287dd commit 3997770

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/cmd/mcp.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ var mcpCmd = &cobra.Command{
3232
cobra.CheckErr(err)
3333
var server *mcp_golang.Server
3434
if mode == "http" {
35+
host, err := cmd.Flags().GetString("host")
36+
cobra.CheckErr(err)
3537
port, err := cmd.Flags().GetString("port")
3638
cobra.CheckErr(err)
3739
transport := http.NewHTTPTransport("/mcp")
38-
transport.WithAddr(fmt.Sprintf(":%s", port))
40+
transport.WithAddr(fmt.Sprintf("%s:%s", host, port))
3941
server = mcp_golang.NewServer(transport)
4042
} else {
4143
server = mcp_golang.NewServer(stdio.NewStdioServerTransport())
@@ -158,5 +160,6 @@ func init() {
158160
betaCmd.AddCommand(mcpCmd)
159161

160162
mcpCmd.Flags().StringP("mode", "m", "stdio", "Mode to run in. Can be one of [\"stdio\", \"http\"]")
163+
mcpCmd.Flags().String("host", "127.0.0.1", "Host address to bind to")
161164
mcpCmd.Flags().StringP("port", "p", "8000", "Port to use when running in 'http' mode")
162165
}

0 commit comments

Comments
 (0)