mcp

package
v0.3.42 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 16 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 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 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, debug bool) *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.

Jump to

Keyboard shortcuts

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