mcp

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package mcp implements the Model Context Protocol server. CRC: crc-MCPResource.md Spec: mcp.md Sequence: seq-mcp-get-state.md

Package mcp implements the Model Context Protocol server. CRC: crc-MCPServer.md Spec: mcp.md Sequence: seq-mcp-lifecycle.md, seq-mcp-state-wait.md

Package mcp implements the Model Context Protocol server. CRC: crc-MCPTool.md Spec: mcp.md Sequence: seq-mcp-lifecycle.md, seq-mcp-run.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditResult

type AuditResult struct {
	App        string       `json:"app"`
	Violations []Violation  `json:"violations"`
	Warnings   []Violation  `json:"warnings"`
	Summary    AuditSummary `json:"summary"`
}

AuditResult contains the results of auditing an app

func AuditApp

func AuditApp(baseDir, appName string) (*AuditResult, error)

AuditApp performs a full audit of an app CRC: crc-Auditor.md

type AuditSummary

type AuditSummary struct {
	TotalMethods      int `json:"total_methods"`
	DeadMethods       int `json:"dead_methods"`
	ViewdefViolations int `json:"viewdef_violations"`
}

AuditSummary provides counts of findings

type InstallResult

type InstallResult struct {
	Installed        []string `json:"installed"`
	Skipped          []string `json:"skipped"`
	Appended         []string `json:"appended"`
	Suggestions      []string `json:"suggestions,omitempty"`
	VersionSkipped   bool     `json:"version_skipped,omitempty"`
	BundledVersion   string   `json:"bundled_version,omitempty"`
	InstalledVersion string   `json:"installed_version,omitempty"`
	Hint             string   `json:"hint,omitempty"`
}

InstallResult contains the results of an install operation.

type Server

type Server struct {
	UiServer *cli.Server // UI engine server for ExecuteInSession
	// contains filtered or unexported fields
}

Server implements an MCP server for AI integration.

func NewServer

func NewServer(cfg *cli.Config, uiServer *cli.Server, viewdefs *cli.ViewdefManager, startFunc func(port int) (string, error), getSessionCount func() int) *Server

NewServer creates a new MCP server.

func (*Server) ClearLogs

func (s *Server) ClearLogs() error

ClearLogs clears all log files in the log directory. After clearing, calls the onClearLogs callback to allow reopening Go log file handles. Spec: mcp.md Section 5.1 - ui_configure clears logs CRC: crc-MCPServer.md

func (*Server) Configure

func (s *Server) Configure(baseDir string) error

Configure prepares the server environment (directories, auto-install). Called by handleConfigure after Stop() to allow reconfiguration. Auto-installs if README.md is missing (Spec: mcp.md Section 3.1). CRC: crc-MCPServer.md Sequence: seq-mcp-lifecycle.md (Scenario 1)

func (*Server) GetCurrentSessionID

func (s *Server) GetCurrentSessionID() string

GetCurrentSessionID returns the internal session ID for the current MCP session. Used by the root session provider to serve "/" without creating a new session. Spec: mcp.md Section 3.3 - Root URL Session Binding

func (*Server) Install

func (s *Server) Install(force bool) (*InstallResult, error)

Install installs bundled configuration files. This is the core install logic used by both Configure (auto-install) and handleInstall (MCP tool). Spec: mcp.md section 5.7

func (*Server) RemovePortFiles

func (s *Server) RemovePortFiles()

RemovePortFiles removes the mcp-port and ui-port files.

func (*Server) SafeExecuteInSession

func (s *Server) SafeExecuteInSession(sessionID string, fn func() (interface{}, error)) (result interface{}, err error)

SafeExecuteInSession wraps ExecuteInSession with panic recovery to prevent crashes.

func (*Server) SendNotification

func (s *Server) SendNotification(method string, params interface{})

SendNotification sends an MCP notification to the client. Called by Lua runtime when mcp.notify(method, params) is invoked.

func (*Server) ServeSSE

func (s *Server) ServeSSE(addr string) error

ServeSSE starts the MCP server as an SSE HTTP server on the given address. Spec: mcp.md Section 2.3

func (*Server) ServeStdio

func (s *Server) ServeStdio() error

ServeStdio starts the MCP server on Stdin/Stdout.

func (*Server) SetBaseDir

func (s *Server) SetBaseDir(baseDir string)

SetBaseDir sets the base directory without running auto-install. Used by the install command which handles installation separately.

func (*Server) SetOnClearLogs

func (s *Server) SetOnClearLogs(fn func())

SetOnClearLogs sets a callback to be called after logs are cleared. Used by main.go to reopen the Go log file handle. CRC: crc-MCPServer.md

func (*Server) ShutdownHTTPServer

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

ShutdownHTTPServer shuts down the standalone HTTP server.

func (*Server) Start

func (s *Server) Start() (string, error)

Start transitions the server to the Running state and starts the HTTP server. Called by handleConfigure after Configure() completes. Spec: mcp.md CRC: crc-MCPServer.md

func (*Server) StartAndCreateSession

func (s *Server) StartAndCreateSession() (string, error)

StartAndCreateSession starts the UI server and creates a session with mcp global. This is called both on process startup (auto-start) and by ui_configure (reconfiguration). Spec: mcp.md Section 3.1 - Server auto-starts Sequence: seq-mcp-lifecycle.md (Scenario 1)

func (*Server) StartHTTPServer

func (s *Server) StartHTTPServer() (int, error)

StartHTTPServer starts a standalone HTTP server in stdio mode. Serves debug pages and state wait endpoint. Returns the port number. Spec: mcp.md Section 2.2

func (*Server) Stop

func (s *Server) Stop() error

Stop destroys the current session and resets state. This allows reconfiguration via ui_configure.

func (*Server) WriteMCPPortFile

func (s *Server) WriteMCPPortFile(port int) error

WriteMCPPortFile writes the MCP port to the mcp-port file in baseDir. Spec: mcp.md Section 5.2

func (*Server) WriteUIPortFile

func (s *Server) WriteUIPortFile(port int) error

WriteUIPortFile writes the UI port to the ui-port file in baseDir. Spec: mcp.md Section 5.2

type State

type State int

State represents the internal state of the MCP server (not exposed externally). Spec: mcp.md Section 3.1 - Server auto-starts.

const (
	Configured State = iota // Internal state during configuration (not exposed)
	Running                 // Server is running and accepting connections
)

type Violation

type Violation struct {
	Type     string `json:"type"`
	Location string `json:"location"`
	Detail   string `json:"detail"`
}

Violation represents a single audit finding

Jump to

Keyboard shortcuts

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