mcp

package
v0.17.5 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 30 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 — 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

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateThemeBlock added in v0.13.0

func GenerateThemeBlock(themes []string, defaultTheme string) string

GenerateThemeBlock creates the HTML block to inject into index.html

func GetCurrentTheme added in v0.10.0

func GetCurrentTheme(baseDir string) string

GetCurrentTheme returns the default theme (from config or hardcoded default)

func GetThemeAccentColor added in v0.13.0

func GetThemeAccentColor(baseDir, theme string) string

GetThemeAccentColor extracts --term-accent from a theme CSS file

func HasThemeBlock added in v0.16.0

func HasThemeBlock(baseDir string) bool

HasThemeBlock checks if index.html already contains the frictionless theme block. Seq: seq-theme-inject.md

func InjectThemeBlock added in v0.13.0

func InjectThemeBlock(baseDir string) error

InjectThemeBlock updates index.html with the frictionless theme block

func ListThemes added in v0.10.0

func ListThemes(baseDir string) ([]string, error)

ListThemes returns all theme CSS files in the themes directory (excludes base.css)

func WatchIndexHTML added in v0.16.0

func WatchIndexHTML(baseDir string, logFn func(level int, format string, args ...interface{})) (func(), error)

WatchIndexHTML watches index.html for external writes and re-injects the theme block if missing. Seq: seq-theme-inject.md

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 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 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

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

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

type ThemeListResult struct {
	Themes  []ThemeInfo `json:"themes"`
	Current string      `json:"current"`
}

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 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