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 ¶
- type AuditResult
- type AuditSummary
- type InstallResult
- type Server
- func (s *Server) ClearLogs() error
- func (s *Server) Configure(baseDir string) error
- func (s *Server) GetCurrentSessionID() string
- func (s *Server) Install(force bool) (*InstallResult, error)
- func (s *Server) RemovePortFiles()
- func (s *Server) SafeExecuteInSession(sessionID string, fn func() (interface{}, error)) (result interface{}, err error)
- func (s *Server) SendNotification(method string, params interface{})
- func (s *Server) ServeSSE(addr string) error
- func (s *Server) ServeStdio() error
- func (s *Server) SetBaseDir(baseDir string)
- func (s *Server) SetOnClearLogs(fn func())
- func (s *Server) ShutdownHTTPServer(ctx context.Context) error
- func (s *Server) Start() (string, error)
- func (s *Server) StartAndCreateSession() (string, error)
- func (s *Server) StartHTTPServer() (int, error)
- func (s *Server) Stop() error
- func (s *Server) WriteMCPPortFile(port int) error
- func (s *Server) WriteUIPortFile(port int) error
- type State
- type Violation
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 ¶
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 ¶
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 ¶
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 ¶
SendNotification sends an MCP notification to the client. Called by Lua runtime when mcp.notify(method, params) is invoked.
func (*Server) ServeSSE ¶
ServeSSE starts the MCP server as an SSE HTTP server on the given address. Spec: mcp.md Section 2.3
func (*Server) ServeStdio ¶
ServeStdio starts the MCP server on Stdin/Stdout.
func (*Server) SetBaseDir ¶
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 ¶
ShutdownHTTPServer shuts down the standalone HTTP server.
func (*Server) Start ¶
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 ¶
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 ¶
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 ¶
Stop destroys the current session and resets state. This allows reconfiguration via ui_configure.
func (*Server) WriteMCPPortFile ¶
WriteMCPPortFile writes the MCP port to the mcp-port file in baseDir. Spec: mcp.md Section 5.2
func (*Server) WriteUIPortFile ¶
WriteUIPortFile writes the UI port to the ui-port file in baseDir. Spec: mcp.md Section 5.2