Skip to content

Commit f8f5033

Browse files
committed
Add VL_INSTANCE_TLS_SKIP_VERIFY option to skip TLS certificate verification
1 parent 3ee92d4 commit f8f5033

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ MCP Server for VictoriaLogs is configured via environment variables:
134134
| `VL_INSTANCE_ENTRYPOINT` | URL to VictoriaLogs instance | Yes | - | - |
135135
| `VL_INSTANCE_BEARER_TOKEN` | Authentication token for VictoriaLogs API | No | - | - |
136136
| `VL_INSTANCE_HEADERS` | Custom HTTP headers to send with requests (comma-separated key=value pairs) | No | - | - |
137+
| `VL_INSTANCE_TLS_SKIP_VERIFY` | Skip TLS certificate verification for VictoriaLogs HTTP client. **Warning: use only in development/testing environments, never in production.** | No | `false` | `true`, `false` |
137138
| `MCP_PASSTHROUGH_HEADERS` | HTTP header names to forward from incoming MCP requests to VictoriaLogs (comma-separated list). Overrides `VL_INSTANCE_HEADERS` on collision. Only applies in `sse`/`http` modes. | No | - | - |
138139
| `VL_DEFAULT_TENANT_ID` | Default tenant ID used when tenant is not specified in requests (format: `AccountID:ProjectID` or `AccountID`) | No | `0:0` | - |
139140
| `MCP_SERVER_MODE` | Server operation mode. See [Modes](#modes) for details. | No | `stdio` | `stdio`, `sse`, `http` |

cmd/mcp-victorialogs/config/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ type Config struct {
2323

2424
entryPointURL *url.URL
2525

26+
tlsSkipVerify bool
27+
2628
// Logging configuration
2729
logFormat string
2830
logLevel string
@@ -98,6 +100,8 @@ func InitConfig() (*Config, error) {
98100
return nil, fmt.Errorf("MCP_LOG_LEVEL must be 'debug', 'info', 'warn' or 'error'")
99101
}
100102

103+
tlsSkipVerify := strings.ToLower(strings.TrimSpace(os.Getenv("VL_INSTANCE_TLS_SKIP_VERIFY"))) == "true"
104+
101105
result := &Config{
102106
serverMode: strings.ToLower(os.Getenv("MCP_SERVER_MODE")),
103107
listenAddr: os.Getenv("MCP_LISTEN_ADDR"),
@@ -110,6 +114,7 @@ func InitConfig() (*Config, error) {
110114
logFormat: logFormat,
111115
logLevel: logLevel,
112116
defaultTenantID: logstorage.TenantID{AccountID: 0, ProjectID: 0},
117+
tlsSkipVerify: tlsSkipVerify,
113118
}
114119
// Left for backward compatibility
115120
if result.listenAddr == "" {
@@ -199,6 +204,10 @@ func (c *Config) LogLevel() string {
199204
return c.logLevel
200205
}
201206

207+
func (c *Config) TLSSkipVerify() bool {
208+
return c.tlsSkipVerify
209+
}
210+
202211
func (c *Config) DefaultTenantID() logstorage.TenantID {
203212
return c.defaultTenantID
204213
}

cmd/mcp-victorialogs/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"context"
5+
"crypto/tls"
56
"errors"
67
"fmt"
78
"log"
@@ -50,6 +51,13 @@ func main() {
5051
return
5152
}
5253

54+
if c.TLSSkipVerify() {
55+
slog.Warn("TLS certificate verification is disabled (VL_INSTANCE_TLS_SKIP_VERIFY=true). Do not use in production.")
56+
transport := http.DefaultTransport.(*http.Transport).Clone()
57+
transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} //nolint:gosec
58+
http.DefaultTransport = transport
59+
}
60+
5361
if !c.IsStdio() {
5462
slog.Info("Starting mcp-victorialogs",
5563
"version", version,

0 commit comments

Comments
 (0)