mcpserver

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcpserver exposes CipherHorizon to assistants over the Model Context Protocol (PRD-020): ad-hoc TLS and SSH scans that run the same probe and evaluation as the CLI, and, when a CipherHorizon server is configured, the fleet (endpoints, stored scans, findings, standards conformance, host inventory) through that server's HTTP API, so its roles, audit trail and scan scope apply unchanged.

The model is an untrusted caller. Every scan passes the server's Guard; the operator can narrow it (--scan-allow), remove the scan tools (--no-scan) or every mutating tool (--read-only). Results are bounded in size and come with the text a reader would see.

Index

Constants

View Source
const (
	DetailVerdict  = "verdict"
	DetailFindings = "findings"
	DetailFull     = "full"
)

Detail levels for a scan result.

Variables

This section is empty.

Functions

func WithCredentials

func WithCredentials(ctx context.Context, h http.Header) context.Context

WithCredentials returns ctx carrying the headers that identify the caller to the server.

Types

type BaselineView

type BaselineView struct {
	ID      string `json:"id"`
	Title   string `json:"title"`
	Judged  bool   `json:"judged"`
	Meets   bool   `json:"meets"`
	Reason  string `json:"reason,omitempty"`
	Changes int    `json:"changes" jsonschema:"how many sshd_config lines would make it meet the baseline"`
}

BaselineView is SSH baseline conformance in brief.

type CBOMInput

type CBOMInput struct {
	ScanID int64 `json:"scanId,omitempty" jsonschema:"a completed stored scan: the CBOM of what that scan observed"`
	// Fleet-wide inventory when nothing is named.
	Inventory bool `json:"inventory,omitempty" jsonschema:"the merged inventory CBOM of every machine instead"`
}

CBOMInput names what to export.

type CBOMResult

type CBOMResult struct {
	MIMEType string `json:"mimeType"`
	Size     int    `json:"size"`
	Document any    `json:"document,omitempty"`
	Note     string `json:"note,omitempty"`
}

CBOMResult carries a CycloneDX document.

type ClauseView

type ClauseView struct {
	Standard string `json:"standard"`
	Clause   string `json:"clause"`
	Level    string `json:"level" jsonschema:"must or should"`
	Text     string `json:"text"`
	Detail   string `json:"detail,omitempty"`
}

ClauseView is one standard clause not met.

type ClientsView

type ClientsView struct {
	Connect int `json:"connect"`
	Fail    int `json:"fail"`
	PQ      int `json:"postQuantum" jsonschema:"clients that get a post-quantum key exchange"`
	NoFS    int `json:"noForwardSecrecy"`
}

ClientsView counts the simulated clients.

type EndpointAddInput

type EndpointAddInput struct {
	Target   string   `` /* 184-byte string literal not displayed */
	Protocol string   `json:"protocol,omitempty" jsonschema:"auto (default), tls or ssh"`
	Name     string   `json:"name,omitempty" jsonschema:"a display name; the address when empty"`
	Tags     []string `json:"tags,omitempty"`
	Notes    string   `json:"notes,omitempty"`
	Scan     bool     `json:"scan,omitempty" jsonschema:"also queue a first scan"`
}

EndpointAddInput adds an endpoint.

type EndpointGetInput

type EndpointGetInput struct {
	ID     int64  `json:"id" jsonschema:"the endpoint's id, from endpoints_list"`
	Detail string `json:"detail,omitempty" jsonschema:"verdict (default), findings or full, as for tls_scan"`
}

EndpointGetInput names one endpoint and how much of its latest verdict to return.

type EndpointInput

type EndpointInput struct {
	ID int64 `json:"id" jsonschema:"the endpoint's id, from endpoints_list"`
}

EndpointInput names one endpoint.

type EndpointResult

type EndpointResult struct {
	Endpoint endpointView     `json:"endpoint"`
	Verdict  *ScanResult      `json:"verdict,omitempty" jsonschema:"the latest completed scan judged, as tls_scan or ssh_scan would return it"`
	History  []map[string]any `json:"history,omitempty" jsonschema:"recent completed scans, newest first (at most 10): when, level, score, counts"`
	ScanURL  string           `json:"reportUrl,omitempty" jsonschema:"the report page in the web interface"`
}

EndpointResult is one endpoint with, when asked, its latest verdict.

type EndpointsListInput

