client

package
v0.0.0-...-9268282 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 19 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package client provides the native Tinyrelay transport used by tinyagent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL, Secret, PubKey string
	HTTP                    *http.Client
}

func New

func New(base, secret string) (*Client, error)

func (*Client) Download

func (c *Client) Download(ctx context.Context, requestPath string) (map[string]any, error)

func (*Client) Identity

func (c *Client) Identity() map[string]string

func (*Client) MCP

func (c *Client) MCP(ctx context.Context, method string, params map[string]any, info mcp.Implementation) (json.RawMessage, error)

MCP posts one JSON-RPC request to the relay's stateless MCP endpoint and returns the raw result. Each call carries a fresh NIP-98 proof bound to the URL and body, the mirrored Mcp-* headers and the reserved _meta fields. The endpoint is /mcp under the client's base URL, so a tenant served under a path prefix is reached at /r/<name>/mcp.

func (*Client) Publish

func (c *Client) Publish(ctx context.Context, e nostr.Event) (nostr.Event, error)

func (*Client) Query

func (c *Client) Query(ctx context.Context, filters []Filter) ([]nostr.Event, error)

func (*Client) Request

func (c *Client) Request(ctx context.Context, requestPath, method string, body json.RawMessage) (any, error)

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, name string, filter Filter, sink EventSink) error

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, room, filename, typ string, data []byte) (UploadResult, error)

type EventSink

type EventSink func(string, nostr.Event)

type Filter

type Filter map[string]any

type MCPError

type MCPError struct {
	Status  int
	Code    int
	Message string
	Data    any
}

MCPError is a JSON-RPC error answered by the relay's MCP endpoint together with the HTTP status it arrived with. Failures to reach the relay at all are returned as ordinary errors instead.

func (*MCPError) Error

func (e *MCPError) Error() string

type UploadResult

type UploadResult map[string]any

Jump to

Keyboard shortcuts

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