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

mcp

package
v0.3.45 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CatalogDescription added in v0.3.42

type CatalogDescription struct {
	Kind            string `json:"kind"`
	Name            string `json:"name"`
	Description     string `json:"description,omitempty"`
	LongDescription string `json:"long_description,omitempty"`
	Module          string `json:"module,omitempty"`
	DataSource      string `json:"data_source,omitempty"`

	// Data object.
	Type            string              `json:"type,omitempty"        jsonschema_description:"TABLE or VIEW"`
	Queries         []DescribedQuery    `` /* 140-byte string literal not displayed */
	PrimaryKey      []string            `json:"primary_key,omitempty"`
	Properties      *ObjectProperties   `json:"properties,omitempty"`
	Args            []DescribedArg      `json:"args,omitempty"        jsonschema_description:"Parameterized-view arguments — pass them as the query's args:{...}"`
	Relations       []DescribedRelation `json:"relations,omitempty"`
	RelationsTotal  int                 `json:"relations_total,omitempty"`
	RelationsOffset int                 `json:"relations_offset,omitempty"`
	RelationsMore   bool                `json:"relations_has_more,omitempty" jsonschema_description:"Call again with a larger relations_offset for the rest"`
	FieldsCount     int                 `json:"fields_count,omitempty" jsonschema_description:"Call catalog-object_fields for the fields themselves"`
	DataSources     []string            `` /* 143-byte string literal not displayed */

	// Function.
	Returns string `json:"returns,omitempty"`
	IsTable *bool  `` /* 130-byte string literal not displayed */

	// Module.
	DataObjectsCount *int `json:"data_objects_count,omitempty"`
	FunctionsCount   *int `json:"functions_count,omitempty"`
	SubmodulesCount  *int `json:"submodules_count,omitempty"`

	// Data source. Pointers so that false is reported for a data source and the
	// field is absent for every other kind.
	Engine      string   `json:"engine,omitempty"`
	ReadOnly    *bool    `json:"read_only,omitempty"`
	AsModule    *bool    `json:"as_module,omitempty"`
	IsExtension *bool    `json:"is_extension,omitempty"`
	Modules     []string `json:"modules,omitempty"`
}

CatalogDescription is one described entity. The shape is kind-dependent; what does not apply to a kind is omitted.

type CatalogItem added in v0.3.42

type CatalogItem struct {
	Kind string `json:"kind" jsonschema_description:"module | data_source | data_object | function"`
	Name string `` /* 143-byte string literal not displayed */
	// Type is TABLE|VIEW for a data object, FUNCTION|MUTATION|SUBSCRIPTION for
	// a callable, and the engine type string for a data source.
	Type        string `json:"type,omitempty"`
	Module      string `json:"module,omitempty"      jsonschema_description:"Owning module — REQUIRED to nest the GraphQL query"`
	DataSource  string `json:"data_source,omitempty"`
	Description string `json:"description,omitempty"`

	// Module only.
	DataObjects *int `json:"data_objects,omitempty" jsonschema_description:"Number of data objects directly in this module"`
	Functions   *int `json:"functions,omitempty"    jsonschema_description:"Number of callables directly in this module"`
	Submodules  *int `json:"submodules,omitempty"`

	// Data source only. Pointers so that false is reported for a data source
	// and the field is absent for every other kind.
	ReadOnly    *bool    `json:"read_only,omitempty"    jsonschema_description:"Mutations are not generated for this source"`
	AsModule    *bool    `json:"as_module,omitempty"`
	IsExtension *bool    `json:"is_extension,omitempty"`
	Modules     []string `json:"modules,omitempty"      jsonschema_description:"Modules this source places members in"`
}

CatalogItem is one entry of catalog-list. The shape is kind-dependent; the fields that do not apply to a kind are omitted rather than zeroed.

type Config added in v0.3.44

type Config struct {
	Debug bool
	// QueryTTL is how long a viz query's result stays cached, so the view's
	// own fetch of the same rows is a cache read rather than a second
	// execution. Zero leaves caching off unless a tool call asks for it.
	QueryTTL time.Duration
}

Config carries what the MCP surface needs beyond the querier.

type DescribeResult added in v0.3.42

