Documentation
¶
Overview ¶
Package schema has the defaults, and types, of MCP clients, of remote servers
Index ¶
- Constants
- Variables
- func ConnectorName(name string) string
- func HostName(rawURL string) string
- func Namespace(name string, taken func(string) bool) string
- func NumberedName(name string, n int) string
- type AuthorizeRequest
- type AuthorizeResponse
- type Connector
- type ConnectorEvent
- type ConnectorList
- type ConnectorMeta
- type ConnectorServer
- type ConnectorTemplate
- type ConnectorTemplateList
- type Credential
Constants ¶
const ( AuthRequired = "required" AuthAuthorized = "authorized" )
The values of a connector's Auth: its server needs to be authorized, or is
const ( // AgentNamespace is the namespace of the registry's agents, which a // connector's namespace can't be, as the registry's AgentNamespace is AgentNamespace = "agent" // DefaultNamespace is a connector's namespace, when its name has nothing // which can be one DefaultNamespace = "mcp" )
const ( // DefaultName is the name of a client, which a server is told, as it // connects, unless it's given another DefaultName = "go-llm" // Name is the schema of the connectors' events, which the broadcaster // publishes Name = "mcp" // ConnectorTable is the table of the connectors' events, whose rows are // their names ConnectorTable = "connector" )
const ( // DefaultConnectorName is a connector's name, when nothing of what it's // named after can be one DefaultConnectorName = "mcp" )
Variables ¶
var ( // DefaultVersion is the version of a client, which a server is told, as // it connects, unless it's given another, which is the build's DefaultVersion = version.Version() )
Functions ¶
func ConnectorName ¶
ConnectorName returns a connector's name, from its server's name, such as github for "GitHub", or github-mcp-server for "github-mcp-server", in lower case, with each run of what an identifier can't have, such as spaces and dots, as a hyphen, starting with a letter, or DefaultConnectorName, when nothing's left of it
func HostName ¶
HostName returns the name of a server, from the host of its URL, such as seolinkmap for https://seolinkmap.com/mcp, or mcp.example for https://mcp.example.com/mcp, without www, and its top-level domain, for when the server can't say its own name
func Namespace ¶
Namespace returns the namespace of the tools of the connector with the name, in a toolkit: the name, without the characters an identifier can't have, starting with a letter, without two underscores together, or one at its end, which the toolkit's namespaces can't have, or DefaultNamespace, when nothing's left of it, and no longer than 24 characters, so its tools' names fit what a model calls them. When it's AgentNamespace, or taken, such as by a namespace in the toolkit, random digits are added to it, within that, until it isn't. The function which says whether a namespace is taken can be nil.
func NumberedName ¶
NumberedName returns the name, with a number, when it's another connector's, such as github-2, for the second, and the name itself for the first
Types ¶
type AuthorizeRequest ¶
type AuthorizeRequest struct {
Redirect string `` /* 205-byte string literal not displayed */
}
AuthorizeRequest is the request to authorize a connector's server, with the URL its authorization server redirects to, once a person has signed in, which is the API's callback, of the request's origin, when it's omitted
type AuthorizeResponse ¶
type AuthorizeResponse struct {
URL string `json:"url" help:"The URL a person signs in at, to authorize the connector's server" format:"uri" readonly:""`
}
AuthorizeResponse is the URL a person signs in at, to authorize the connector's server
type Connector ¶
type Connector struct {
Name string `` /* 227-byte string literal not displayed */
ConnectorMeta
Serial uint64 `` /* 131-byte string literal not displayed */
// The status, which isn't stored
Connected bool `json:"connected,omitempty" readonly:"" help:"Whether the connector's server is connected"`
Server *ConnectorServer `json:"server,omitempty" readonly:"" help:"The connector's server, as it said, once it's connected"`
Error string `json:"error,omitempty" readonly:"" help:"Why the connector's server couldn't be connected, or its session ended"`
Namespace string `` /* 155-byte string literal not displayed */
Auth string `` /* 202-byte string literal not displayed */
Icon string `` /* 274-byte string literal not displayed */
}
Connector is a remote MCP server, as it's connected to: its name, its fields which can be set, and its serial, which changes each time its definition does, which are what's needed to create a client of its server, and what a store of connectors holds, and its status: whether its server is connected, and which server it is, when it is, or why it couldn't be connected, or its session ended, which isn't stored, as it's the process's
func (Connector) Definition ¶
Definition returns the connector without its status, which is what's stored
type ConnectorEvent ¶
type ConnectorEvent struct {
Serial uint64 `json:"serial" help:"The connector's serial"`
Server *ConnectorServer `json:"server,omitempty" help:"The connector's server, as it said, once it's connected"`
Error string `json:"error,omitempty" help:"Why the connector's server was disconnected, when it wasn't disconnected"`
Auth string `json:"auth,omitempty" help:"That its server needs to be authorized, which is required, as it couldn't be connected"`
}
ConnectorEvent is the data of an event of a connector: its serial, and, when its server was connected, which server it is, as it said, or, when it was disconnected, why, when it wasn't disconnected, such as when the server closed the session
type ConnectorList ¶
type ConnectorList struct {
Count uint `json:"count" help:"The number of connectors"`
Body []*Connector `json:"body,omitempty" help:"The connectors"`
}
ConnectorList is a list of connectors, in order of their names
func (ConnectorList) String ¶
func (l ConnectorList) String() string
type ConnectorMeta ¶
type ConnectorMeta struct {
URL string `` /* 136-byte string literal not displayed */
Include []string `` /* 199-byte string literal not displayed */
Exclude []string `` /* 163-byte string literal not displayed */
// The names of the credentials of the client its server is authorized
// as, when its authorization server doesn't register clients, such as
// GitHub's, which the credentials provider has, so the client's
// identifier, and secret, themselves, aren't kept
ClientIDCredential string `` /* 227-byte string literal not displayed */
ClientSecretCredential string `` /* 159-byte string literal not displayed */
}
ConnectorMeta are the fields of a connector which can be set
func (ConnectorMeta) Matcher ¶
func (m ConnectorMeta) Matcher() (func(string) bool, error)
Matcher returns the function which says whether the name of one of the server's tools, prompts or resources is included: it matches one of the include patterns, or there are none, and none of the exclude patterns. Returns ErrBadParameter when a pattern isn't a regular expression.
func (ConnectorMeta) String ¶
func (m ConnectorMeta) String() string
func (ConnectorMeta) Validate ¶
func (m ConnectorMeta) Validate() error
Validate returns ErrBadParameter when the URL isn't an http, or https, URL with a host, as an MCP server which runs as a command, over stdio, can't be connected to
type ConnectorServer ¶
type ConnectorServer struct {
Name string `json:"name" help:"The server's name" example:"github-mcp-server"`
Version string `json:"version,omitempty" help:"The server's version" example:"1.0.0"`
}
ConnectorServer is the name, and version, of a connector's server, as it said, once it's connected
type ConnectorTemplate ¶
type ConnectorTemplate struct {
Name string `json:"name" yaml:"name" help:"The server's name, such as GitHub" example:"GitHub"`
Description string `json:"description,omitempty" yaml:"description" help:"What the server does" optional:""`
URL string `` /* 138-byte string literal not displayed */
ClientIDCredential string `` /* 203-byte string literal not displayed */
ClientSecretCredential string `` /* 174-byte string literal not displayed */
Icon string `` /* 164-byte string literal not displayed */
}
ConnectorTemplate is a remote MCP server which a connector can be added for, without its URL being typed, such as GitHub's: its name, and URL, and the names of the credentials of the client it's signed in to with, when its sign-in doesn't register clients itself, which the server has, so it's offered
func (ConnectorTemplate) Meta ¶
func (t ConnectorTemplate) Meta() ConnectorMeta
Meta returns the fields of a connector of the template
func (ConnectorTemplate) Validate ¶
func (t ConnectorTemplate) Validate() error
Validate returns ErrBadParameter when the template has no name, as it's listed by it, or its URL, or the names of its credentials, aren't valid
type ConnectorTemplateList ¶
type ConnectorTemplateList struct {
Count uint `json:"count" help:"The number of templates"`
Body []*ConnectorTemplate `json:"body,omitempty" help:"The templates, in order of their names"`
}
ConnectorTemplateList is the templates of the connectors which can be added, and how many there are
type Credential ¶
type Credential struct {
URL string `json:"url"`
ClientCredential string `json:"client_credential,omitempty"`
Issuer string `json:"issuer"`
AuthorizationEndpoint string `json:"authorization_endpoint"`
TokenEndpoint string `json:"token_endpoint"`
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret,omitempty"`
RedirectURIs []string `json:"redirect_uris,omitempty"`
Resource string `json:"resource,omitempty"`
Scopes []string `json:"scopes,omitempty"`
Token *oauth2.Token `json:"token,omitempty"`
}
Credential is how a connector's server is authorized, which is stored, but isn't returned: the URL of the server it's for, its authorization server's endpoints, the client it registered, or the name of the credential of the connector's own client, whose identifier, and secret, aren't kept, the resource, and scopes, and the token, once it's signed in to, which is refreshed, as it expires