mcp

package
v0.149.3 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package mcp exposes a roost's privileged tools as a role-scoped MCP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OriginAllowed

func OriginAllowed(r *http.Request) bool

Native MCP clients omit Origin. Browser-originated requests must be same-host to prevent DNS rebinding; reverse proxies preserve the external Host header.

Types

type CallEnvFunc

type CallEnvFunc func(*http.Request) map[string]string

CallEnvFunc supplies trusted per-request identity variables to the privileged tool process.

type CallObserver

type CallObserver func(*http.Request, string, []string, egg.ToolResponse)

CallObserver receives allowed and denied tool-call attempts for centralized auditing.

type NativeCallObserver added in v0.144.0

type NativeCallObserver func(*http.Request, string, json.RawMessage, map[string]any, bool)

NativeCallObserver receives the exact typed call envelope for audit logging.

type NativeTool added in v0.144.0

type NativeTool struct {
	Name        string
	Title       string
	Description string
	InputSchema map[string]any
	Annotations map[string]any
	Call        func(context.Context, Principal, json.RawMessage) (map[string]any, bool, error)
}

NativeTool is a typed in-process MCP operation. Native tools are available to authenticated roost users independently of role-scoped executable tools.

type Policy

type Policy = config.MCPConfig

Policy aliases the wing.yaml MCP configuration used by the protocol adapter.

type Principal added in v0.144.0

type Principal struct {
	UserID   string
	Email    string
	ClientID string
	Roles    []string
}

Principal is the authenticated identity supplied to built-in control tools. UserID owns created resources. ClientID identifies the acting MCP client.

type PrincipalFunc added in v0.144.0

type PrincipalFunc func(*http.Request) Principal

PrincipalFunc resolves the authenticated caller from a request.

type RolePolicy

type RolePolicy = config.MCPRoleConfig

RolePolicy aliases one role in the wing.yaml MCP configuration.

type RolesFunc

type RolesFunc func(*http.Request) []string

RolesFunc resolves all caller roles from the request. Disabled roles contribute no access; tools allowed by any enabled role are included in the caller's maximum subset.

type Server

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

Server is an MCP-over-HTTP (Streamable HTTP) endpoint over a shared ToolRunner, gated by a per-role Policy.

func NewServer

func NewServer(runner *egg.ToolRunner, policy *Policy, rolesOf RolesFunc) *Server

func (*Server) HasNativeTools added in v0.144.0

func (s *Server) HasNativeTools() bool

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles a single JSON-RPC request per POST (stateless Streamable HTTP).

func (*Server) SetCallEnv

func (s *Server) SetCallEnv(callEnv CallEnvFunc)

func (*Server) SetCallObserver

func (s *Server) SetCallObserver(observer CallObserver)

func (*Server) SetNativeCallObserver added in v0.144.0

func (s *Server) SetNativeCallObserver(observer NativeCallObserver)

func (*Server) SetNativeTools added in v0.144.0

func (s *Server) SetNativeTools(tools []NativeTool, principalOf PrincipalFunc)

Jump to

Keyboard shortcuts

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