Documentation
¶
Overview ¶
Package mcp manages Model Context Protocol server configuration and calls.
Package mcp implements Codog's Model Context Protocol client helpers.
Index ¶
- func NormalizeNameForTooling(name string) string
- func ServerConfigHash(server config.MCPServerConfig) string
- func ServerSignature(server config.MCPServerConfig) string
- func ToolName(serverName, toolName string) string
- func ToolPrefix(serverName string) string
- func URLServerSignature(rawURL string) string
- func UnwrapCCRProxyURL(rawURL string) string
- type AuthStatusResult
- type InitializeResult
- type LifecycleError
- type LifecycleStatus
- type PromptGetResult
- type PromptListResult
- type ResourceListResult
- type ResourceReadResult
- type ResourceTemplateListResult
- type ServerDescriptor
- type ServerDetails
- type ServerStatus
- func Inspect(ctx context.Context, name string, server config.MCPServerConfig) ServerStatus
- func InspectAll(ctx context.Context, servers map[string]config.MCPServerConfig) []ServerStatus
- func Preflight(ctx context.Context, name string, server config.MCPServerConfig) ServerStatus
- func PreflightAll(ctx context.Context, servers map[string]config.MCPServerConfig) []ServerStatus
- type ServerTransport
- type StartupFailure
- type StartupReport
- type ToolCallResult
- type ToolInfo
- type ToolListResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeNameForTooling ¶
NormalizeNameForTooling converts an MCP server or member name into the form used in Codog tool names.
func ServerConfigHash ¶
func ServerConfigHash(server config.MCPServerConfig) string
ServerConfigHash returns a stable hash for an MCP server configuration.
func ServerSignature ¶
func ServerSignature(server config.MCPServerConfig) string
ServerSignature returns a redacted, stable signature for a configured MCP server.
func ToolPrefix ¶
ToolPrefix returns the Codog tool-name prefix for one MCP server.
func URLServerSignature ¶
URLServerSignature returns the stable MCP server signature for a URL.
func UnwrapCCRProxyURL ¶
UnwrapCCRProxyURL returns the upstream target URL embedded in a Claude Code remote proxy URL when one is present.
Types ¶
type AuthStatusResult ¶
type AuthStatusResult struct {
Server string `json:"server"`
Status string `json:"status"`
Lifecycle LifecycleStatus `json:"lifecycle"`
ServerInfo json.RawMessage `json:"server_info,omitempty"`
Capabilities json.RawMessage `json:"capabilities,omitempty"`
ToolCount int `json:"tool_count"`
ResourceCount int `json:"resource_count"`
ResourceError string `json:"resource_error,omitempty"`
Error string `json:"error,omitempty"`
}
AuthStatusResult summarizes authentication and discovery health for an MCP server.
func InspectAuth ¶
func InspectAuth(ctx context.Context, serverName string, server config.MCPServerConfig) AuthStatusResult
InspectAuth checks initialize, tool discovery, and resource discovery health for one MCP server.
type InitializeResult ¶
type InitializeResult struct {
Server string `json:"server"`
Status string `json:"status"`
Lifecycle LifecycleStatus `json:"lifecycle"`
ProtocolVersion string `json:"protocol_version,omitempty"`
Capabilities json.RawMessage `json:"capabilities,omitempty"`
ServerInfo json.RawMessage `json:"server_info,omitempty"`
Error string `json:"error,omitempty"`
}
InitializeResult records the outcome of an MCP initialize handshake.
func Initialize ¶
func Initialize(ctx context.Context, serverName string, server config.MCPServerConfig) InitializeResult
Initialize performs the MCP initialize handshake for one configured server.
type LifecycleError ¶
type LifecycleError struct {
Phase string `json:"phase"`
Message string `json:"message"`
Context map[string]string `json:"context,omitempty"`
Recoverable bool `json:"recoverable"`
}
LifecycleError describes a structured MCP lifecycle failure.
type LifecycleStatus ¶
type LifecycleStatus struct {
Phase string `json:"phase"`
LastSuccessfulPhase string `json:"last_successful_phase,omitempty"`
Error *LifecycleError `json:"error,omitempty"`
}
LifecycleStatus reports the current MCP lifecycle phase and the last recoverable or fatal error surfaced by that lifecycle.
type PromptGetResult ¶
type PromptGetResult struct {
Server string `json:"server"`
Prompt string `json:"prompt"`
Lifecycle LifecycleStatus `json:"lifecycle"`
Result json.RawMessage `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
PromptGetResult records the result of rendering one MCP prompt.
func GetPrompt ¶
func GetPrompt(ctx context.Context, serverName string, server config.MCPServerConfig, promptName string, arguments json.RawMessage) PromptGetResult
GetPrompt renders one MCP prompt after initializing the server connection.
type PromptListResult ¶
type PromptListResult struct {
Server string `json:"server"`
Lifecycle LifecycleStatus `json:"lifecycle"`
Prompts json.RawMessage `json:"prompts,omitempty"`
Error string `json:"error,omitempty"`
}
PromptListResult records prompts discovered from one MCP server.
func ListPrompts ¶
func ListPrompts(ctx context.Context, serverName string, server config.MCPServerConfig) PromptListResult
ListPrompts discovers prompts exposed by one MCP server.
type ResourceListResult ¶
type ResourceListResult struct {
Server string `json:"server"`
Lifecycle LifecycleStatus `json:"lifecycle"`
Resources json.RawMessage `json:"resources,omitempty"`
Error string `json:"error,omitempty"`
}
ResourceListResult records resources discovered from one MCP server.
func ListResources ¶
func ListResources(ctx context.Context, serverName string, server config.MCPServerConfig) ResourceListResult
ListResources discovers the resources exposed by one MCP server.
type ResourceReadResult ¶
type ResourceReadResult struct {
Server string `json:"server"`
URI string `json:"uri"`
Lifecycle LifecycleStatus `json:"lifecycle"`
Result json.RawMessage `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
ResourceReadResult records the result of reading one MCP resource.
func ReadResource ¶
func ReadResource(ctx context.Context, serverName string, server config.MCPServerConfig, uri string) ResourceReadResult
ReadResource reads one MCP resource by URI after initializing the server connection.
type ResourceTemplateListResult ¶
type ResourceTemplateListResult struct {
Server string `json:"server"`
Lifecycle LifecycleStatus `json:"lifecycle"`
Templates json.RawMessage `json:"templates,omitempty"`
Error string `json:"error,omitempty"`
}
ResourceTemplateListResult records resource templates discovered from one MCP server.
func ListResourceTemplates ¶
func ListResourceTemplates(ctx context.Context, serverName string, server config.MCPServerConfig) ResourceTemplateListResult
ListResourceTemplates discovers resource templates exposed by one MCP server.
type ServerDescriptor ¶
type ServerDescriptor struct {
Name string `json:"name"`
Valid bool `json:"valid"`
Required bool `json:"required"`
Transport ServerTransport `json:"transport"`
Summary string `json:"summary"`
Details ServerDetails `json:"details"`
}
ServerDescriptor is a redacted, user-facing description of one MCP server.
func DescribeServer ¶
func DescribeServer(name string, server config.MCPServerConfig) ServerDescriptor
DescribeServer returns a redacted descriptor for one configured MCP server.
type ServerDetails ¶
type ServerDetails struct {
Command string `json:"command,omitempty"`
URL string `json:"url,omitempty"`
ArgsSummary []string `json:"args_summary,omitempty"`
ArgsCount int `json:"args_count"`
ToolCallTimeoutMS int `json:"tool_call_timeout_ms,omitempty"`
EnvKeys []string `json:"env_keys,omitempty"`
HeaderKeys []string `json:"header_keys,omitempty"`
HeadersHelperConfigured bool `json:"headers_helper_configured,omitempty"`
OAuthConfigured bool `json:"oauth_configured,omitempty"`
OAuthClientIDConfigured bool `json:"oauth_client_id_configured,omitempty"`
OAuthCallbackPort int `json:"oauth_callback_port,omitempty"`
OAuthAuthServerMetadataURL string `json:"oauth_auth_server_metadata_url,omitempty"`
OAuthXAA *bool `json:"oauth_xaa,omitempty"`
}
ServerDetails contains redacted transport-specific configuration details.
type ServerStatus ¶
type ServerStatus struct {
Name string `json:"name"`
Status string `json:"status"`
Required bool `json:"required"`
Lifecycle LifecycleStatus `json:"lifecycle"`
Command string `json:"command,omitempty"`
URL string `json:"url,omitempty"`
Signature string `json:"signature,omitempty"`
ConfigHash string `json:"config_hash,omitempty"`
ResolvedPath string `json:"resolved_path,omitempty"`
ProtocolVersion string `json:"protocol_version,omitempty"`
ServerInfo json.RawMessage `json:"server_info,omitempty"`
ToolCount int `json:"tool_count,omitempty"`
Tools []string `json:"tools,omitempty"`
Error string `json:"error,omitempty"`
}
ServerStatus reports the local inspection status for one configured MCP server.
func Inspect ¶
func Inspect(ctx context.Context, name string, server config.MCPServerConfig) ServerStatus
Inspect preflights one MCP server and discovers its tool list when initialization succeeds.
func InspectAll ¶
func InspectAll(ctx context.Context, servers map[string]config.MCPServerConfig) []ServerStatus
InspectAll inspects all configured MCP servers in deterministic name order.
func Preflight ¶
func Preflight(ctx context.Context, name string, server config.MCPServerConfig) ServerStatus
Preflight validates one MCP server configuration and performs its initialize handshake.
func PreflightAll ¶
func PreflightAll(ctx context.Context, servers map[string]config.MCPServerConfig) []ServerStatus
PreflightAll preflights all configured MCP servers in deterministic name order.
type ServerTransport ¶
ServerTransport identifies the MCP transport configured for a server.
type StartupFailure ¶
type StartupFailure struct {
Name string `json:"name"`
Status string `json:"status"`
Required bool `json:"required"`
Phase string `json:"phase,omitempty"`
Recoverable bool `json:"recoverable"`
Error string `json:"error,omitempty"`
}
StartupFailure records the redacted failure surface for one MCP server in a startup report.
type StartupReport ¶
type StartupReport struct {
Status string `json:"status"`
Total int `json:"total"`
OKCount int `json:"ok_count"`
ErrorCount int `json:"error_count"`
RequiredCount int `json:"required_count"`
RequiredOKCount int `json:"required_ok_count"`
RequiredFailedCount int `json:"required_failed_count"`
OptionalCount int `json:"optional_count"`
OptionalOKCount int `json:"optional_ok_count"`
OptionalFailedCount int `json:"optional_failed_count"`
FailedRequired []StartupFailure `json:"failed_required_servers,omitempty"`
FailedOptional []StartupFailure `json:"failed_optional_servers,omitempty"`
}
StartupReport summarizes whether the configured MCP set is usable at session startup time. Required server failures are fatal; optional failures degrade startup but keep the rest of the MCP inventory usable.
func BuildStartupReport ¶
func BuildStartupReport(statuses []ServerStatus) StartupReport
BuildStartupReport aggregates server statuses into a startup gate result.
type ToolCallResult ¶
type ToolCallResult struct {
Server string `json:"server"`
Tool string `json:"tool"`
Lifecycle LifecycleStatus `json:"lifecycle"`
Result json.RawMessage `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
ToolCallResult records the result of invoking one MCP tool.
func CallTool ¶
func CallTool(ctx context.Context, serverName string, server config.MCPServerConfig, toolName string, arguments json.RawMessage) ToolCallResult
CallTool invokes one MCP tool after initializing the server connection.
type ToolInfo ¶
type ToolInfo struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
InputSchema map[string]any `json:"input_schema,omitempty"`
}
ToolInfo describes one MCP tool exposed by a server.
type ToolListResult ¶
type ToolListResult struct {
Server string `json:"server"`
Tools []ToolInfo `json:"tools,omitempty"`
Error string `json:"error,omitempty"`
}
ToolListResult records the tools discovered from one MCP server.
func ListTools ¶
func ListTools(ctx context.Context, serverName string, server config.MCPServerConfig) ToolListResult
ListTools discovers the tools exposed by one MCP server.