mcpserver

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcpserver is the dev MCP server of `gx mcp` (REQ-AI-04). An agent reads the app model, checks the app, renders fixtures and pages in headless Chrome, audits them with axe-core and installs registry items. It needs no node: Chrome runs through chromedp and axe-core is embedded.

Index

Constants

This section is empty.

Variables

View Source
var ToolNames = []string{"describe", "check", "routes", "render_fixture", "screenshot_route", "a11y_audit", "registry_search", "registry_add"}

ToolNames are the names of the tools of the dev MCP server. A plugin cannot take one.

Functions

func Run

func Run(ctx context.Context, opt Options, t mcp.Transport) error

Run serves one client on the transport until it disconnects, then stops the app and Chrome.

func Stdio

func Stdio() mcp.Transport

Stdio is the transport of `gx mcp`: JSON-RPC on stdin and stdout.

Types

type AddInput

type AddInput struct {
	Item string `json:"item" jsonschema:"the item name, with an optional version: button or button@0.1.0"`
}

AddInput is the input of registry_add.

type AddOutput

type AddOutput struct {
	Added []AddedItem `json:"added"`
}

AddOutput is the result of registry_add: the items in install order, dependencies first.

type AddedItem

type AddedItem struct {
	Name    string   `json:"name"`
	Version string   `json:"version"`
	Files   []string `json:"files"`
}

AddedItem is one item registry_add installed.

type AuditInput

type AuditInput struct {
	Path      string `json:"path,omitempty" jsonschema:"the site path of a page; give this or a component and a name"`
	Component string `json:"component,omitempty" jsonschema:"the component of a fixture"`
	Name      string `json:"name,omitempty" jsonschema:"the fixture name"`
	Package   string `` /* 133-byte string literal not displayed */
	Theme     string `json:"theme,omitempty" jsonschema:"light or dark, for a fixture; empty follows the system"`
}

AuditInput names a page or a fixture.

type AuditNode

type AuditNode = chrome.AuditNode

AuditNode, Violation and AuditOutput are the result of a11y_audit.

type AuditOutput

type AuditOutput = chrome.AuditOutput

AuditNode, Violation and AuditOutput are the result of a11y_audit.

type CheckOutput

type CheckOutput struct {
	OK          bool         `json:"ok"`
	Diagnostics []Diagnostic `json:"diagnostics"`
}

CheckOutput is the result of check.

type DescribeOutput

type DescribeOutput struct {
	Model *compiler.AppModel `json:"model"`
}

DescribeOutput is the result of describe.

type Diagnostic

type Diagnostic struct {
	Code    string `json:"code"`
	File    string `json:"file"`
	Line    int    `json:"line"`
	Column  int    `json:"column"`
	Message string `json:"message"`
	Fix     string `json:"fix,omitempty"`
	Doc     string `json:"doc"`
}

Diagnostic is one diagnostic in the result of check (REQ-AI-02).

type ExtraTool added in v0.3.0

type ExtraTool struct {
	Name        string
	Description string
	// InputSchema is the JSON Schema of the arguments: an object schema.
	InputSchema json.RawMessage
	// Call gets the JSON object of the arguments and returns the text of
	// the answer.
	Call func(ctx context.Context, args json.RawMessage) (string, error)
}

ExtraTool is one tool of a plugin in the dev MCP server.

type FixtureInput

type FixtureInput struct {
	Component string `json:"component" jsonschema:"the component name, for example Button"`
	Name      string `json:"name" jsonschema:"the fixture name, for example Default"`
	Package   string `` /* 133-byte string literal not displayed */
	Format    string `json:"format,omitempty" jsonschema:"html (the default) or png"`
	Theme     string `json:"theme,omitempty" jsonschema:"light or dark; empty follows the system"`
}

FixtureInput names one fixture.

type FixtureOutput

type FixtureOutput struct {
	Component string `json:"component"`
	Name      string `json:"name"`
	Format    string `json:"format"`
	// HTML is the markup of the fixture, for the format html.
	HTML string `json:"html,omitempty"`
	// Bytes is the size of the PNG, for the format png.
	Bytes int `json:"bytes,omitempty"`
}

FixtureOutput is the result of render_fixture.

type Options

type Options struct {
	// Dir is the app module root.
	Dir string
	// Main is the app main package; apprun.DetectMain finds it when empty.
	Main string
	// Version is the Gx version the server reports.
	Version string
	// Installer returns the registry installer of the app, from gx.toml.
	Installer func() (registry.Installer, error)
	// Extra are the tools that the plugins of the project add
	// (REQ-PLG-01).
	Extra []ExtraTool
}

Options configure one server.

type RouteInput

type RouteInput struct {
	Path   string `json:"path" jsonschema:"the site path with its query, for example /products/1?tab=reviews"`
	Width  int    `json:"width,omitempty" jsonschema:"the viewport width in CSS pixels; the default is 1280"`
	Height int    `json:"height,omitempty" jsonschema:"the viewport height in CSS pixels; the default is 800"`
}

RouteInput names one page of the app.

type RoutesOutput

type RoutesOutput struct {
	Routes []compiler.RouteReport `json:"routes"`
}

RoutesOutput is the result of routes.

type ScreenshotOutput

type ScreenshotOutput struct {
	Path  string `json:"path"`
	Bytes int    `json:"bytes"`
}

ScreenshotOutput is the result of screenshot_route.

type SearchInput

type SearchInput struct {
	Query string `json:"query,omitempty" jsonschema:"words to find in the name, the kind or the description of an item; empty lists every item"`
}

SearchInput is the input of registry_search.

type SearchOutput

type SearchOutput struct {
	Items []registry.Summary `json:"items"`
}

SearchOutput is the result of registry_search.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server holds the state the tools share: one running dev build of the app and one headless Chrome. Both start on the first tool call that needs them.

func New

func New(opt Options) *Server

New returns a server for the app in opt.Dir.

func (*Server) Close

func (s *Server) Close()

Close stops the app and Chrome.

func (*Server) MCP

func (s *Server) MCP() *mcp.Server

MCP returns the protocol server, for a transport.

type Violation

type Violation = chrome.Violation

AuditNode, Violation and AuditOutput are the result of a11y_audit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL