refactor: Refactor retriever engine checks and expose mapping
This commit is contained in:
@@ -4,10 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
@@ -61,31 +58,6 @@ type mcpGoClient struct {
|
||||
initialized bool
|
||||
}
|
||||
|
||||
// validateURLScheme validates that authentication endpoints use HTTPS
|
||||
func validateURLScheme(serviceURL string, hasBasicAuth bool, hasTokenAuth bool) error {
|
||||
if !hasBasicAuth && !hasTokenAuth {
|
||||
// No authentication, no HTTPS requirement
|
||||
return nil
|
||||
}
|
||||
|
||||
if serviceURL == "" {
|
||||
return fmt.Errorf("URL is required")
|
||||
}
|
||||
|
||||
// Parse the URL
|
||||
parsedURL, err := url.Parse(serviceURL)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid URL: %w", err)
|
||||
}
|
||||
|
||||
// Enforce HTTPS for authenticated endpoints
|
||||
if parsedURL.Scheme != "https" {
|
||||
return fmt.Errorf("HTTPS is required for authenticated connections, got %s scheme", parsedURL.Scheme)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewMCPClient creates a new MCP client based on the transport type
|
||||
func NewMCPClient(config *ClientConfig) (MCPClient, error) {
|
||||
// Create HTTP client with timeout
|
||||
|
||||
Reference in New Issue
Block a user