type DescribeResult struct {
	Items    []CatalogDescription `json:"items"`
	NotFound []string             `` /* 150-byte string literal not displayed */
}

DescribeResult is the answer for a batch of exact names.

type DescribedArg added in v0.3.42

type DescribedArg struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Description string `json:"description,omitempty"`
}

type DescribedQuery added in v0.3.42

type DescribedQuery struct {
	Name         string         `json:"name"`
	Type         string         `` /* 205-byte string literal not displayed */
	RootTypeName string         `json:"root_type_name,omitempty"`
	Args         []DescribedArg `json:"args,omitempty"`
}

type DescribedRelation added in v0.3.42

type DescribedRelation struct {
	Name       string `json:"name"`
	Direction  string `json:"direction"  jsonschema_description:"FORWARD (this object points out) or BACK (something points here)"`
	Kind       string `json:"kind"       jsonschema_description:"FK | M2M | JOIN"`
	FieldName  string `` /* 127-byte string literal not displayed */
	DataObject string `json:"data_object,omitempty" jsonschema_description:"The far data object"`
	Through    string `json:"through,omitempty"     jsonschema_description:"M2M junction object"`
}

type EnumValue added in v0.3.42

type EnumValue struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Deprecated  bool   `json:"deprecated,omitempty"`
}

EnumValue is one enum member.

type FieldArgs added in v0.3.42

type FieldArgs struct {
	Field string         `json:"field"`
	Args  []DescribedArg `json:"args"`
}

FieldArgs is one field's argument tree.

type FieldArgsResult added in v0.3.42

type FieldArgsResult struct {
	TypeName string      `json:"type_name"`
	Items    []FieldArgs `json:"items"`
	NotFound []string    `json:"not_found,omitempty"`
}

type FieldValueBucket added in v0.3.42

type FieldValueBucket struct {
	Value any `json:"value"`
	Rows  int `json:"rows"`
}

type FieldValues added in v0.3.42

type FieldValues struct {
	Object string             `json:"object"`
	Field  string             `json:"field"`
	Values []FieldValueBucket `json:"values,omitempty"`
	Stats  map[string]any     `json:"stats,omitempty" jsonschema_description:"min/max/avg where the field's type allows, plus the distinct count"`
}

FieldValues is the distribution of one field.

type ObjectProperties added in v0.3.42

type ObjectProperties struct {
	IsCube       bool `json:"is_cube,omitempty"`
	IsM2M        bool `json:"is_m2m,omitempty"`
	IsHypertable bool `json:"is_hypertable,omitempty"`
	SoftDelete   bool `json:"soft_delete,omitempty"`
	HasVectors   bool `` /* 128-byte string literal not displayed */
}

type Page added in v0.3.42

type Page[T any] struct {
	Items   []T  `json:"items"`
	Total   int  `json:"total"    jsonschema_description:"Total matching items after permission filtering"`
	Limit   int  `json:"limit"`
	Offset  int  `json:"offset"`
	HasMore bool `json:"has_more" jsonschema_description:"More items exist past this page"`
	// Truncated marks a module tree deeper than the walk reaches: re-run with
	// `module` set to a deeper node to enumerate the rest.
	Truncated bool `json:"truncated,omitempty"`
}

Page is the uniform pagination envelope of every list-returning tool. Total is counted AFTER permission filtering, so "50 of 312" is honest.

type ReportEnvelope added in v0.3.44

type ReportEnvelope struct {
	Spec *reports.Spec       `json:"spec"`
	Data *reports.ReportData `json:"data"`
}

