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 ¶
- type Namespace
- func (ns *Namespace) Connect(ctx context.Context, c *client.Client, description string, ...) error
- func (ns *Namespace) ConnectedTo(c *client.Client) bool
- func (ns *Namespace) Description() string
- func (ns *Namespace) Disconnect(c *client.Client)
- func (ns *Namespace) Name() string
- func (ns *Namespace) Notify(fn func(eventschema.EventAction, string))
- func (ns *Namespace) Prompt(name string) (*sdkmcp.Prompt, error)
- func (ns *Namespace) PromptMessages(ctx context.Context, name string, input json.RawMessage) ([]llm.Message, error)
- func (ns *Namespace) Refresh(ctx context.Context) error
- func (ns *Namespace) SystemPrompt() string
- func (ns *Namespace) Tools() []llm.Tool
- func (ns *Namespace) Type() string
- type Opt
- type RunFunc
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 ¶
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) 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 ¶
ConnectedTo returns true when the namespace has the tools of the server the client is connected to
func (*Namespace) Description ¶
Description returns what the namespace is, such as its server's title
func (*Namespace) Disconnect ¶
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) Notify ¶
func (ns *Namespace) Notify(fn func(eventschema.EventAction, string))
Notify sets the function which is called, once the namespace is added to a toolkit, when one of its tools is created, updated, or deleted, as they're listed again, or cleared
func (*Namespace) Prompt ¶ added in v1.6.4
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) Refresh ¶
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) SystemPrompt ¶
SystemPrompt returns how to use the server, and its tools, as it said, when it was connected, or nothing, while it isn't
type Opt ¶
type Opt func(*opt) error
Opt is an option of a namespace
func WithAgents ¶ added in v1.6.4
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 ¶
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