Documentation
¶
Overview ¶
Package mcpexplore owns MCP explorer targets, transports, and client lifecycle.
Index ¶
- Constants
- func AliasTarget(alias string, environ []string) (Target, Server, error)
- func CommandEnvironment(environ []string) []string
- func NewCommand(name string, args ...string) *exec.Cmd
- func NewCommandContext(ctx context.Context, name string, args ...string) *exec.Cmd
- func NewHTTPClient(endpoint string) (*http.Client, error)
- func RegistryPath() (string, error)
- func RestrictedCommandEnvironment(environ, passEnv []string) []string
- func SaveRegistry(registry Registry) error
- func UpdateRegistry(update func(*Registry) error) error
- func ValidateAlias(alias string) error
- type Client
- func (c *Client) Call(ctx context.Context, name string, arguments map[string]any) (*protocol.CallToolResult, error)
- func (c *Client) Close() error
- func (c *Client) Discover(ctx context.Context) (*protocol.DiscoverResult, error)
- func (c *Client) Inspect(ctx context.Context, name string) (*protocol.Tool, error)
- func (c *Client) ListTools(ctx context.Context) ([]*protocol.Tool, error)
- type Registry
- type Server
- type Target
Constants ¶
const HTTPTokenEnv = "JINN_MCP_HTTP_TOKEN" //nolint:gosec // Environment variable name, not a credential.
HTTPTokenEnv is the only bearer-token source for HTTP explorer targets.
Variables ¶
This section is empty.
Functions ¶
func AliasTarget ¶
AliasTarget resolves a registered alias into a transport target and server definition.
func CommandEnvironment ¶
CommandEnvironment removes the HTTP bearer token before launching subprocesses.
func NewCommand ¶
NewCommand constructs a subprocess without a shell and strips the HTTP token.
func NewCommandContext ¶
NewCommandContext constructs an explicit-argv subprocess bound to ctx.
func NewHTTPClient ¶
NewHTTPClient authenticates same-origin requests and blocks cross-origin redirects.
func RegistryPath ¶
RegistryPath returns the user-only registry path without creating it.
func RestrictedCommandEnvironment ¶
RestrictedCommandEnvironment returns the registry subprocess environment.
func SaveRegistry ¶
SaveRegistry replaces a valid registry through a durable lock, backup, and rename.
func UpdateRegistry ¶
UpdateRegistry serializes a read-modify-write change. It never replaces a corrupt current registry.
func ValidateAlias ¶
ValidateAlias checks the public, case-sensitive registry alias contract.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client exposes the discovery-only MCP explorer operations.
func (*Client) Call ¶
func (c *Client) Call(ctx context.Context, name string, arguments map[string]any) (*protocol.CallToolResult, error)
Call invokes one MCP tool. Tool-level isError results are returned normally.
type Registry ¶
Registry is the strict versioned on-disk server registry.
func LoadRegistry ¶
LoadRegistry reads and validates the registry. exists is false for a missing file.
func (Registry) SortedAliases ¶
SortedAliases returns registered aliases in lexical order.
type Server ¶
type Server struct {
Transport string `json:"transport"`
URL string `json:"url,omitempty"`
TokenEnv string `json:"token_env,omitempty"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
PassEnv []string `json:"pass_env,omitempty"`
}
Server is one user-owned, shell-free MCP target.
type Target ¶
type Target struct {
Endpoint string
Command string
CommandArgs []string
TokenEnv string
CommandEnv []string
DisableDefaultToken bool
}
Target identifies either an HTTP MCP endpoint or an explicit-argv subprocess.
func TargetForServer ¶
TargetForServer converts one already-loaded registry server into a constrained target.