namespace

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 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 namespace is the namespace of a connector's tools, in a toolkit: the tools of its MCP server, which are called with its client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Namespace

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

Namespace is the namespace of a connector's tools, in a toolkit, which it has for as long as the connector exists: its MCP server's tools, as they were last listed, once it's connected, and none, while it isn't, which are listed again with Refresh, such as when the server says they changed

func New

func New(name, description string, opts ...Opt) (*Namespace, error)

New returns the namespace, with the name, such as one schema.Namespace returns, and the description, such as the connector's URL, until its server says its title, which has no tools, until it's connected, with the options, such as how long its tools have, with WithTimeout. Returns ErrBadParameter when the name is empty.

func (*Namespace) Available added in v1.7.0

func (ns *Namespace) Available() bool

Available returns true when the namespace's server is a workspace, which it is while it's connected, and says it has resources, as an MCP server's resources are listed, and read, by folder, or all of them, when it ignores the folder

func (*Namespace) Connect

func (ns *Namespace) Connect(ctx context.Context, c *client.Client, description string, match func(string) bool, serial uint64) error

Connect lists the tools of the server the client is connected to, which are included, by the match, which includes every one when it's nil, and says each which was created, updated, or deleted, since they were last listed, with the description, such as the server's title, when it isn't empty, for the connector with the serial, unless it's been connected for a later one, such as once its patterns changed, when it does nothing. When they can't be listed, it has none, and that's the error.

func (*Namespace) ConnectedTo

func (ns *Namespace) ConnectedTo(c *client.Client) bool

ConnectedTo returns true when the namespace has the tools of the server the client is connected to

func (*Namespace) Description

func (ns *Namespace) Description() string

Description returns what the namespace is, such as its server's title

func (*Namespace) Disconnect

func (ns *Namespace) Disconnect(c *client.Client)

Disconnect clears the tools, as the client is disconnected from its server, and says each was deleted, so the namespace has none, until it's connected again, unless it's connected with another client, such as one which replaced it, when it does nothing

func (*Namespace) List added in v1.7.0

List returns a page of the server's folders, and resources, as workspace.NewClient's workspace does. Returns ErrServiceUnavailable when it isn't connected.

func (*Namespace) Name

func (ns *Namespace) Name() string

Name returns the namespace's name

func (*Namespace) Prompt added in v1.6.4

func (ns *Namespace) Prompt(name string) (*sdkmcp.Prompt, error)

Prompt returns the server's prompt, by its name as an agent, such as args_prompt, as it was last listed, or ErrNotFound, when there's none, such as while it isn't connected

func (*Namespace) PromptMessages added in v1.6.4

func (ns *Namespace) PromptMessages(ctx context.Context, name string, input json.RawMessage) ([]llm.Message, error)

PromptMessages returns the messages of the server's prompt, by its name as an agent, with the input, which is a JSON object of its arguments, as a model is sent them. Returns ErrNotFound when there's no prompt, or it isn't connected, and ErrBadParameter when the input isn't valid.

func (*Namespace) Read added in v1.7.0

func (ns *Namespace) Read(ctx context.Context, uri string) (llm.Resource, error)

Read returns the server's resource, or artwork, with the URI, as workspace.NewClient's workspace does. Returns ErrServiceUnavailable when it isn't connected.

func (*Namespace) Refresh

func (ns *Namespace) Refresh(ctx context.Context) error

Refresh lists the tools again, of the server it's connected to, such as when it says they changed, or does nothing, while it isn't connected. When they can't be listed, they're as they were, and that's the error.

func (*Namespace) Root added in v1.7.0

func (ns *Namespace) Root() string

Root returns the root of the server's resources' URIs, of its resource template which is one, such as file:///{+path}, or nothing, when it has none, or isn't connected

func (*Namespace) Subscribe added in v1.7.0

func (ns *Namespace) Subscribe(ctx context.Context, uri string) error

Subscribe asks for the resource with the URI's updates, from the server the namespace is connected to, and each it's connected to after

func (*Namespace) SystemPrompt

func (ns *Namespace) SystemPrompt() string

SystemPrompt returns how to use the server, and its tools, as it said, when it was connected, or nothing, while it isn't

func (*Namespace) Title added in v1.7.0

func (ns *Namespace) Title() string

Title returns the title of the server the namespace is connected to, or its name, when it has none, or nothing, when it isn't connected

func (*Namespace) Tools

func (ns *Namespace) Tools() []llm.Tool

Tools returns the server's tools, and its prompts, as agents, as they were last listed, in order of their names, or none, while it isn't connected

func (*Namespace) Tree added in v1.7.0

func (ns *Namespace) Tree() bool

Tree returns true when the server the namespace is connected to says its folders are listed on their own, or false, when it isn't connected

func (*Namespace) Type

func (ns *Namespace) Type() string

Type returns that the namespace's tools are an MCP server's

func (*Namespace) Unsubscribe added in v1.7.0

func (ns *Namespace) Unsubscribe(ctx context.Context, uri string) error

Unsubscribe stops asking for the resource with the URI's updates

func (*Namespace) Version added in v1.7.0

func (ns *Namespace) Version() string

Version returns the version of the server the namespace is connected to, or nothing, when it isn't connected

func (*Namespace) Watch added in v1.7.0

func (ns *Namespace) Watch(ctx context.Context, ch chan<- eventschema.Change) error

Watch sends the changes to the namespace's tools, as they're listed again, or cleared, to the channel, until the context is cancelled, as toolkit.Namespace says

func (*Namespace) WatchResources added in v1.7.0

func (ns *Namespace) WatchResources(ctx context.Context, ch chan<- schema.Change) error

WatchResources sends the server's resources which are updated, which are subscribed to, with Subscribe, and, without a URI, that its resources changed, as it says, or as the namespace is connected to another server, or the same again, to the channel, until the context is cancelled, when it returns nil. It follows the client the namespace is connected with, which changes, as it's connected again. It sends a change without a URI first, once it's watching the client, or there's none, so no update is missed, and again once it's watching each client after.

type Opt

type Opt func(*opt) error

Opt is an option of a namespace

func WithAgents added in v1.6.4

func WithAgents(run RunFunc) Opt

WithAgents makes the server's prompts agents, which are tools, beside its tools, run with the function, as the registry runs its agents. Without it, they aren't.

func WithTimeout

func WithTimeout(timeout time.Duration) Opt

WithTimeout is how long one of the server's tools has, as it's called, rather than the toolkit's default, which it has when it's zero

type RunFunc added in v1.6.4

type RunFunc func(ctx context.Context, name string, input json.RawMessage) (any, error)

RunFunc runs the agent with the name, in its namespace, such as github:review_pr, with the input, as a tool which a model called, as the registry runs its agents, and returns its reply

Jump to

Keyboard shortcuts

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