server

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT 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 server defines the MCP server: its tools, their inputs and outputs, and the validation between an agent's request and the lookups.

Index

Constants

This section is empty.

Variables

View Source
var Version = ""

Version is set at build time for container images, with -ldflags "-X .../internal/server.Version=...". Use BuildVersion to read it.

Functions

func BuildVersion

func BuildVersion() string

BuildVersion is the server's own version, as reported to clients. When the binary was not given one at build time, it falls back to the module version Go records for `go install ...@v1.2.3`, and to "dev" for a local build.

func New

func New(deps Deps) *mcp.Server

New returns the MCP server with all tools registered.

func NewHTTPHandler

func NewHTTPHandler(mcpServer *mcp.Server, options HTTPOptions) http.Handler

NewHTTPHandler serves the MCP server over Streamable HTTP as the 2026-07-28 revision describes it: one endpoint at /mcp that accepts POST, no sessions, and requests from other browser origins refused. /healthz answers 200 for load balancers and container probes, and needs no token.

Types

type ComponentInput

type ComponentInput struct {
	Name      string `json:"name,omitempty" jsonschema:"product name, such as LiteLLM or GitLab. Give this or image."`
	Image     string `` /* 158-byte string literal not displayed */
	Version   string `` /* 132-byte string literal not displayed */
	Ecosystem string `` /* 152-byte string literal not displayed */
	Package   string `json:"package,omitempty" jsonschema:"package name within the ecosystem"`
	Repo      string `json:"repo,omitempty" jsonschema:"upstream GitHub repository as owner/name, to read its security advisories"`
	CPE       string `json:"cpe,omitempty" jsonschema:"NVD product as vendor:product, such as gitlab:gitlab"`
}

ComponentInput identifies one component.

type ComponentSummary

type ComponentSummary struct {
	Component       ResolvedComponent `json:"component"`
	Status          string            `` /* 129-byte string literal not displayed */
	Reason          string            `json:"reason"`
	Counts          intel.Counts      `json:"counts"`
	LatestVersion   string            `json:"latestVersion,omitempty"`
	VersionStatus   string            `json:"versionStatus"`
	Support         intel.Support     `json:"support" jsonschema:"whether this version's release line still receives fixes"`
	OlderAdvisories int               `json:"olderAdvisories" jsonschema:"advisories that apply but were left out because they predate since"`
	VendorNotices   int               `` /* 126-byte string literal not displayed */
	TopAdvisories   []string          `json:"topAdvisories" jsonschema:"ids of the most urgent advisories, at most 5"`
	Failed          []string          `json:"failedSources" jsonschema:"sources that could not be checked for this component"`
}

ComponentSummary is one row of a batch answer.

type Deps

type Deps struct {
	Intel   *intel.Client
	Catalog *catalog.Catalog
	Logger  *slog.Logger
	// Metrics may be nil, in which case nothing is recorded.
	Metrics *metrics.Registry
}

Deps are what the tools need.

type HTTPOptions

type HTTPOptions struct {
	// Tokens says who may call. When it holds none, there is no
	// authentication, and the server must only be reachable by callers you
	// trust.
	Tokens *Tokens
	// JSON answers each request with a single application/json body instead
	// of a text/event-stream. Both are valid Streamable HTTP; the stream is
	// the default, and plain JSON suits proxies that buffer responses.
	JSON bool
	// RatePerMinute caps the requests each client may make in a minute.
	// Zero means no cap.
	RatePerMinute int
	Metrics       *metrics.Registry
	Logger        *slog.Logger
}

HTTPOptions configure the Streamable HTTP transport.

type ImageGroup added in v0.2.0

type ImageGroup struct {
	Images     []string `json:"images" jsonschema:"up to 10 of the image references in this group"`
	ImageCount int      `json:"imageCount"`
	ComponentSummary
}

ImageGroup is the answer for every image that is the same product at the same version.

type ResolvedComponent

type ResolvedComponent struct {
	Name         string `json:"name"`
	Version      string `json:"version,omitempty"`
	VersionFrom  string `json:"versionFrom,omitempty" jsonschema:"where the version came from: input or image-tag"`
	ResolvedFrom string `` /* 145-byte string literal not displayed */
	Ecosystem    string `json:"ecosystem,omitempty"`
	Package      string `json:"package,omitempty"`
	Repo         string `json:"repo,omitempty"`
	CPE          string `json:"cpe,omitempty"`
}

ResolvedComponent is how the server understood the request.

type Tokens added in v0.3.0

type Tokens struct {
	// contains filtered or unexported fields
}

Tokens holds the bearer tokens that may call the server over HTTP, each with the name of the team or client it was issued to. The name is what appears in the audit log and the metrics; the token itself never does.

Tokens come from a single shared secret, from a file of named tokens, or both. The file is read again when it changes, so a token can be added or revoked without restarting the server.

func NewTokens added in v0.3.0

func NewTokens(shared, path string) (*Tokens, error)

NewTokens builds the token set. shared is a single token for everyone, and path is a file of named tokens; either may be empty. The file is read now, so that a mistake in it stops the server at start-up.

func (*Tokens) Lookup added in v0.3.0

func (t *Tokens) Lookup(presented string) (name string, ok bool)

Lookup returns the name a token was issued to. Every stored token is compared, each in constant time, so the answer takes the same time whichever token matches or none.

func (*Tokens) Names added in v0.3.0

func (t *Tokens) Names() int

Names returns how many named tokens are loaded.

func (*Tokens) Required added in v0.3.0

func (t *Tokens) Required() bool

Required reports whether callers must present a token.

Jump to

Keyboard shortcuts

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