mcp

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package mcp implements a native Model Context Protocol (MCP) server for Argus.

The server communicates over JSON-RPC 2.0 via stdio and exposes Argus's 30-rule database hygiene engine as autonomous AI agent tools.

Index

Constants

View Source
const (
	CostCheap     = transport.CostCheap
	CostExpensive = transport.CostExpensive

	DefaultMaxConcurrentCheap     = transport.DefaultMaxConcurrentCheap
	DefaultMaxConcurrentExpensive = transport.DefaultMaxConcurrentExpensive
	DefaultShutdownTimeout        = transport.DefaultShutdownTimeout

	CodeParseError                 = errorspkg.CodeParseError
	CodeInvalidRequest             = errorspkg.CodeInvalidRequest
	CodeMethodNotFound             = errorspkg.CodeMethodNotFound
	CodeInvalidParams              = errorspkg.CodeInvalidParams
	CodeInternalError              = errorspkg.CodeInternalError
	CodeServerNotInitialized       = errorspkg.CodeServerNotInitialized
	CodeUnsupportedProtocolVersion = errorspkg.CodeUnsupportedProtocolVersion
	CodeCancelled                  = errorspkg.CodeCancelled
)
View Source
const LatestProtocolVersion = "2026-07-28"

LatestProtocolVersion is the canonical protocol version offered by Argus.

View Source
const (
	// MaxMessageSize is the maximum allowed size (in bytes) of a single newline-delimited
	// JSON-RPC message on the stdio transport. Messages exceeding this limit cause
	// immediate connection termination — no partial execution, no partial stdout.
	MaxMessageSize = 10 * 1024 * 1024 // 10 MiB
)

Variables

View Source
var (
	ProtocolError                   = errorspkg.ProtocolError
	InvalidParamsError              = errorspkg.InvalidParamsError
	MethodNotFoundError             = errorspkg.MethodNotFoundError
	UnsupportedProtocolVersionError = errorspkg.UnsupportedProtocolVersionError
	CancelledError                  = errorspkg.CancelledError
	ToolSuccess                     = errorspkg.ToolSuccess
	ToolError                       = errorspkg.ToolError

	ValidateJSONRPC       = transport.ValidateJSONRPC
	NewDispatcher         = transport.NewDispatcher
	NewSynchronizedWriter = transport.NewSynchronizedWriter
	NewRequestTracker     = transport.NewRequestTracker
	IDKey                 = transport.IDKey
	ErrShutdownTimeout    = transport.ErrShutdownTimeout

	RegisterTool   = tools.RegisterTool
	UnregisterTool = tools.UnregisterTool

	NewPathAuthority = security.NewPathAuthority
	SubmitViaURL     = telemetry.SubmitViaURL
)
View Source
var ErrOversizedMessage = errors.New("mcp: message exceeds maximum allowed size")

ErrOversizedMessage is returned when a client sends a message exceeding MaxMessageSize. This is a connection-fatal transport violation: the server terminates the connection without sending a JSON-RPC error response, because the message framing itself is broken.

View Source
var SupportedProtocolVersions = map[string]bool{
	"2024-11-05": true,
	"2025-03-26": true,
	"2025-06-18": true,
	"2025-11-25": true,
	"2026-07-28": true,
}

SupportedProtocolVersions contains the set of MCP protocol versions supported by Argus.

Functions

func NegotiateProtocolVersion added in v1.1.0

func NegotiateProtocolVersion(requested string) string

NegotiateProtocolVersion negotiates an MCP protocol version according to the MCP specification: If the requested version is supported, it is selected; otherwise, the latest supported version is returned as the fallback.

func Serve added in v1.1.0

func Serve(r io.Reader, w io.Writer, opts ...ServerOption) error

Serve starts the MCP server reading from r and writing to w with optional configuration.

func ServeStdio

func ServeStdio() error

ServeStdio starts the MCP server reading from stdin and writing to stdout with strict lifecycle enforcement.

Types

type Dispatcher added in v1.1.0

type Dispatcher = transport.Dispatcher

type JSONRPCError added in v1.1.0

type JSONRPCError = errorspkg.JSONRPCError

type JSONRPCResponse added in v1.1.0

type JSONRPCResponse = errorspkg.JSONRPCResponse

type ParsedRequest added in v1.1.0

type ParsedRequest = transport.ParsedRequest

type RequestMeta added in v1.1.0

type RequestMeta = transport.RequestMeta

type RequestTracker added in v1.1.0

type RequestTracker = transport.RequestTracker

type ResourceCost added in v1.1.0

type ResourceCost = transport.ResourceCost

type ServerOption added in v1.1.0

type ServerOption func(*serverConfig)

ServerOption configures server runtime policies.

func WithStrictLifecycle added in v1.1.0

func WithStrictLifecycle(strict bool) ServerOption

WithStrictLifecycle configures whether the server enforces the standard MCP lifecycle state machine.

type SynchronizedWriter added in v1.1.0

type SynchronizedWriter = transport.SynchronizedWriter

type Tool added in v1.1.0

type Tool = tools.Tool

type ToolDef added in v1.1.0

type ToolDef = tools.ToolDef

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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