server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 15 Imported by: 1 module, 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 assembles what `verdict serve` runs: a Twirp endpoint, an MCP endpoint, and a health check over one HTTP listener. It also serves MCP over stdio, for a client that launches Verdict as a subprocess.

The library has no dependency on this package. Everything here is a thin wrapper: a Go service that wants a decision engine imports pkg/verdict and never starts a server at all.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeStdio

func ServeStdio(ctx context.Context, engine *verdict.Engine, opts Options) error

ServeStdio runs the MCP surface over stdin and stdout until ctx is cancelled or the client disconnects. It is what an MCP client that launches Verdict as a subprocess talks to.

Nothing may be written to stdout but protocol frames: stdout *is* the transport. Anything a caller wants to log goes to stderr, which is why Options.Logger must not be writing to stdout when this is used.

Types

type Options

type Options struct {
	// Listen is the address to bind, e.g. ":7430".
	Listen string
	// TwirpPath is the prefix the Twirp handler is mounted under. Defaults to
	// "/twirp".
	TwirpPath string
	// MCPEnabled mounts the MCP endpoint at /mcp.
	MCPEnabled bool
	// MCPAllowLoad exposes the model-loading MCP tool.
	MCPAllowLoad bool
	// ModelRoot bounds LoadModel's path field. Empty forbids loading by path.
	ModelRoot string
	// ReadTimeout and WriteTimeout bound a single request.
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	// Version is reported by the health endpoint and to MCP clients.
	Version string
	// Logger receives request and lifecycle logs.
	Logger *slog.Logger
}

Options configure a Server.

type Server

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

Server is the assembled HTTP surface.

func New

func New(engine *verdict.Engine, opts Options) (*Server, error)

New builds a server over an engine.

func (*Server) Handler

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

Handler exposes the assembled mux, so a host can mount Verdict inside its own HTTP server rather than running a second listener.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context) error

ListenAndServe runs the server until ctx is cancelled, then shuts it down gracefully.

Directories

Path Synopsis
mcp
Package mcp exposes a Verdict engine as MCP tools, so an agent can evaluate decisions, read a decision's rules, and check a model for gaps and overlaps without a human in the loop.
Package mcp exposes a Verdict engine as MCP tools, so an agent can evaluate decisions, read a decision's rules, and check a model for gaps and overlaps without a human in the loop.
gosdk
Package gosdk mounts Verdict's MCP tool catalogue onto the official modelcontextprotocol/go-sdk server.
Package gosdk mounts Verdict's MCP tool catalogue onto the official modelcontextprotocol/go-sdk server.
Package twirp implements the Verdict RPC surface.
Package twirp implements the Verdict RPC surface.

Jump to

Keyboard shortcuts

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