mcp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package mcp is the jevkit decision server: a stdio JSON-RPC MCP server (built on the official Go SDK) that exposes Jev as five tools.

The curated tools (jev_classify_request, jev_classify_failure, jev_rank_relevance) each fix one registered, versioned question set and return the typed answer plus the registry's act/gather/fallback decision. jev_developer_assess dispatches to a small, versioned, opt-in set of developer.* question sets built for coding-agent decision support. jev_ask is the raw, unversioned escape hatch. Every tool redacts state before it reaches the transport.

Agents decide whether to call these tools from very little: the server's initialize Instructions and the tool descriptions. Registry-backed results therefore carry one line of guidance next to the decision, so a gather says what evidence to add instead of reading as no answer.

stdout is the protocol channel; all logging goes to the configured log writer (stderr in production). The API key is resolved by the injected client, never by a caller, and is never logged or returned.

Index

Constants

View Source
const DefaultServerName = "jevkit"

DefaultServerName is the key under mcpServers that jevkit owns.

View Source
const Instructions = `` /* 1738-byte string literal not displayed */

Instructions is sent in the initialize result. MCP hosts show it to the agent ahead of the tool list, and it is often the only thing an agent reads before deciding whether these tools are worth loading, so it says when to call them, not how they work.

Variables

This section is empty.

Functions

func AppendAudit

func AppendAudit(stateDir string, e AuditEntry) error

AppendAudit writes e as one line under an exclusive lock, defaulting the timestamp to now (UTC). A missing stateDir disables auditing entirely; the caller should not invoke this when stateDir is empty.

func AuditPath

func AuditPath(stateDir string) string

AuditPath is <stateDir>/jevkit/jev-ask-audit.jsonl.

func ConfigDocument

func ConfigDocument(name, command string) ([]byte, error)

ConfigDocument is a standalone client config holding only the entry.

func MergeConfig

func MergeConfig(existing []byte, name, command string) (out []byte, changed bool, err error)

MergeConfig sets mcpServers.<name> in an existing client config (nil or empty input starts a new one), leaving every other setting untouched. changed is false when the entry was already present and identical, so merging twice is a no-op.

func ServerEntry

func ServerEntry(command string) map[string]any

ServerEntry is the client-config entry that launches the server. It has no env block: the server resolves the API key itself, so nothing secret is ever written to a client config.

func WriteConfigFile

func WriteConfigFile(path, name, command string) (changed bool, err error)

WriteConfigFile merges the entry into path, creating it (and its directory) if needed. The file is rewritten only when it changes, atomically, keeping its mode.

Types

type Asker

type Asker interface {
	Ask(ctx context.Context, req jev.Request) (*jev.Response, error)
}

Asker is the slice of the jev client the server uses.

type AuditEntry

type AuditEntry struct {
	Timestamp     string          `json:"timestamp"`
	Tool          string          `json:"tool"`
	Caller        string          `json:"caller"`
	Unregistered  bool            `json:"unregistered"`
	StateBytes    int             `json:"stateBytes"`
	Questions     []AuditQuestion `json:"questions"`
	RedactionHits map[string]int  `json:"redactionHits,omitempty"`
}

AuditEntry is one jev_ask call: identifying and size/redaction metadata only. It never carries state, instructions or criteria text.

type AuditQuestion

type AuditQuestion struct {
	ID              string `json:"id"`
	Type            string `json:"type"`
	InstructionsLen int    `json:"instructionsBytes"`
	CriteriaLen     int    `json:"criteriaBytes"`
}

AuditQuestion is one question's privacy-safe shape in an audit entry: its id, declared type and byte counts, never its instructions or criteria text.

type Config

type Config struct {
	// Decider supplies the registry and applies its thresholds.
	Decider *registry.Decider
	// Client asks Jev. It resolves the API key itself.
	Client Asker
	// Redact scrubs plain state/instructions text before it is sent; an
	// error rejects the call. It reports which rules fired (never the
	// matched text) so callers can record redaction counts.
	Redact func(string) (string, []redact.Hit, error)
	// RedactJSON scrubs structured (object or array) JSON text before it is
	// sent, preserving shape: jev_ask's structured state, instructions and
	// criteria. An error rejects the call.
	RedactJSON func(raw json.RawMessage) (json.RawMessage, []redact.Hit, error)
	// Unavailable returns "" when Jev can be used, else a short reason
	// (no key, breaker open). It must not return or log the key.
	Unavailable func(ctx context.Context) string
	// AuditDir, when set, receives one privacy-safe jev_ask audit line per
	// call (timestamp, caller, question ids/types, byte and redaction-hit
	// counts; never payload text) under <AuditDir>/jevkit/jev-ask-audit.jsonl.
	// Empty disables auditing.
	AuditDir string
	// Log receives all logging (stderr in production); nil discards it.
	Log io.Writer
	// Version is reported as the server version.
	Version string
}

Config wires a Server. Everything except Log and Version is required.

type Server

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

Server is the Jev MCP server.

func New

func New(cfg Config) (*Server, error)

New builds the server and registers its tools.

func (*Server) Run

func (s *Server) Run(ctx context.Context, t sdk.Transport) error

Run serves one session over t until the peer disconnects or ctx ends.

func (*Server) RunStdio

func (s *Server) RunStdio(ctx context.Context, in io.ReadCloser, out io.WriteCloser) error

RunStdio serves newline-delimited JSON-RPC over in and out.

Jump to

Keyboard shortcuts

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