package lazymcp ¶
import "golazy.dev/lazymcp"
Constants ¶
const VisibilityModel, VisibilityApp ¶
const (
VisibilityModel = "model"
VisibilityApp = "app"
)
Types ¶
type AppCSP ¶
AppCSP describes MCP Apps content security policy metadata.
type AppCSP struct {
ConnectDomains []string `json:"connect_domains,omitempty"`
ResourceDomains []string `json:"resource_domains,omitempty"`
}
type AppPermissions ¶
AppPermissions describes optional MCP Apps permission metadata.
type AppPermissions struct {
Tools []string `json:"tools,omitempty"`
}
type AppSpec ¶
AppSpec describes one MCP Apps UI resource owned by an MCP module.
type AppSpec struct {
URI string
Name string
Desc string
HTML string
View string
Variables func(context.Context) (map[string]any, error)
Layout string
UseLayout bool
CSP AppCSP
Permissions AppPermissions
Domain string
PrefersBorder bool
}
type Base ¶
Base is embedded by application MCP module types.
type Base struct {
// contains filtered or unexported fields
}
func NewBase ¶
NewBase creates an MCP base value.
func NewBase(ctx context.Context) Base
func (base Base) Context ¶
Context returns the application context captured by NewBase.
func (base Base) Context() context.Context
func (base Base) Name ¶
Name returns the explicit module name. Empty means infer from type/package.
func (base Base) Name() string
type Message ¶
Message is an MCP prompt message.
type Message struct {
Role string `json:"role"`
Text string `json:"text"`
}
func UserMessages ¶
UserMessages creates user-role prompt messages.
func UserMessages(messages ...string) []Message
type Options ¶
Options configures a Scope.
type Options struct {
Views Views
Authorizer func(context.Context, string) bool
}
type PromptSpec ¶
PromptSpec describes one MCP prompt.
type PromptSpec struct {
Name string
Desc string
Messages []Message
Fn any
}
type ResourceContent ¶
ResourceContent is returned by ResourceSpec readers.
type ResourceContent struct {
Text string
Blob []byte
MIMEType string
}
type ResourceSpec ¶
ResourceSpec describes one MCP resource.
type ResourceSpec struct {
URI string
Name string
Desc string
MIMEType string
Read func(context.Context) (ResourceContent, error)
}
type Scope ¶
Scope owns registered MCP modules and serves the MCP HTTP endpoint.
type Scope struct {
// contains filtered or unexported fields
}
func NewScope ¶
NewScope creates an empty MCP scope.
func NewScope(options Options) *Scope
func (scope *Scope) Empty ¶
Empty reports whether the scope has no registered modules.
func (scope *Scope) Empty() bool
func (scope *Scope) Handler ¶
Handler serves MCP requests at /mcp and falls through to next for other paths.
func (scope *Scope) Handler(next http.Handler) http.Handler
func (scope *Scope) MiddlewareName ¶
MiddlewareName returns the dispatcher-visible middleware name.
func (scope *Scope) MiddlewareName() string
func (scope *Scope) Register ¶
Register registers one MCP module component.
func (scope *Scope) Register(component any) error
func (scope *Scope) ServeHTTP ¶
ServeHTTP serves MCP JSON-RPC requests.
func (scope *Scope) ServeHTTP(w http.ResponseWriter, r *http.Request)
type SkillSpec ¶
SkillSpec describes an Agent Skill directory served through MCP resources.
type SkillSpec struct {
Path string
FS fs.FS
}
type ToolSpec ¶
ToolSpec describes one MCP tool.
type ToolSpec struct {
Name string
Desc string
Fn any
UI UIRef
Visibility []string
}
type UIRef ¶
UIRef links a tool to an MCP Apps UI resource.
type UIRef struct {
ResourceURI string
}
func UI ¶
UI returns a UIRef for uri.
func UI(uri string) UIRef
type ViewOptions ¶
ViewOptions configures rendering for one MCP App view.
type ViewOptions struct {
View string
Variables map[string]any
Layout string
UseLayout bool
}
type Views ¶
Views renders MCP App views. lazyapp adapts lazyview.Views to this interface.
type Views interface {
RenderString(context.Context, ViewOptions) (string, error)
}
Package lazymcp exposes GoLazy application capabilities through the Model Context Protocol.
Applications normally configure MCP through lazyapp.Config.MCP. The package can also be used directly by constructing a Scope, registering MCP modules, and mounting the scope as an HTTP handler. Authentication and authorization are intentionally supplied by outer layers; lazymcp reads validated JWT claims from context when they are present and filters module access from the "mcps" claim by default.