type EndpointsListInput struct {
	Protocol string `json:"protocol,omitempty" jsonschema:"tls or ssh; empty for both"`
	Tag      string `json:"tag,omitempty" jsonschema:"only endpoints carrying this tag"`
	Query    string `json:"query,omitempty" jsonschema:"only endpoints whose name or address contains this text"`
	// Only narrows by state.
	Only string `` /* 159-byte string literal not displayed */
	Page
}

EndpointsListInput filters the endpoint list.

type FindInput added in v0.9.0

type FindInput struct {
	Domain          string `json:"domain" jsonschema:"the domain alone, such as example.com"`
	Wordlist        bool   `` /* 155-byte string literal not displayed */
	CertificateLogs bool   `` /* 184-byte string literal not displayed */
}

FindInput is what domain_find takes.

type FindOptions added in v0.9.0

type FindOptions struct {
	// Resolver answers DNS queries (default: the system resolver).
	Resolver namefind.Resolver
	// CT searches Certificate Transparency, and CTAllowed says whether the operator turned that
	// on. With either unset the tool refuses certificateLogs with the reason.
	CT        namefind.CTSearcher
	CTAllowed func() bool
	// Dial replaces the guarded dialer of the port checks (tests).
	Dial func(ctx context.Context, address string, port int) (net.Conn, error)
	// Timeout bounds one call (default 10 minutes).
	Timeout time.Duration
}

FindOptions configures domain_find (PRD-022, internal).

type FindResult added in v0.9.0

type FindResult struct {
	Domain string `json:"domain"`
	// Total is how many names were found; Names holds those that resolve, at most 500.
	Total     int `json:"total"`
	Resolving int `json:"resolving"`
	Answering int `json:"answering" jsonschema:"names with an address of their own on which at least one port answered"`
	// WildcardOnly counts names left out of names because they resolve only to the zone's answer for any name.
	WildcardOnly int                     `` /* 189-byte string literal not displayed */
	Names        []FoundName             `json:"names"`
	Cut          int                     `json:"cut,omitempty" jsonschema:"resolving names left out of names because of the 500 limit"`
	Sources      []namefind.SourceReport `json:"sources" jsonschema:"what each source did: ran, off or failed"`
	Limits       []string                `json:"limits" jsonschema:"what this run could not see"`
}

FindResult is the structured half of domain_find's answer.

type FindingView

type FindingView struct {
	ID          string `json:"id"`
	Severity    string `json:"severity"`
	Title       string `json:"title"`
	Detail      string `json:"detail,omitempty"`
	Remediation string `json:"remediation,omitempty"`
}

FindingView is one finding, for the model.

type FindingsListInput

type FindingsListInput struct {
	Severity string `` /* 128-byte string literal not displayed */
	Status   string `json:"status,omitempty" jsonschema:"new (no status set), acknowledged or accepted-risk; empty for every finding"`
	Protocol string `json:"protocol,omitempty" jsonschema:"tls, ssh or host; empty for all"`
	Page
}

FindingsListInput filters the fleet's findings.

type FlatFinding

type FlatFinding struct {
	AssetID     int64  `json:"assetId"`
	AssetName   string `json:"assetName"`
	AssetKind   string `json:"assetKind"`
	Key         string `json:"key"`
	Title       string `json:"title"`
	Detail      string `json:"detail,omitempty"`
	Severity    string `json:"severity,omitempty"`
	Category    string `json:"category,omitempty"`
	Class       string `json:"class,omitempty" jsonschema:"post-quantum class for host findings"`
	Remediation string `json:"remediation,omitempty"`
	Status      *struct {
		Status string `json:"status"`
		Note   string `json:"note,omitempty"`
	} `json:"status,omitempty"`
}

FlatFinding is one finding across the fleet, as the API returns it.

type Fleet

type Fleet struct {
	// Base is the server's URL, e.g. https://cipherhorizon.example.net.
	Base string
	// Token is the automation token (serve --token), sent as a bearer token. Empty when the
	// credentials come with each call (serve --mcp forwards the caller's own).
	Token string
	// Client makes the requests; nil means a default with a timeout. serve --mcp sets a Client
	// whose Transport calls the server in-process.
	Client *http.Client
}

Fleet is the CipherHorizon server the fleet tools talk to, through its HTTP API.

type FleetSummary

type FleetSummary = map[string]any

FleetSummary is what the Overview shows, as the API returns it, passed through.

type FoundName added in v0.9.0

