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, indent string) string
- func GetCurrentTheme(baseDir string) string
- func GetThemeAccentColor(baseDir, theme string) string
- func HasThemeBlock(baseDir string) bool
- func InjectAllThemeBlocks(baseDir string) error
- func InjectThemeBlock(baseDir string) error
- func InjectThemeBlockInFile(baseDir, filePath 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 ManifestEntry
- type Server
- func (s *Server) CallRun(code string) (interface{}, error)
- func (s *Server) ClearLogs() error
- func (s *Server) Configure(baseDir string) error
- func (s *Server) GetCurrentSessionID() string
- func (s *Server) GetCurrentVendedID() string
- func (s *Server) Install(force bool) (*InstallResult, error)
- func (s *Server) RegisterAPIRoutes(mux *http.ServeMux)
- 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 ThemeAuditResult
- type ThemeAuditSummary
- type ThemeClass
- type ThemeClassesResult
- type ThemeFrontmatter
- type ThemeInfo
- type ThemeListResult
- 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 an HTML file. The indent parameter is the leading whitespace to use for each line (detected from the marker's position in the source file).
func GetCurrentTheme ¶ added in v0.10.0
GetCurrentTheme reads the theme from storage/settings.json, falling back to the 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 InjectAllThemeBlocks ¶ added in v0.29.0
InjectAllThemeBlocks patches all HTML files in html/ that contain frictionless markers with the current theme block. CRC: crc-ThemeManager.md | R178
func InjectThemeBlock ¶ added in v0.13.0
InjectThemeBlock updates index.html with the frictionless theme block.
func InjectThemeBlockInFile ¶ added in v0.29.0
InjectThemeBlockInFile patches a single HTML file with the frictionless theme block. If the file has <!-- #frictionless -->...<!-- /frictionless --> markers, the content between them is replaced. Otherwise the block is inserted after <head>. CRC: crc-ThemeManager.md | R177
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]ManifestEntry `json:"files"`
}
InstallManifest records SHA-256 hashes and collision policies for installed files. Stored in settings.json under the "installManifest" key.
type InstallResult ¶
type InstallResult struct {
Installed []string `json:"installed"`
Skipped []string `json:"skipped"`
UserModified []string `json:"user_modified,omitempty"`
BackedUp []string `json:"backed_up,omitempty"`
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 ManifestEntry ¶ added in v0.27.0
type ManifestEntry struct {
Hash string `json:"hash"`
OnCollision string `json:"onCollision"`
Group string `json:"group"`
}
ManifestEntry records the installed state and upgrade policy for a single file. CRC: crc-MCPTool.md (R169-R176)
type Server ¶
type Server struct {
UiServer *cli.Server // UI engine server for ExecuteInSession
ProjectDir string // Explicit project root for skill/CLAUDE.md installation (optional; derived from baseDir if empty)
// 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) CallRun ¶ added in v0.27.0
CallRun executes Lua code in the current session programmatically. Used by flib.RunLua for embedded callers that don't go through HTTP.
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) GetCurrentVendedID ¶ added in v0.27.0
GetCurrentVendedID returns the vended (small counter) session ID. Used by flib.WithLua to access the Lua session directly.
func (*Server) Install ¶
func (s *Server) Install(force bool) (*InstallResult, error)
Install installs bundled configuration files with manifest-aware conflict detection. This is the core install logic used by Configure (auto-install), handleInstall (MCP tool), and handleUpdate (smart update). Spec: mcp.md section 5.5
func (*Server) RegisterAPIRoutes ¶ added in v0.27.0
RegisterAPIRoutes registers Frictionless API handlers on an external mux. This allows an embedding binary to serve /api/*, /wait, /state, /variables on its own listener (e.g. a Unix domain socket) instead of a separate TCP port.
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. CRC: crc-MCPServer.md | Seq: seq-mcp-lifecycle.md (Scenario 3)
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