resource

package
v0.33.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package resource provides MCP resource handlers for domain knowledge.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetQueryExamples

func GetQueryExamples(moduleReg *module.Registry) map[string]types.ExampleCategory

GetQueryExamples returns query examples from initialized modules only. Examples are surfaced through the semantic search tool, not as a bulk resource: the full set is far too large to hand to a model wholesale.

func RegisterAPIResources

func RegisterAPIResources(log logrus.FieldLogger, reg Registry, moduleReg *module.Registry)

RegisterAPIResources registers the python://ethpandaops resource with the registry.

func RegisterDatasourcesResources

func RegisterDatasourcesResources(
	log logrus.FieldLogger,
	reg Registry,
	moduleReg *module.Registry,
)

RegisterDatasourcesResources registers the datasources:// resources with the registry.

func RegisterGettingStartedResources

func RegisterGettingStartedResources(
	log logrus.FieldLogger,
	reg Registry,
	toolReg ToolLister,
)

RegisterGettingStartedResources registers the panda://getting-started resource.

func RegisterNetworksResources

func RegisterNetworksResources(log logrus.FieldLogger, reg Registry, client cartographoor.CartographoorClient)

RegisterNetworksResources registers all network-related resources with the registry.

Types

type ConsensusSpecIndex added in v0.21.0

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

ConsensusSpecIndex provides semantic search over consensus specs with hybrid scoring and exact constant name matching.

func NewConsensusSpecIndex added in v0.21.0

func NewConsensusSpecIndex(
	log logrus.FieldLogger,
	embedder embedding.Embedder,
	specs []types.ConsensusSpec,
	constants []types.SpecConstant,
) (*ConsensusSpecIndex, error)

NewConsensusSpecIndex creates a semantic search index from consensus specs.

func (*ConsensusSpecIndex) SearchConstants added in v0.21.0

func (idx *ConsensusSpecIndex) SearchConstants(
	query string,
	limit int,
) []ConstantSearchResult

SearchConstants returns constants matching the query by exact name match, prefix match, or substring match.

func (*ConsensusSpecIndex) SearchSpecs added in v0.21.0

func (idx *ConsensusSpecIndex) SearchSpecs(
	query string,
	limit int,
) ([]ConsensusSpecSearchResult, error)

SearchSpecs returns the top-k semantically similar specs for a query.

type ConsensusSpecSearchResult added in v0.21.0

type ConsensusSpecSearchResult struct {
	Spec  types.ConsensusSpec `json:"spec"`
	Score float64             `json:"similarity_score"`
}

ConsensusSpecSearchResult includes a spec and its similarity score.

type ConstantSearchResult added in v0.21.0

type ConstantSearchResult struct {
	Constant types.SpecConstant `json:"constant"`
	Score    float64            `json:"similarity_score"`
}

ConstantSearchResult includes a constant and its similarity score.

type DatasourceProvider

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

DatasourceProvider provides datasource information from the module registry.

func NewDatasourceProvider

func NewDatasourceProvider(moduleReg *module.Registry) *DatasourceProvider

NewDatasourceProvider creates a new datasource provider.

func (*DatasourceProvider) DatasourceInfo

func (p *DatasourceProvider) DatasourceInfo() []types.DatasourceInfo

DatasourceInfo returns aggregated datasource info from all initialized modules.

type DatasourcesJSONResponse

type DatasourcesJSONResponse struct {
	Datasources []types.DatasourceInfo `json:"datasources"`
}

DatasourcesJSONResponse is the JSON response for datasources resources.

type EIPIndex added in v0.12.0

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

EIPIndex provides semantic search over EIPs with hybrid scoring.

func NewEIPIndex added in v0.12.0

func NewEIPIndex(
	log logrus.FieldLogger,
	embedder embedding.Embedder,
	eips []types.EIP,
) (*EIPIndex, error)

NewEIPIndex creates a semantic search index from EIPs. All chunks are batch-embedded via the remote embedder (which handles its own model-aware caching on the proxy side).

func (*EIPIndex) Search added in v0.12.0

func (idx *EIPIndex) Search(query string, limit int) ([]EIPSearchResult, error)

Search returns the top-k semantically similar EIPs for a query. Uses hybrid scoring: vector similarity + exact text match boost.

type EIPSearchResult added in v0.12.0

type EIPSearchResult struct {
	EIP   types.EIP `json:"eip"`
	Score float64   `json:"similarity_score"`
}

EIPSearchResult includes the EIP and its similarity score.

type ExampleIndex

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

ExampleIndex provides semantic search over query examples.

func NewExampleIndex

func NewExampleIndex(
	log logrus.FieldLogger,
	embedder embedding.Embedder,
	categories map[string]types.ExampleCategory,
) (*ExampleIndex, error)

NewExampleIndex creates and populates a semantic search index from query examples using batch embedding.

func (*ExampleIndex) Close

func (idx *ExampleIndex) Close() error

Close releases resources held by the index.

func (*ExampleIndex) Search