ReportEnvelope is what viz-report returns: the spec echoed verbatim (the view's Apply re-submits it) plus the run results, sampled for the wire the same way viz results are.

type SearchHit added in v0.3.42

type SearchHit struct {
	Kind        string  `json:"kind"        jsonschema_description:"module | data_source | data_object | function | field"`
	Name        string  `json:"name"`
	Module      string  `json:"module,omitempty"      jsonschema_description:"Owning module — REQUIRED to nest the GraphQL query"`
	DataSource  string  `json:"data_source,omitempty"`
	Description string  `json:"description,omitempty"`
	Score       float64 `json:"score"       jsonschema_description:"0-1, higher is better. Lexical fallback scores are coarse"`

	// Field hits only.
	Object    string `json:"object,omitempty"     jsonschema_description:"The data object this field belongs to"`
	FieldKind string `json:"field_kind,omitempty" jsonschema_description:"column | relation | extra"`
	HugrType  string `json:"hugr_type,omitempty"  jsonschema_description:"The field's GraphQL type"`
	RefObject string `` /* 152-byte string literal not displayed */

	// NextCall names the rung that turns this hit into something callable.
	NextCall string `json:"next_call,omitempty"`
}

SearchHit is one ranked result.

type SearchResultPage added in v0.3.42

type SearchResultPage struct {
	Items    []SearchHit `json:"items"`
	Limit    int         `json:"limit"`
	Offset   int         `json:"offset"`
	HasMore  bool        `json:"has_more"`
	Filtered int         `json:"filtered_out,omitempty" jsonschema_description:"Candidates dropped because the caller may not see them"`
	Lexical  bool        `` /* 165-byte string literal not displayed */
	// LexicalReason says WHY the vector index was unusable. A silent fallback
	// is indistinguishable from a broken ranking query, and would stay broken
	// unnoticed; this makes the difference observable to operators and tests.
	LexicalReason string `json:"lexical_reason,omitempty"`
}

SearchResultPage is the search envelope. It carries no total: the filter runs after ranking, so an honest total would mean scanning the whole index for every query. Filtered reports what the permission pass removed from the candidates actually examined — enough to tell "nothing matches" from "nothing you may see matches".

type Server

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

Server wraps the MCP server and its dependencies.

func New

func New(querier types.Querier, mcpServer *server.MCPServer, cfg Config) *Server

New creates a new MCP server backed by the given query engine. Everything — including the permission filter on the search path — goes through the querier, so MCP holds no copy of the engine's access policy.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns an http.Handler for mounting at /mcp.

type TypeDescription added in v0.3.42

type TypeDescription struct {
	Name        string `json:"name"`
	Kind        string `json:"kind"        jsonschema_description:"OBJECT | INPUT_OBJECT | ENUM | SCALAR | INTERFACE | UNION | LIST | NON_NULL"`
	Description string `json:"description,omitempty"`

	// Member counts — call schema-type_fields / schema-enum_values for the
	// members themselves.
	FieldsCount      int `json:"fields_count,omitempty"`
	InputFieldsCount int `json:"input_fields_count,omitempty"`
	EnumValuesCount  int `json:"enum_values_count,omitempty"`

	// Role in the logical model, when it has one.
	LogicalKind string `json:"logical_kind,omitempty" jsonschema_description:"Set when this type IS a logical entity: data_object, or module_root"`
	Module      string `json:"module,omitempty"`
	DerivedFrom string `` /* 170-byte string literal not displayed */
	Role        string `` /* 199-byte string literal not displayed */

	NextCall string `json:"next_call,omitempty" jsonschema_description:"The tool that owns this name"`
}

TypeDescription is what one name turned out to be.

type TypeDescriptions added in v0.3.42

type TypeDescriptions struct {
	Items    []TypeDescription `json:"items"`
	NotFound []string          `json:"not_found,omitempty" jsonschema_description:"Names that do not exist OR that the caller may not see"`
}

type TypeField added in v0.3.42

type TypeField struct {
	Name        string `json:"name"`
	Type        string `json:"type"        jsonschema_description:"GraphQL type, SDL spelling"`
	ArgsCount   int    `` /* 133-byte string literal not displayed */
	Description string `json:"description,omitempty"`

	// Data-object fields only.
	FieldKind string `json:"field_kind,omitempty" jsonschema_description:"column | relation | extra"`
	RefObject string `` /* 141-byte string literal not displayed */
	IsPK      bool   `json:"is_pk,omitempty"`
}

TypeField is one member of a type.

type VizChartSpec added in v0.3.44

type VizChartSpec = viz.ChartSpec

The specs and the KPI card are shared with the report renderer and live in pkg/mcp/viz; the aliases keep this package's wire surface (and its output schemas) exactly where it was.

type VizColumnSpec added in v0.3.44

type VizColumnSpec = viz.ColumnSpec

The specs and the KPI card are shared with the report renderer and live in pkg/mcp/viz; the aliases keep this package's wire surface (and its output schemas) exactly where it was.

type VizDataResult added in v0.3.44

type VizDataResult struct {
	Rows      []map[string]any `json:"rows"`
	RowCount  int              `json:"row_count"`
	Truncated bool             `json:"truncated"`
}

type VizEnvelope added in v0.3.44

type VizEnvelope struct {
	Kind      string           `json:"kind" jsonschema_description:"chart | table | kpi"`
	Title     string           `json:"title"`
	Chart     *VizChartSpec    `json:"chart,omitempty"`
	Columns   []VizColumnSpec  `json:"columns,omitempty"`
	Kpis      []VizKPI         `json:"kpis,omitempty" jsonschema_description:"The KPI cards (kind=kpi); always complete — a panel is never sampled"`
	Filters   []VizFilterSpec  `` /* 130-byte string literal not displayed */
	Source    *VizSource       `json:"source,omitempty"`
	Rows      []map[string]any `json:"rows" jsonschema_description:"Canonical flat rows the view renders"`
	RowCount  int              `json:"row_count"`
	Truncated bool             `json:"truncated" jsonschema_description:"true when the hard cap cut the result"`
	AtLimit   bool             `` /* 158-byte string literal not displayed */
	// Both only ever set on the copy the caller receives.
	RowsSampled bool `json:"rows_sampled,omitempty" jsonschema_description:"rows here is a sample of the first few; row_count is the real length"`
	Fetch       bool `` /* 211-byte string literal not displayed */
}

VizEnvelope is the structured result both the model and the app view read.

type VizFilterSpec added in v0.3.44

type VizFilterSpec struct {
	Name    string `json:"name" jsonschema_description:"Identifier of the control, unique within the view"`
	Label   string `json:"label,omitempty"`
	Control string `` /* 197-byte string literal not displayed */
	Field   string `json:"field,omitempty" jsonschema_description:"Row field the control matches against (default: name)"`
	Default any    `json:"default,omitempty" jsonschema_description:"Initial value when the user has not touched the control"`
	Value   any    `json:"value,omitempty" jsonschema_description:"Pre-applied value set from the conversation; applied to the first render too"`
}

type VizKPI added in v0.3.44

type VizKPI = viz.KPI

The specs and the KPI card are shared with the report renderer and live in pkg/mcp/viz; the aliases keep this package's wire surface (and its output schemas) exactly where it was.

type VizSource added in v0.3.44

type VizSource struct {
	Type        string         `json:"type" jsonschema_description:"query | inline"`
	Query       string         `json:"query,omitempty"`
	Variables   map[string]any `json:"variables,omitempty" jsonschema_description:"Original variables, passed back unchanged when the view fetches its rows"`
	JQTransform string         `json:"jq_transform,omitempty"`
}

Directories

Path Synopsis
Package reports implements design/039: a report is a pure function of (spec, variables, identity).
Package reports implements design/039: a report is a pure function of (spec, variables, identity).
Package ui holds the embedded browser assets of the visualization stack — the widget page, the shared JS core and the ECharts runtime — and exports them as bytes: go:embed does not cross package borders, so everything that inlines these assets into a page (pkg/mcp for the widget builds, pkg/mcp/reports for the report document) imports them from here.
Package ui holds the embedded browser assets of the visualization stack — the widget page, the shared JS core and the ECharts runtime — and exports them as bytes: go:embed does not cross package borders, so everything that inlines these assets into a page (pkg/mcp for the widget builds, pkg/mcp/reports for the report document) imports them from here.
Package viz is the visualization core shared by the MCP viz tools (pkg/mcp) and the report renderer (pkg/mcp/reports): the canonical data contracts — flat rows and KPI cards — the chart/column specs, the caps, and the query+jq pipeline that feeds them (query.go).
Package viz is the visualization core shared by the MCP viz tools (pkg/mcp) and the report renderer (pkg/mcp/reports): the canonical data contracts — flat rows and KPI cards — the chart/column specs, the caps, and the query+jq pipeline that feeds them (query.go).

Jump to

Keyboard shortcuts

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