type FoundName struct {
	Name      string   `json:"name"`
	Sources   []string `json:"sources" jsonschema:"which sources reported the name: domain, dns, ct, wordlist"`
	Addresses []string `json:"addresses"`
	CNAME     string   `json:"cname,omitempty"`
	External  bool     `json:"external,omitempty" jsonschema:"the name is an alias for a host outside the domain: the service is hosted elsewhere"`
	Ports     []int    `json:"ports" jsonschema:"the ports among 443, 8443, 22 (and 25 on mail servers) that accepted a connection"`
	Refused   string   `json:"refused,omitempty" jsonschema:"why the name may not be connected to from here"`
}

FoundName is one name in a domain_find result.

type HTTPOptions

type HTTPOptions struct {
	// Key, when set, is required as a bearer token on every request (compared in constant time).
	Key string
	// Authenticate, when set, runs before the MCP handler and decides whether the request may
	// proceed (serve --mcp passes the web server's own identification). It returns false after
	// writing its own refusal.
	Authenticate func(w http.ResponseWriter, r *http.Request) bool
	// ForwardCredentials makes the fleet tools call the API with the request's own Authorization
	// and Cookie headers rather than a fixed token (serve --mcp).
	ForwardCredentials bool
}

HTTPOptions configures Handler.

type HygieneView

type HygieneView struct {
	Score int    `json:"score" jsonschema:"0 to 100, or -1 when not rated"`
	Band  string `json:"band" jsonschema:"Excellent, Good, Fair, Poor or Failing"`
}

HygieneView is the TLS hygiene score in brief.

type ListResult

type ListResult[T any] struct {
	Items     []T  `json:"items"`
	Total     int  `json:"total"`
	Offset    int  `json:"offset"`
	Limit     int  `json:"limit"`
	Truncated bool `json:"truncated" jsonschema:"more items exist after this window"`
}

ListResult is a window onto a list.

type MachinesListInput

type MachinesListInput struct {
	Query string `json:"query,omitempty" jsonschema:"only machines whose name contains this text"`
	Page
}

MachinesListInput filters the host inventory's machines.

type Options

type Options struct {
	Version string
	Log     *slog.Logger // nil: nothing is logged

	// Scan configures the ad-hoc tls_scan and ssh_scan tools. NoScan leaves them out.
	Scan   ScanOptions
	NoScan bool
	// Find configures domain_find, which NoScan also leaves out: it connects to what it finds.
	Find FindOptions

	// Fleet, when set, adds the tools that read and (unless ReadOnly) change a CipherHorizon
	// server's fleet through its HTTP API.
	Fleet    *Fleet
	ReadOnly bool

	// Verdict writes the verdict text the CLI prints for an evaluation; Details writes what
	// --details adds. Both are injected so this package does not depend on the CLI.
	Verdict func(w io.Writer, target string, ev eval.Evaluation) error
	Details func(w io.Writer, rep any, ev eval.Evaluation) error

	Now func() time.Time
}

Options configures New.

type Page

type Page struct {
	Limit  int `json:"limit,omitempty" jsonschema:"items to return (default 50, at most 200)"`
	Offset int `json:"offset,omitempty" jsonschema:"items to skip"`
}

Page bounds a list: the model asks for a window and is told how much there is.

type ReadinessView

type ReadinessView struct {
	Level       int    `json:"level" jsonschema:"0 to 4"`
	Label       string `json:"label" jsonschema:"L0 to L4 with its name"`
	Summary     string `json:"summary"`
	HNDLExposed bool   `` /* 139-byte string literal not displayed */
}

ReadinessView is the post-quantum readiness in brief.

type SSHScanInput

type SSHScanInput struct {
	Target   string `json:"target" jsonschema:"host or host:port of an SSH server (ssh:// prefix allowed). The port is 22 unless given"`
	Baseline string `` /* 172-byte string literal not displayed */
	Detail   string `` /* 199-byte string literal not displayed */
}

SSHScanInput is what ssh_scan takes.

type ScanGetInput

type ScanGetInput struct {
	ID     int64  `json:"id" jsonschema:"the scan's id, from scan_start or an endpoint's latest scan"`
	Detail string `` /* 133-byte string literal not displayed */
}

ScanGetInput names one stored scan.

type ScanGetResult

type ScanGetResult struct {
	Scan    scanSummary `json:"scan"`
	Asset   endpointRef `json:"endpoint"`
	Events  []string    `json:"events,omitempty" jsonschema:"the scan's log, oldest first"`
	Verdict *ScanResult `json:"verdict,omitempty"`
}

ScanGetResult is one stored scan.

type ScanOptions

type ScanOptions struct {
	Guard server.Guard
	// Timeout is the per-connection timeout; Concurrency the connections in flight to a target;
	// MaxConnections the cap per TLS target.
	Timeout        time.Duration
	Concurrency    int
	MaxConnections int
	HTTPChecks     bool
}

