Skip to content

feat: add support for insecure config loading via new CLI flag #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package main

import (
"crypto/tls"
"errors"
"net/http"
"time"

"github.com/TBXark/confstore"
Expand Down Expand Up @@ -129,9 +131,21 @@ type FullConfig struct {
McpServers map[string]*MCPClientConfigV2 `json:"mcpServers"`
}

func load(path string) (*Config, error) {
func load(path string, insecure bool) (*Config, error) {
httpClient := http.DefaultClient
if insecure {
httpClient = &http.Client{
Transport: &http.Transport{
// Disable TLS verification for insecure connections
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
}
Comment on lines +136 to +143
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Instead of creating a new http.Transport from scratch, consider cloning http.DefaultTransport to preserve its default settings (e.g., timeouts, keep-alives).

	if insecure {
		transport := http.DefaultTransport.(*http.Transport).Clone()
		transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
		httpClient = &http.Client{Transport: transport}
	}


conf, err := confstore.Load[FullConfig](path)
conf, err := confstore.Load[FullConfig](
path,
confstore.WithHTTPClientOption(httpClient),
)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.23.0
toolchain go1.23.7

require (
github.com/TBXark/confstore v0.0.4
github.com/TBXark/confstore v0.0.5
github.com/TBXark/optional-go v0.0.1
github.com/mark3labs/mcp-go v0.32.0
golang.org/x/sync v0.15.0
Expand Down
14 changes: 2 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/TBXark/confstore v0.0.4 h1:4HCbWbXz1qKtxjxcmEGU1W0kyBJz6aXZtca7CPx7Ojk=
github.com/TBXark/confstore v0.0.4/go.mod h1:TOxM19Snt9wT02PJzyz66sgq7sWhr4AFzPEZIKvVnTE=
github.com/TBXark/confstore v0.0.5 h1:LBbqBS9GdQuqzRi1azLJMdlTJjyEKrGZ9VOrteZUZfQ=
github.com/TBXark/confstore v0.0.5/go.mod h1:TOxM19Snt9wT02PJzyz66sgq7sWhr4AFzPEZIKvVnTE=
github.com/TBXark/optional-go v0.0.1 h1:ZIeoYfA7UWcpx+Otxdc0f0tvfSDkJuJVYmjnLfr2P8I=
github.com/TBXark/optional-go v0.0.1/go.mod h1:skpoGkocQNq/IRct1T2rgwSrXEy1nUY+Sz28r68t4yE=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand All @@ -14,12 +14,6 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mark3labs/mcp-go v0.24.1 h1:YV+5X/+W4oBdERLWgiA1uR7AIvenlKJaa5V4hqufI7E=
github.com/mark3labs/mcp-go v0.24.1/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4=
github.com/mark3labs/mcp-go v0.28.0 h1:7yl4y5D1KYU2f/9Uxp7xfLIggfunHoESCRbrjcytcLM=
github.com/mark3labs/mcp-go v0.28.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4=
github.com/mark3labs/mcp-go v0.30.0 h1:Taz7fiefkxY/l8jz1nA90V+WdM2eoMtlvwfWforVYbo=
github.com/mark3labs/mcp-go v0.30.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4=
github.com/mark3labs/mcp-go v0.32.0 h1:fgwmbfL2gbd67obg57OfV2Dnrhs1HtSdlY/i5fn7MU8=
github.com/mark3labs/mcp-go v0.32.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -32,10 +26,6 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var BuildVersion = "dev"
func main() {
conf := flag.String("config", "config.json", "path to config file or a http(s) url")
version := flag.Bool("version", false, "print version and exit")
insecure := flag.Bool("insecure", false, "allow insecure HTTPS connections by skipping TLS certificate verification")
help := flag.Bool("help", false, "print help and exit")
flag.Parse()
if *help {
Expand All @@ -21,7 +22,7 @@ func main() {
fmt.Println(BuildVersion)
return
}
config, err := load(*conf)
config, err := load(*conf, *insecure)
if err != nil {
log.Fatalf("Failed to load config: %v", err)
}
Expand Down