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 — subscribe integration for the publisher pub/sub server. CRC: crc-MCPSubscribe.md | Seq: seq-publish-subscribe.md, seq-publisher-lifecycle.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 ¶
- func GenerateThemeBlock(baseDir string, themes []string, defaultTheme string) string
- func GetCurrentTheme(baseDir string) string
- func GetThemeAccentColor(baseDir, theme string) string
- func HasThemeBlock(baseDir string) bool
- func InjectThemeBlock(baseDir string) error
- func ListThemes(baseDir string) ([]string, error)
- func WatchIndexHTML(baseDir string, logFn func(level int, format string, args ...interface{})) (func(), error)
- type AuditResult
- type AuditSummary
- type ClassUsage
- type InstallManifest
- 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) Update() (*UpdateResult, error)
- func (s *Server) WriteMCPPortFile(port int) error
- func (s *Server) WriteUIPortFile(port int) error
- type State
- type ThemeAuditResult
- type ThemeAuditSummary
- type ThemeClass
- type ThemeClassesResult
- type ThemeFrontmatter
- type ThemeInfo
- type ThemeListResult
- type UpdateConflict
- type UpdateResult
- type Violation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateThemeBlock ¶ added in v0.13.0
GenerateThemeBlock creates the HTML block to inject into index.html
func GetCurrentTheme ¶ added in v0.10.0
GetCurrentTheme returns the default theme (from config or hardcoded default)
func GetThemeAccentColor ¶ added in v0.13.0
GetThemeAccentColor extracts --term-accent from a theme CSS file
func HasThemeBlock ¶ added in v0.16.0
HasThemeBlock checks if index.html already contains the frictionless theme block. Seq: seq-theme-inject.md
func InjectThemeBlock ¶ added in v0.13.0
InjectThemeBlock updates index.html with the frictionless theme block
func ListThemes ¶ added in v0.10.0
ListThemes returns all theme CSS files in the themes directory (excludes base.css)
Types ¶
type AuditResult ¶
type AuditResult struct {
App string `json:"app"`
Violations []Violation `json:"violations"`
Warnings []Violation `json:"warnings"`
Reminders []string `json:"reminders"`
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 ClassUsage ¶ added in v0.10.0
type ClassUsage struct {
Class string `json:"class"`
File string `json:"file"`
Line int `json:"line,omitempty"`
}
ClassUsage tracks where a CSS class is used
type InstallManifest ¶ added in v0.18.0
type InstallManifest struct {
Version string `json:"version"`
Files map[string]string `json:"files"`
}
InstallManifest records the SHA256 hashes of installed files for smart update.
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) Update ¶ added in v0.18.0
func (s *Server) Update() (*UpdateResult, error)
Update performs a smart update using the install manifest for conflict detection. Files unchanged by the user are overwritten; modified files get a .merge copy.
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
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.
type ThemeAuditResult ¶ added in v0.10.0
type ThemeAuditResult struct {
App string `json:"app"`
Theme string `json:"theme"`
UndocumentedClasses []ClassUsage `json:"undocumented_classes"`
UnusedThemeClasses []string `json:"unused_theme_classes"`
Summary ThemeAuditSummary `json:"summary"`
}
ThemeAuditResult contains results of auditing an app's theme usage
func AuditAppTheme ¶ added in v0.10.0
func AuditAppTheme(baseDir, appName, theme string) (*ThemeAuditResult, error)
AuditAppTheme compares an app's CSS class usage against documented theme classes. If theme is empty, it audits against the union of all themes.
func AuditAppWithClasses ¶ added in v0.22.0
func AuditAppWithClasses(baseDir, appName, themeName string, classes []ThemeClass) (*ThemeAuditResult, error)
AuditAppWithClasses compares an app's CSS class usage against a provided class list.
type ThemeAuditSummary ¶ added in v0.10.0
type ThemeAuditSummary struct {
Total int `json:"total"`
Documented int `json:"documented"`
Undocumented int `json:"undocumented"`
}
ThemeAuditSummary provides counts for theme auditing
type ThemeClass ¶ added in v0.10.0
type ThemeClass struct {
Name string `json:"name"`
Description string `json:"description"`
Usage string `json:"usage"`
Elements []string `json:"elements"`
}
ThemeClass represents a semantic CSS class defined in a theme
func GetAllThemeClasses ¶ added in v0.22.0
func GetAllThemeClasses(baseDir string) ([]ThemeClass, error)
CRC: crc-ThemeManager.md | Seq: seq-theme-audit.md GetAllThemeClasses scans all theme CSS files and returns a deduplicated union of all @class entries.
func ResolveThemeClasses ¶ added in v0.22.0
func ResolveThemeClasses(baseDir, theme string) (string, []ThemeClass, error)
ResolveThemeClasses returns the theme label and class list for a given theme name. If theme is empty, it returns the deduplicated union of all themes with the label "(all)".
type ThemeClassesResult ¶ added in v0.10.0
type ThemeClassesResult struct {
Theme string `json:"theme"`
Classes []ThemeClass `json:"classes"`
}
ThemeClassesResult is returned by the classes action
type ThemeFrontmatter ¶ added in v0.10.0
type ThemeFrontmatter struct {
Name string `json:"name"`
Description string `json:"description"`
Classes []ThemeClass `json:"classes"`
}
ThemeFrontmatter represents theme metadata parsed from CSS comments
func GetThemeClasses ¶ added in v0.10.0
func GetThemeClasses(baseDir, theme string) (*ThemeFrontmatter, error)
GetThemeClasses parses a theme CSS file and returns its documented classes
func ParseThemeCSS ¶ added in v0.13.0
func ParseThemeCSS(content []byte) (*ThemeFrontmatter, error)
ParseThemeCSS extracts metadata from CSS comment block
type ThemeInfo ¶ added in v0.13.0
type ThemeInfo struct {
Name string `json:"name"`
Description string `json:"description"`
AccentColor string `json:"accent_color,omitempty"`
}
ThemeInfo contains basic theme information
type ThemeListResult ¶ added in v0.10.0
ThemeListResult is returned by the list action
func ListThemesWithInfo ¶ added in v0.13.0
func ListThemesWithInfo(baseDir string) (*ThemeListResult, error)
ListThemesWithInfo returns themes with their metadata
type UpdateConflict ¶ added in v0.18.0
type UpdateConflict struct {
Path string `json:"path"`
Reason string `json:"reason"`
OldHash string `json:"old_hash"`
CurrentHash string `json:"current_hash"`
MergePath string `json:"merge_path,omitempty"`
}
UpdateConflict describes a file that couldn't be updated because the user modified it.
type UpdateResult ¶ added in v0.18.0
type UpdateResult struct {
Updated []string `json:"updated"`
Skipped []string `json:"skipped"`
Conflicts []UpdateConflict `json:"conflicts,omitempty"`
NewVersion string `json:"new_version,omitempty"`
}
UpdateResult contains the results of an update operation.