ScanOptions bounds the ad-hoc scans.

type ScanResult

type ScanResult struct {
	Target   string `json:"target"`
	Protocol string `json:"protocol" jsonschema:"tls or ssh"`
	// Scanned is false when the target answered nothing; Error then says why and there is no verdict.
	Scanned    bool   `json:"scanned"`
	Error      string `json:"error,omitempty"`
	Incomplete bool   `json:"incomplete,omitempty" jsonschema:"a stage did not finish; the verdict judges what was seen"`

	Readiness  *ReadinessView `json:"readiness,omitempty"`
	Hygiene    *HygieneView   `json:"hygiene,omitempty" jsonschema:"TLS only: the TLS hygiene score"`
	Baseline   *BaselineView  `json:"baseline,omitempty" jsonschema:"SSH only: conformance to the chosen SSH baseline"`
	Standards  []StandardView `json:"standards,omitempty" jsonschema:"every published standard this program carries for the protocol, with its verdict"`
	Clients    *ClientsView   `` /* 129-byte string literal not displayed */
	Counts     map[string]int `json:"counts,omitempty" jsonschema:"findings by severity"`
	ChecksRun  int            `json:"checksRun,omitempty"`
	FixFirst   []FindingView  `json:"fixFirst,omitempty" jsonschema:"what to fix first, worst first (at most three)"`
	Findings   []FindingView  `json:"findings,omitempty" jsonschema:"with detail findings or full: every finding, worst first"`
	Clauses    []ClauseView   `json:"clausesNotMet,omitempty" jsonschema:"with detail findings or full: every standard clause the endpoint does not meet"`
	Changes    []string       `` /* 131-byte string literal not displayed */
	SSHDConfig string         `` /* 126-byte string literal not displayed */
	Full       any            `json:"evaluation,omitempty" jsonschema:"with detail full: the complete evaluation, as the CLI's --json prints it"`
	Note       string         `json:"note,omitempty" jsonschema:"what was left out and how to get it"`
	// contains filtered or unexported fields
}

ScanResult is the structured half of a scan tool's answer. The text half is the verdict the CLI prints. Fields a protocol does not have are omitted: SSH has no hygiene score, TLS no baseline.

type ScanStartInput

type ScanStartInput struct {
	EndpointIDs []int64 `json:"endpointIds,omitempty" jsonschema:"the endpoints to scan"`
	Tag         string  `json:"tag,omitempty" jsonschema:"scan every endpoint carrying this tag instead"`
	All         bool    `json:"all,omitempty" jsonschema:"scan every endpoint; prefer a tag or ids"`
}

ScanStartInput starts stored scans.

type ScanStartResult

type ScanStartResult struct {
	Queued        int           `json:"queued"`
	AlreadyActive int           `json:"alreadyActive"`
	Missing       int           `json:"missing"`
	Scans         []scanSummary `json:"scans"`
	Note          string        `json:"note"`
}

ScanStartResult says what was queued.

type Server

type Server struct {
	*mcp.Server
	// contains filtered or unexported fields
}

Server is the MCP server with the options it was built from.

func New

func New(opts Options) *Server

New builds the MCP server: tools in a fixed order, the resources and the prompts.

func (*Server) Handler

func (s *Server) Handler(opts HTTPOptions) http.Handler

Handler serves the MCP server over Streamable HTTP, stateless (the 2026-07-28 revision's mode): no sessions, every POST self-contained, GET and DELETE answered 405. The SDK refuses requests that reach a loopback listener with a foreign Host header (DNS rebinding); Origin is checked here as the specification asks.

type StandardView

type StandardView struct {
	ID             string `json:"id"`
	Title          string `json:"title"`
	Publisher      string `json:"publisher"`
	Verdict        string `json:"verdict" jsonschema:"meets, does-not-meet or not-assessed"`
	MustFailures   int    `json:"mustFailures"`
	ShouldFailures int    `json:"shouldFailures"`
}

StandardView is one standard's verdict.

type TLSScanInput

type TLSScanInput struct {
	Target string `` /* 196-byte string literal not displayed */
	// StartTLS overrides the automatic choice.
	StartTLS string `` /* 184-byte string literal not displayed */
	Detail   string `` /* 252-byte string literal not displayed */
	// HTTPChecks is the only thing beyond a handshake the scan sends.
	HTTPChecks *bool `` /* 189-byte string literal not displayed */
}

TLSScanInput is what tls_scan takes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL