Help us shape the future of Go! Take the 2026 Go Developer Survey

tools

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Copyright © 2025 Benny Powers <web@bennypowers.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2025 Benny Powers <web@bennypowers.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2025 Benny Powers <web@bennypowers.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2025 Benny Powers <web@bennypowers.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2025 Benny Powers <web@bennypowers.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var NewBaseTemplateData = types.NewBaseTemplateData

Use unified template data constructors from types package

View Source
var NewBaseTemplateDataWithSchema = types.NewBaseTemplateDataWithSchema

Functions

func BuildErrorResponse

func BuildErrorResponse(message string) *mcp.CallToolResult

BuildErrorResponse creates a standard error response for MCP tools

func BuildSuccessResponse

func BuildSuccessResponse(content string) *mcp.CallToolResult

BuildSuccessResponse creates a standard success response for MCP tools

func LookupElement

func LookupElement(registry types.MCPContext, tagName string) (types.ElementInfo, *mcp.CallToolResult, error)

LookupElement looks up an element in the registry and returns appropriate responses Returns: (element, errorResponse, error) - If element found: (element, nil, nil) - If element not found: (nil, errorResponse, nil) - If lookup failed: (nil, nil, error)

func MakeGenerateConfigHandler added in v0.11.0

func MakeGenerateConfigHandler(registry mcpTypes.MCPContext) mcp.ToolHandler

func MakeGenerateHtmlHandler

func MakeGenerateHtmlHandler(registry types.MCPContext) mcp.ToolHandler

MakeGenerateHtmlHandler is the exported version for testing

func MakeValidateConfigHandler added in v0.11.0

func MakeValidateConfigHandler(registry mcpTypes.MCPContext) mcp.ToolHandler

func MakeValidateHtmlHandler

func MakeValidateHtmlHandler(registry types.MCPContext) mcp.ToolHandler

MakeValidateHtmlHandler is the exported version for testing

func ParseToolArgs

func ParseToolArgs[T any](req *mcp.CallToolRequest) (T, error)

ParseToolArgs parses JSON arguments from an MCP request into the specified type

func RenderTemplate

func RenderTemplate(templateName string, data any) (string, error)

RenderTemplate renders a template using the global thread-safe pool

func Tools

func Tools(registry types.MCPContext) ([]types.ToolDefinition, error)

Tools returns all available tool definitions with their handlers

Types

type AttributeConflict

type AttributeConflict struct {
	ElementTagName string
	Attribute1     string
	Value1         string
	Attribute2     string
	Value2         string
	ConflictReason string
}

AttributeConflict represents conflicting attribute combinations

type AttributeMap added in v0.6.0

type AttributeMap map[string]string

type AttributeWithValue

type AttributeWithValue struct {
	types.Attribute
	Value string
}

AttributeWithValue pairs an attribute with its assigned value

type BaseTemplateData

type BaseTemplateData = types.BaseTemplateData

type ContentAttributeRedundancy

type ContentAttributeRedundancy struct {
	ElementTagName string
	AttributeName  string
	AttributeValue string
	SlotName       string
	SlotContent    string
}

ContentAttributeRedundancy represents cases where slot content overrides attributes

type ElementUsage

type ElementUsage struct {
	Html   string
	Issues []string
}

ElementUsage represents a specific usage of an element in HTML

type ElementValidationResult

type ElementValidationResult struct {
	types.ElementInfo
	TagName      string
	ElementFound bool
	Usages       []ElementUsage
}

ElementValidationResult represents specific element validation

type ElementWithCapabilities

type ElementWithCapabilities struct {
	types.ElementInfo
	Capabilities []string
}

ElementWithCapabilities wraps an element with its capability strings

type ElementWithIssues

type ElementWithIssues struct {
	types.ElementInfo
	UsageCount int
}

ElementWithIssues pairs an element with its validation results

type GenerateConfigArgs added in v0.11.0

type GenerateConfigArgs struct {
	Focus string `json:"focus,omitempty"`
}

type GenerateHtmlArgs

type GenerateHtmlArgs struct {
	TagName    string            `json:"tagName"`
	Context    string            `json:"context,omitempty"`
	Options    map[string]string `json:"options,omitempty"`
	Content    string            `json:"content,omitempty"`
	Attributes AttributeMap      `json:"attributes,omitempty"`
}

GenerateHtmlArgs represents the arguments for the generate_html tool

type HTMLGenerationTemplateData

type HTMLGenerationTemplateData struct {
	BaseTemplateData
	Content            string
	GeneratedHTML      string
	RequiredAttributes []AttributeWithValue
	OptionalAttributes []AttributeWithValue
	SortedAttributes   []AttributeWithValue
	Slots              []SlotWithContent
}

HTMLGenerationTemplateData specific to HTML generation

func NewHTMLGenerationTemplateData

func NewHTMLGenerationTemplateData(element types.ElementInfo, context string, options map[string]string) HTMLGenerationTemplateData

NewHTMLGenerationTemplateData creates HTML generation template data

func NewHTMLGenerationTemplateDataWithSchema

func NewHTMLGenerationTemplateDataWithSchema(element types.ElementInfo, context string, options map[string]string, schemaDefinitions any) HTMLGenerationTemplateData

NewHTMLGenerationTemplateDataWithSchema creates HTML generation template data with schema context

type HTMLValidationData

type HTMLValidationData struct {
	Html                         string
	Context                      string
	FoundElements                []ElementWithIssues
	ManifestIssues               []ValidationIssue
	ManifestFeatures             []ValidationFeature
	SlotContentIssues            []SlotContentIssue
	AttributeConflicts           []AttributeConflict
	ContentAttributeRedundancies []ContentAttributeRedundancy
	SpecificElement              *ElementValidationResult
}

HTMLValidationData represents data for custom element validation templates

type ResponseBuilder

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

ResponseBuilder provides a fluent interface for building tool responses

func NewResponseBuilder

func NewResponseBuilder() *ResponseBuilder

NewResponseBuilder creates a new response builder

func (*ResponseBuilder) AddDescription

func (rb *ResponseBuilder) AddDescription(element types.ElementInfo) *ResponseBuilder

AddDescription adds element description if available

func (*ResponseBuilder) AddHeader

func (rb *ResponseBuilder) AddHeader(level int, text string) *ResponseBuilder

AddHeader adds a markdown header at the specified level

func (*ResponseBuilder) AddSection

func (rb *ResponseBuilder) AddSection(content string) *ResponseBuilder

AddSection adds a section with content

func (*ResponseBuilder) AddTemplateSection

func (rb *ResponseBuilder) AddTemplateSection(templateName string, data any) *ResponseBuilder

AddTemplateSection renders a template and adds it as a section

func (*ResponseBuilder) Build

func (rb *ResponseBuilder) Build() *mcp.CallToolResult

Build creates the final MCP response

func (*ResponseBuilder) String

func (rb *ResponseBuilder) String() string

String returns the current content as a string

type SchemaDefinitionMap added in v0.6.0

type SchemaDefinitionMap map[string]any

type SlotContentIssue

type SlotContentIssue struct {
	SlotName         string
	ElementTagName   string
	Guideline        string
	ViolationMessage string
}

SlotContentIssue represents content guideline violations in slots

type SlotWithContent

type SlotWithContent struct {
	types.Slot
	ExampleContent string
	DefaultContent string
}

SlotWithContent pairs a slot with example content

type TemplateDataProvider

type TemplateDataProvider = types.TemplateDataProvider

Use unified template data types from types package

type ValidateHtmlArgs

type ValidateHtmlArgs struct {
	Html    string `json:"html"`
	Context string `json:"context,omitempty"`
	TagName string `json:"tagName,omitempty"`
}

ValidateHtmlArgs represents the arguments for the validate_html tool

type ValidationFeature

type ValidationFeature struct {
	Type    string // "slots", "guidelines", "css-apis"
	Element string
	Details string
}

ValidationFeature represents available manifest features

type ValidationIssue

type ValidationIssue struct {
	Type      string // "missing-attribute", "invalid-value", "semantic-issue"
	Element   string
	Attribute string
	Expected  string
	Actual    string
	Message   string
	Priority  string // "error", "warning", "info"
}

ValidationIssue represents a specific validation problem

type ValidationSuggestion

type ValidationSuggestion struct {
	Type     string // "semantic-elements", "list-structure", "document-structure"
	Priority string // "error", "warning", "suggestion"
	Message  string
}

ValidationSuggestion represents improvement suggestions

type ValidationTemplateData

type ValidationTemplateData struct {
	BaseTemplateData
	Html                         string
	FoundElements                []ElementWithIssues
	ManifestIssues               []ValidationIssue
	ManifestFeatures             []ValidationFeature
	SlotContentIssues            []SlotContentIssue
	AttributeConflicts           []AttributeConflict
	ContentAttributeRedundancies []ContentAttributeRedundancy
	SpecificElement              *ElementValidationResult
}

ValidationTemplateData specific to validation tools

func NewValidationTemplateData

func NewValidationTemplateData(element mcpTypes.ElementInfo, context string, options map[string]string, html string) ValidationTemplateData

NewValidationTemplateData creates validation template data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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