Documentation
¶
Overview ¶
Package mcp provides Model Context Protocol server implementation for netcheck.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunServer ¶
func RunServer(cfg ServerConfig) error
RunServer starts the MCP server with all tools auto-registered from the checker registry.
Types ¶
type GatewayInfo ¶
type GatewayInfo struct {
IP string `json:"ip"`
Interfaces []NetIf `json:"interfaces,omitempty"`
ExternalIP string `json:"external_ip,omitempty"`
Routes []string `json:"routes,omitempty"`
}
GatewayInfo describes the discovered network gateway.
type Issue ¶
type Issue struct {
Severity string `json:"severity"`
Description string `json:"description"`
Details string `json:"details"`
}
Issue represents a security finding.
func IssuesFromInfo ¶
func IssuesFromInfo(issues []common.SecurityIssue) []Issue
IssuesFromInfo converts common.SecurityIssues to MCP Issues.
type NetIf ¶
type NetIf struct {
Name string `json:"name"`
Addrs []string `json:"addrs"`
MAC string `json:"mac,omitempty"`
Flags string `json:"flags,omitempty"`
}
NetIf describes a local network interface.
type RouterState ¶
type RouterState struct {
IP string `json:"ip"`
Vendor string `json:"vendor,omitempty"`
Model string `json:"model,omitempty"`
WebInterface bool `json:"web_interface"`
DefaultCreds bool `json:"default_creds"`
UPnPEnabled bool `json:"upnp_enabled"`
NATpmpEnabled bool `json:"natpmp_enabled"`
IPv6Enabled bool `json:"ipv6_enabled"`
MDNSEnabled bool `json:"mdns_enabled"`
SSDPEnabled bool `json:"ssdp_enabled"`
OpenPorts []int `json:"open_ports,omitempty"`
}
RouterState is a summary of router findings.
func RouterStateFromInfo ¶
func RouterStateFromInfo(r *common.RouterInfo) *RouterState
RouterStateFromInfo converts a common.RouterInfo to the MCP RouterState.
type ServerConfig ¶
type ServerConfig struct {
// AllCheckers returns all available checker implementations.
AllCheckers func() []checker.Checker
// DiscoverGateway finds the network gateway IP.
DiscoverGateway func() string
}
ServerConfig holds configuration for the MCP server.
type Service ¶
type Service struct {
Type string `json:"type"`
Name string `json:"name"`
IP string `json:"ip,omitempty"`
Port int `json:"port,omitempty"`
Protocol string `json:"protocol,omitempty"`
Details string `json:"details,omitempty"`
}
Service represents a discovered network service.
func ServicesFromMDNS ¶
func ServicesFromMDNS(services []common.MDNSService) []Service
ServicesFromMDNS converts mDNS services to generic Service entries.
func ServicesFromSSDP ¶
func ServicesFromSSDP(services []common.SSDPService) []Service
ServicesFromSSDP converts SSDP services to generic Service entries.
func ServicesFromUPnP ¶
func ServicesFromUPnP(services []common.UPnPService) []Service
ServicesFromUPnP converts UPnP services to generic Service entries.
type ToolHandler ¶
type ToolHandler func(ctx context.Context, input *ToolInput) (*ToolOutput, error)
ToolHandler is the function signature for MCP tool handlers.
type ToolInput ¶
type ToolInput struct {
GatewayIP string `json:"gateway_ip,omitempty"`
// Port scanning
Ports []int `json:"ports,omitempty"`
// Web checker
CheckDefaultCreds bool `json:"check_default_creds,omitempty"`
// UPnP
EnumerateMappings bool `json:"enumerate_mappings,omitempty"`
CheckIPv6Firewall bool `json:"check_ipv6_firewall,omitempty"`
EnumerateServices bool `json:"enumerate_services,omitempty"`
CheckSecurityIssues bool `json:"check_security_issues,omitempty"`
// mDNS
Detailed bool `json:"detailed,omitempty"`
// SSDP
IPv4Enabled bool `json:"ipv4_enabled,omitempty"`
IPv6Enabled bool `json:"ipv6_enabled,omitempty"`
SearchTargets []string `json:"search_targets,omitempty"`
// Device/IPv6
ShowVirtual bool `json:"show_virtual,omitempty"`
// External
TestProxy bool `json:"test_proxy,omitempty"`
// Checkers to run (for full_scan)
Checkers []string `json:"checkers,omitempty"`
}
ToolInput is the universal input for all MCP tools. Each tool uses the subset of fields relevant to it.
type ToolOutput ¶
type ToolOutput struct {
// Summary is a one-line description of results.
Summary string `json:"summary"`
// Gateway info (populated by discover_network and full_scan).
Gateway *GatewayInfo `json:"gateway,omitempty"`
// Router state after checks (populated by router-based checks).
Router *RouterState `json:"router,omitempty"`
// Issues found during the check.
Issues []Issue `json:"issues,omitempty"`
// Services discovered (UPnP, SSDP, mDNS).
Services []Service `json:"services,omitempty"`
// Port mappings found (UPnP).
PortMappings []common.PortMapping `json:"port_mappings,omitempty"`
// Log is the human-readable output from the checker.
Log string `json:"log,omitempty"`
}
ToolOutput is the structured response from all MCP tools.