resource

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 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 RefreshableConsensusSpecIndex added in v0.36.0

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

RefreshableConsensusSpecIndex wraps a ConsensusSpecIndex behind an atomic swap. It delegates both the vector spec search and the lexical constant search.

func NewRefreshableConsensusSpecIndex added in v0.36.0

func NewRefreshableConsensusSpecIndex(idx *ConsensusSpecIndex) *RefreshableConsensusSpecIndex

NewRefreshableConsensusSpecIndex wraps an initial index.

func (*RefreshableConsensusSpecIndex) SearchConstants added in v0.36.0

func (r *RefreshableConsensusSpecIndex) SearchConstants(query string, limit int) []ConstantSearchResult

SearchConstants delegates to the current index. Constant search is lexical (no embedding), so it returns nil — not an error — while the index is swapped out.

func (*RefreshableConsensusSpecIndex) SearchSpecs added in v0.36.0

func (r *RefreshableConsensusSpecIndex) SearchSpecs(query string, limit int) ([]ConsensusSpecSearchResult, error)

SearchSpecs delegates to the current index, or reports not-ready while swapped out (spec search is vector-based and must not mix model spaces).

func (*RefreshableConsensusSpecIndex) Swap added in v0.36.0

Swap replaces the current index (nil parks it as not-ready).

type RefreshableEIPIndex added in v0.36.0

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

RefreshableEIPIndex wraps an EIPIndex behind an atomic swap. See RefreshableRunbookIndex for the rationale.

func NewRefreshableEIPIndex added in v0.36.0

func NewRefreshableEIPIndex(idx *EIPIndex) *RefreshableEIPIndex

NewRefreshableEIPIndex wraps an initial index.

func (*RefreshableEIPIndex) Search added in v0.36.0

func (r *RefreshableEIPIndex) Search(query string, limit int) ([]EIPSearchResult, error)

Search delegates to the current index, or reports not-ready while swapped out.

func (*RefreshableEIPIndex) Swap added in v0.36.0

func (r *RefreshableEIPIndex) Swap(idx *EIPIndex)

Swap replaces the current index (nil parks it as not-ready).

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 RefreshableRunbookIndex added in v0.36.0

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

RefreshableRunbookIndex wraps a RunbookIndex behind an atomic swap so the runtime can replace it (e.g. after the proxy's embedding model changes and the corpus is re-embedded) without disrupting in-flight searches. While the inner index is nil — during a re-index — Search returns a not-ready error rather than scoring a new-model query against an old-model index.

func NewRefreshableRunbookIndex added in v0.36.0

func NewRefreshableRunbookIndex(idx *RunbookIndex) *RefreshableRunbookIndex

NewRefreshableRunbookIndex wraps an initial index.

func (*RefreshableRunbookIndex) Search added in v0.36.0

func (r *RefreshableRunbookIndex) Search(query string, limit int) ([]RunbookSearchResult, error)

Search delegates to the current index, or reports not-ready while swapped out.

func (*RefreshableRunbookIndex) Swap added in v0.36.0

func (r *RefreshableRunbookIndex) Swap(idx *RunbookIndex)

Swap replaces the current index. Passing nil parks the index as not-ready (used at the start of a re-index so no search mixes embedding model spaces).

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