func (idx *ExampleIndex) Search(query string, limit int) ([]SearchResult, error)

Search returns the top-k semantically similar examples for a query.

type GroupDetailResponse

type GroupDetailResponse struct {
	Group    string                       `json:"group"`
	Networks map[string]discovery.Network `json:"networks"`
}

GroupDetailResponse is the response for networks://{group} (devnet group).

type NetworkDetailResponse

type NetworkDetailResponse struct {
	ID               string            `json:"id"`
	ResourceURI      string            `json:"resource_uri"`
	NodeInventoryURL string            `json:"node_inventory_url,omitempty"`
	Usage            string            `json:"usage,omitempty"`
	Network          discovery.Network `json:"network"`
}

NetworkDetailResponse is the response for networks://{name} (single network).

type NetworkSummary

type NetworkSummary struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	ChainID     uint64 `json:"chain_id,omitempty"`
	Status      string `json:"status"`
	IsDevnet    bool   `json:"is_devnet"`
	DevnetGroup string `json:"devnet_group,omitempty"`
	ResourceURI string `json:"resource_uri"`
}

NetworkSummary is a compact representation for the active networks list.

type NetworksActiveResponse

type NetworksActiveResponse struct {
	Networks           []NetworkSummary    `json:"networks"`
	Groups             []string            `json:"groups"`
	ActiveDevnetGroups map[string][]string `json:"active_devnet_groups"`
	Usage              string              `json:"usage"`
}

NetworksActiveResponse is the response for networks://active.

type NetworksAllResponse

type NetworksAllResponse struct {
	Networks map[string]discovery.Network `json:"networks"`
	Groups   []string                     `json:"groups"`
}

NetworksAllResponse is the response for networks://all.

type ReadHandler

type ReadHandler = types.ReadHandler

ReadHandler is a function that reads a resource and returns its content.

type RefreshableExampleIndex added in v0.32.0

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

RefreshableExampleIndex wraps an ExampleIndex behind a swap so a background refresher can replace it (e.g. when proxy discovery changes which datasets are active in this deployment) without disrupting in-flight searches. It implements the same Search signature as ExampleIndex.

func NewRefreshableExampleIndex added in v0.32.0

func NewRefreshableExampleIndex(idx *ExampleIndex) *RefreshableExampleIndex

NewRefreshableExampleIndex wraps an initial index.

func (*RefreshableExampleIndex) Search added in v0.32.0

func (r *RefreshableExampleIndex) Search(query string, limit int) ([]SearchResult, error)

Search delegates to the current index.

func (*RefreshableExampleIndex) Swap added in v0.32.0

func (r *RefreshableExampleIndex) Swap(idx *ExampleIndex)

Swap replaces the current index. The previous index is dropped (not closed): the embedder it references is shared with the other search indices and is owned by the runtime, which closes it once at shutdown.

type Registry

type Registry interface {
	// RegisterStatic registers a static resource with a fixed URI.
	RegisterStatic(res StaticResource)

	// RegisterTemplate registers a template resource with URI parameters.
	RegisterTemplate(res TemplateResource)

	// ListStatic returns all registered static resources.
	ListStatic() []mcp.Resource

	// ListTemplates returns all registered resource templates.
	ListTemplates() []mcp.ResourceTemplate

	// Read reads a resource by URI for the given client surface and
	// returns its content, mime type, and any error.
	Read(ctx context.Context, uri string, s surface.Dialect) (content string, mimeType string, err error)
}

Registry manages MCP resources and their handlers.

func NewRegistry

func NewRegistry(log logrus.FieldLogger) Registry

NewRegistry creates a new resource registry.

type RunbookIndex

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

RunbookIndex provides semantic search over runbooks.

func NewRunbookIndex

func NewRunbookIndex(
	log logrus.FieldLogger,
	embedder embedding.Embedder,
	runbooks []types.Runbook,
) (*RunbookIndex, error)

NewRunbookIndex creates and populates a semantic search index from runbooks using batch embedding.

func (*RunbookIndex) Search

func (idx *RunbookIndex) Search(query string, limit int) ([]RunbookSearchResult, error)

Search returns the top-k semantically similar runbooks for a query.

type RunbookSearchResult

type RunbookSearchResult struct {
	Runbook types.Runbook `json:"runbook"`
	Score   float64       `json:"similarity_score"`
}

RunbookSearchResult includes the runbook and its similarity score.

type SearchResult

type SearchResult struct {
	CategoryKey  string        `json:"category_key"`
	CategoryName string        `json:"category_name"`
	Example      types.Example `json:"example"`
	Score        float64       `json:"similarity_score"`
}

SearchResult includes the example and its similarity score.

type StaticResource

type StaticResource = types.StaticResource

StaticResource represents a static resource with a fixed URI.

type TemplateResource

type TemplateResource = types.TemplateResource

TemplateResource represents a resource template with URI parameters.

type ToolLister

type ToolLister interface {
	List() []mcp.Tool
}

ToolLister provides access to registered tools.

Jump to

Keyboard shortcuts

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