api

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package api provides client functionality for interacting with MCP Registry API endpoints

Index

Constants

This section is empty.

Variables

View Source
var ErrRegistryUnauthorized = errors.New("registry authentication failed")

ErrRegistryUnauthorized is a sentinel error for 401/403 responses from registry APIs.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GetServer retrieves a single server by its reverse-DNS name
	GetServer(ctx context.Context, name string) (*v0.ServerJSON, error)

	// ListServers retrieves all servers with automatic pagination handling
	ListServers(ctx context.Context, opts *ListOptions) ([]*v0.ServerJSON, error)

	// SearchServers searches for servers matching the query string
	// Always returns the latest version of each server
	SearchServers(ctx context.Context, query string) ([]*v0.ServerJSON, error)

	// ValidateEndpoint validates that the endpoint implements the MCP Registry API
	ValidateEndpoint(ctx context.Context) error
}

Client represents an MCP Registry API client

func NewClient

func NewClient(baseURL string, allowPrivateIp bool, tokenSource auth.TokenSource) (Client, error)

NewClient creates a new MCP Registry API client. If tokenSource is non-nil, the HTTP client transport will be wrapped to inject Bearer tokens into all requests.

type ListOptions

type ListOptions struct {
	// Limit is the maximum number of servers to retrieve per page (default: 100)
	Limit int

	// UpdatedSince filters servers updated after this RFC3339 timestamp
	UpdatedSince string

	// Version filters servers by version (e.g., "latest")
	Version string
}

ListOptions contains options for listing servers

type RegistryHTTPError added in v0.12.2

type RegistryHTTPError struct {
	StatusCode int
	Body       string
	URL        string
}

RegistryHTTPError represents an HTTP error from a registry API endpoint.

func (*RegistryHTTPError) Error added in v0.12.2

func (e *RegistryHTTPError) Error() string

func (*RegistryHTTPError) Unwrap added in v0.12.2

func (e *RegistryHTTPError) Unwrap() error

Unwrap returns ErrRegistryUnauthorized for 401/403 status codes, allowing callers to use errors.Is(err, ErrRegistryUnauthorized).

type SkillsClient added in v0.12.2

type SkillsClient interface {
	// GetSkill retrieves a skill by namespace and name (latest version).
	GetSkill(ctx context.Context, namespace, name string) (*thvregistry.Skill, error)
	// GetSkillVersion retrieves a specific version of a skill.
	GetSkillVersion(ctx context.Context, namespace, name, version string) (*thvregistry.Skill, error)
	// ListSkills retrieves skills with optional filtering and pagination.
	ListSkills(ctx context.Context, opts *SkillsListOptions) (*SkillsListResult, error)
	// SearchSkills searches for skills matching the query (single page, no auto-pagination).
	SearchSkills(ctx context.Context, query string) (*SkillsListResult, error)
	// ListSkillVersions lists all versions of a specific skill.
	ListSkillVersions(ctx context.Context, namespace, name string) (*SkillsListResult, error)
}

SkillsClient provides access to the ToolHive Skills extension API.

func NewSkillsClient added in v0.12.2

func NewSkillsClient(baseURL string, allowPrivateIp bool, tokenSource auth.TokenSource) (SkillsClient, error)

NewSkillsClient creates a new ToolHive Skills extension API client. If tokenSource is non-nil, the HTTP client transport will be wrapped to inject Bearer tokens into all requests.

type SkillsListOptions added in v0.12.2

type SkillsListOptions struct {
	// Search is an optional search query to filter skills.
	Search string
	// Limit is the maximum number of skills per page (default: 100).
	Limit int
	// Cursor is the pagination cursor for fetching the next page.
	Cursor string
}

SkillsListOptions contains options for listing skills.

type SkillsListResult added in v0.12.2

type SkillsListResult struct {
	Skills     []*thvregistry.Skill
	NextCursor string
}

SkillsListResult contains a page of skills and pagination info.

Jump to

Keyboard shortcuts

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