Documentation
¶
Index ¶
Constants ¶
const ( TransportProtocolStreamableHttp = "streamablehttp" TransportProtocolStdio = "stdio" KindMCPServerConfig = "MCPServerConfig" )
const (
DefaultBasePath = "/mcp"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthConfig ¶
type AuthConfig struct {
// List of authorization server URLs for token validation.
AuthorizationServers []string `json:"authorizationServers,omitempty" jsonschema:"optional"`
// URI for the JSON Web Key Set (JWKS) used for token verification.
JWKSURI string `json:"jwksUri,omitempty" jsonschema:"optional"`
}
AuthConfig defines OAuth 2.0 authorization settings.
type ClientTLSConfig ¶ added in v0.2.3
type ClientTLSConfig struct {
// Paths to CA certificate files (PEM format) to trust for outbound HTTPS requests.
// These are added to the system's default certificate pool.
CACertFiles []string `json:"caCertFiles,omitempty" jsonschema:"optional"`
// Path to a directory containing CA certificate files (PEM format).
// All .pem and .crt files in this directory will be loaded.
CACertDir string `json:"caCertDir,omitempty" jsonschema:"optional"`
// If true, skip TLS certificate verification for outbound requests.
// WARNING: This is insecure and should only be used for testing.
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty" jsonschema:"optional"`
}
ClientTLSConfig defines TLS settings for outbound HTTP requests. Use this to configure custom CA certificates for connecting to internal services that use certificates signed by a corporate or private CA.
func (*ClientTLSConfig) BuildTLSConfig ¶ added in v0.2.3
func (c *ClientTLSConfig) BuildTLSConfig() (*tls.Config, error)
BuildTLSConfig creates a tls.Config from the ClientTLSConfig settings. It loads CA certificates from the specified files and/or directory.
type MCPServerConfig ¶
type MCPServerConfig struct {
// Runtime configuration for the MCP server.
Runtime *ServerRuntime `json:"runtime,omitempty" jsonschema:"optional"`
}
MCPServerConfig defines the runtime configuration of an MCP server.
func (*MCPServerConfig) UnmarshalJSON ¶
func (s *MCPServerConfig) UnmarshalJSON(data []byte) error
func (*MCPServerConfig) Validate ¶
func (s *MCPServerConfig) Validate() error
type MCPServerConfigFile ¶
type MCPServerConfigFile struct {
// Kind identifies the type of GenMCP config file.
Kind string `json:"kind" jsonschema:"required"`
// Version of the GenMCP config file format.
SchemaVersion string `json:"schemaVersion" jsonschema:"required"`
// MCP server definition.
MCPServerConfig `json:",inline"`
}
MCPServerConfigFile is the root structure of a Server Config File (mcpserver.yaml).
func ParseMCPFile ¶
func ParseMCPFile(path string) (*MCPServerConfigFile, error)
ParseMCPFile parses a Server Config File (mcpserver.yaml)
func (*MCPServerConfigFile) UnmarshalJSON ¶
func (m *MCPServerConfigFile) UnmarshalJSON(data []byte) error
func (*MCPServerConfigFile) Validate ¶
func (m *MCPServerConfigFile) Validate() error
type RuntimeOverrider ¶
type RuntimeOverrider interface {
ApplyOverrides(runtime *ServerRuntime) error
}
func NewEnvRuntimeOverrider ¶
func NewEnvRuntimeOverrider() RuntimeOverrider
type ServerRuntime ¶
type ServerRuntime struct {
// Transport protocol to use (streamablehttp or stdio).
TransportProtocol string `json:"transportProtocol" jsonschema:"required"`
// Configuration for streamable HTTP transport protocol.
StreamableHTTPConfig *StreamableHTTPConfig `json:"streamableHttpConfig,omitempty" jsonschema:"optional"`
// Configuration for stdio transport protocol.
StdioConfig *StdioConfig `json:"stdioConfig,omitempty" jsonschema:"optional"`
// Configuration for the server logging
LoggingConfig *logging.LoggingConfig `json:"loggingConfig" jsonschema:"optional"`
// TLS configuration for outbound HTTP requests (e.g., custom CA certificates).
// Use this when connecting to internal services that use certificates signed by a corporate CA.
ClientTLSConfig *ClientTLSConfig `json:"clientTlsConfig,omitempty" jsonschema:"optional"`
// contains filtered or unexported fields
}
ServerRuntime defines transport protocol and associated configuration.
func (*ServerRuntime) GetBaseLogger ¶
func (sr *ServerRuntime) GetBaseLogger() *zap.Logger
GetBaseLogger returns the base logger for the server. If LoggingConfig is nil, it defaults to a console logger with info level to ensure startup messages are visible as documented in tutorials. If LoggingConfig is provided but fails to build, it falls back to a console logger. If the runtime is nil, it returns a no-op logger.
func (*ServerRuntime) GetHTTPClient ¶ added in v0.2.3
func (sr *ServerRuntime) GetHTTPClient() (*http.Client, error)
GetHTTPClient returns a configured HTTP client based on the ClientTLSConfig. The client is created once and cached for subsequent calls. If ClientTLSConfig is nil, it returns a default HTTP client with reasonable timeouts.
func (*ServerRuntime) Validate ¶
func (r *ServerRuntime) Validate() error
type StdioConfig ¶
type StdioConfig struct{}
StdioConfig defines configuration for stdio transport protocol.
type StreamableHTTPConfig ¶
type StreamableHTTPConfig struct {
// Port number to listen on.
Port int `json:"port" jsonschema:"required"`
// Base path for the MCP server (default: /mcp).
BasePath string `json:"basePath,omitempty" jsonschema:"optional"`
// Indicates whether the server is stateless (default: true when unset).
Stateless bool `json:"stateless,omitempty" jsonschema:"optional"`
// OAuth 2.0 configuration for protected resources.
Auth *AuthConfig `json:"auth,omitempty" jsonschema:"optional"`
// TLS configuration for HTTPS.
TLS *TLSConfig `json:"tls,omitempty" jsonschema:"optional"`
}
StreamableHTTPConfig defines configuration for the HTTP-based runtime.
func (*StreamableHTTPConfig) UnmarshalJSON ¶
func (s *StreamableHTTPConfig) UnmarshalJSON(data []byte) error
type TLSConfig ¶
type TLSConfig struct {
// Absolute path to the server's public certificate.
CertFile string `json:"certFile,omitempty" jsonschema:"optional"`
// Absolute path to the server's private key.
KeyFile string `json:"keyFile,omitempty" jsonschema:"optional"`
}
TLSConfig defines paths to TLS certificate and private key files.