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 ¶
- Variables
- func Run(ctx context.Context, opt Options, t mcp.Transport) error
- func Stdio() mcp.Transport
- type AddInput
- type AddOutput
- type AddedItem
- type AuditInput
- type AuditNode
- type AuditOutput
- type CheckOutput
- type DescribeOutput
- type Diagnostic
- type ExtraTool
- type FixtureInput
- type FixtureOutput
- type Options
- type RouteInput
- type RoutesOutput
- type ScreenshotOutput
- type SearchInput
- type SearchOutput
- type Server
- type Violation
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 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 ¶
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 ¶
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 ¶
SearchOutput is the result of registry_search.