Documentation
¶
Overview ¶
Package mcp implements orb's bundled, settings-driven MCP extension. It is dormant when no enabled servers are configured and exposes remote tools only through the native extension API.
Index ¶
- Constants
- Variables
- func AddServer(path, name string, config ServerConfig) (bool, error)
- func Extension(agentDir string, supplied ...Entry) extensions.Factory
- func GlobalPath(agentDir string) string
- func Login(ctx context.Context, cwd, agentDir string, entry Entry, show func(string), ...) (tools int, already bool, err error)
- func Namespace(server string) string
- func ProjectPath(cwd string) string
- func RemoveCredentials(agentDir, name, serverURL string) (bool, error)
- func RemoveServer(path, name string) (bool, error)
- func ToolSearchExtension() extensions.Factory
- func Validate(name string, config *ServerConfig) error
- type Entry
- type Exposure
- type Manager
- func (manager *Manager) Close() error
- func (manager *Manager) Reconnect(ctx context.Context, name string) error
- func (manager *Manager) SignIn(ctx context.Context, name string, prompt signInPrompt) error
- func (manager *Manager) SignOut(name string) (bool, error)
- func (manager *Manager) Status() []ServerStatus
- type OAuthConfig
- type ProviderAuth
- type ServerConfig
- type ServerState
- type ServerStatus
- type ToolExposureRule
- type ToolExposures
Constants ¶
const (
// MCPServersSection is the system prompt section listing servers whose tools are not declared.
MCPServersSection = "mcp_servers"
)
const ToolSearchName = "tool_search"
ToolSearchName is the tool that loads deferred tools, such as MCP servers'.
Variables ¶
var ErrSignInCancelled = errSignInCancelled
ErrSignInCancelled reports a sign-in the user abandoned or did not finish in time.
Functions ¶
func AddServer ¶ added in v0.14.0
func AddServer(path, name string, config ServerConfig) (bool, error)
AddServer adds or replaces a server in an mcp.json, creating the file, and reports whether it replaced one.
func Extension ¶ added in v0.14.0
func Extension(agentDir string, supplied ...Entry) extensions.Factory
Extension is the MCP integration. When a session starts it reads mcp.json (the agent directory's, and the project's once trusted), adds the servers its client supplied, and connects them in the background.
func GlobalPath ¶ added in v0.14.0
GlobalPath and ProjectPath are the mcp.json files.
func Login ¶ added in v0.14.0
func Login(ctx context.Context, cwd, agentDir string, entry Entry, show func(string), paste func(context.Context) (string, error)) (tools int, already bool, err error)
Login signs a server in outside a session, unless it already accepts the stored credentials, and reports the tools it then offers. show receives the authorization URL; paste asks for the redirect URL and ends with ctx.
func Namespace ¶ added in v0.14.0
Namespace is the namespace of a server's tools: mcp__<server> with - as _.
func ProjectPath ¶ added in v0.14.0
func RemoveCredentials ¶ added in v0.14.0
RemoveCredentials deletes a server's stored OAuth credentials outside a session.
func RemoveServer ¶ added in v0.14.0
RemoveServer removes a server and reports whether the file defined it.
func ToolSearchExtension ¶ added in v0.14.0
func ToolSearchExtension() extensions.Factory
ToolSearchExtension registers tool_search inactive; the MCP integration activates it when servers have deferred tools. Loading a tool activates it, so the transcript records it and resume restores it.
func Validate ¶ added in v0.14.0
func Validate(name string, config *ServerConfig) error
Validate checks one server entry, aliases resolved, against the mcpServers shape.
Types ¶
type Entry ¶ added in v0.14.0
type Entry struct {
Name string
Config ServerConfig
// Source is the mcp.json that defines the entry; Scope is "global" or "project".
Source string
Scope string
}
Entry is a configured server and where it came from.
type Exposure ¶ added in v0.14.0
type Exposure string
Exposure is how the model reaches a server's tools:
- codemode (default): Orb has no codemode, so these are reached as deferred.
- deferred: declared once tool_search loads them, then called directly.
- direct: declared like built-in tools.
- hidden: registered but unreachable.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns all MCP client sessions for one coding-agent session.
func (*Manager) Reconnect ¶
Reconnect closes and recreates one server session. An empty name reconnects all enabled servers in name order.
func (*Manager) SignIn ¶ added in v0.14.0
SignIn signs a server in through the browser and reconnects it.
func (*Manager) SignOut ¶ added in v0.14.0
SignOut deletes a server's stored credentials and disconnects it; it reports whether there were any.
func (*Manager) Status ¶
func (manager *Manager) Status() []ServerStatus
type OAuthConfig ¶ added in v0.14.0
type OAuthConfig struct {
// ClientID is a pre-registered client; without it Orb registers one.
ClientID string `json:"clientId,omitempty"`
// ClientSecret may reference ${NAME} or !command.
ClientSecret string `json:"clientSecret,omitempty"`
// CallbackPort fixes the loopback port; without CallbackURL the redirect
// URI is http://127.0.0.1:<port>/callback.
CallbackPort int `json:"callbackPort,omitempty"`
// CallbackURL is the redirect URI registered for ClientID: http on
// localhost, 127.0.0.1 or [::1]; without a port, CallbackPort or a free one.
CallbackURL string `json:"callbackUrl,omitempty"`
// Scope is the space-separated scopes to request; default the advertised ones.
Scope string `json:"scope,omitempty"`
// ClientName is sent with dynamic client registration. Default: orb.
ClientName string `json:"clientName,omitempty"`
// AuthServerMetadataURL replaces discovery through the server; trusted as
// configured, https except on loopback hosts.
AuthServerMetadataURL string `json:"authServerMetadataUrl,omitempty"`
}
OAuthConfig configures OAuth for servers without dynamic client registration.
type ProviderAuth ¶ added in v0.14.0
type ProviderAuth struct {
Provider string `json:"provider"`
}
ProviderAuth sends the token of an `orb login` provider.
type ServerConfig ¶
type ServerConfig struct {
Type string `json:"type,omitempty"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
// CWD resolves relative paths against the session's working directory.
CWD string `json:"cwd,omitempty"`
URL string `json:"url,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
OAuth *OAuthConfig `json:"oauth,omitempty"`
Auth *ProviderAuth `json:"auth,omitempty"`
// Exposure defaults to codemode.
Exposure Exposure `json:"exposure,omitempty"`
// ToolExposure overrides Exposure for single tools, by the name the server
// offers or a pattern where * matches anything; an exact name wins, then
// the first matching pattern.
ToolExposure ToolExposures `json:"toolExposure,omitempty"`
// Description says what the server offers: the mcp_servers prompt section
// lists it and tool search ranks the server's tools by it.
Description string `json:"description,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
// Timeout is the per-request timeout in seconds; progress resets it. Default 60.
Timeout float64 `json:"timeout,omitempty"`
}
ServerConfig is one entry of mcpServers.
func (ServerConfig) ExposureOf ¶ added in v0.14.0
func (config ServerConfig) ExposureOf() Exposure
ExposureOf is a server's exposure, the default codemode when unset.
func (ServerConfig) IsEnabled ¶ added in v0.14.0
func (config ServerConfig) IsEnabled() bool
IsEnabled reports a server that connects; enabled false keeps the entry.
func (ServerConfig) IsHTTP ¶ added in v0.14.0
func (config ServerConfig) IsHTTP() bool
IsHTTP reports a streamable HTTP server.
func (ServerConfig) ToolExposureOf ¶ added in v0.14.0
func (config ServerConfig) ToolExposureOf(tool string) Exposure
ToolExposureOf is the exposure of one tool: its toolExposure entry, else the server's.
func (ServerConfig) UsesOAuth ¶ added in v0.14.0
func (config ServerConfig) UsesOAuth() bool
UsesOAuth reports a server that signs in with OAuth: HTTP without an Authorization header or auth.provider.
type ServerState ¶
type ServerState string
const ( ServerConnecting ServerState = "connecting" ServerConnected ServerState = "connected" ServerFailed ServerState = "failed" ServerNeedsAuth ServerState = "needs-auth" ServerDisabled ServerState = "disabled" ServerStopped ServerState = "stopped" )
type ServerStatus ¶
type ToolExposureRule ¶ added in v0.14.0
type ToolExposures ¶ added in v0.14.0
type ToolExposures []ToolExposureRule
ToolExposures keeps toolExposure's entries in file order, which decides among patterns.
func (ToolExposures) MarshalJSON ¶ added in v0.14.0
func (rules ToolExposures) MarshalJSON() ([]byte, error)
func (*ToolExposures) UnmarshalJSON ¶ added in v0.14.0
func (rules *ToolExposures) UnmarshalJSON(data []byte) error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cli is `orb mcp`: it configures and checks MCP servers and signs in to OAuth servers without starting a session.
|
Package cli is `orb mcp`: it configures and checks MCP servers and signs in to OAuth servers without starting a session. |
|
Package serve offers an Orb session's tools to another agent harness over MCP, the protocol harnesses take outside tools through.
|
Package serve offers an Orb session's tools to another agent harness over MCP, the protocol harnesses take outside tools through. |