Documentation
¶
Overview ¶
Package mcp exposes a subset of Authorizer's gRPC methods as MCP tools. Which methods are exposed is declared at the proto layer via the custom option `authorizer.v1.mcp_tool` — the scanner reads it at startup to build the tool registry. No service-by-service hand-registration.
Package mcp serves a curated subset of Authorizer's gRPC methods to LLM clients via the Model Context Protocol. Stdio is the ONLY supported transport — see the deliberate design note on Server below.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Name is the MCP server's reported implementation name.
Name string
// Version is the MCP server's reported implementation version.
Version string
// Bearer, when set, is propagated as `Authorization: Bearer <value>`
// metadata on every gRPC dispatch. This is how MCP-side identity
// reaches the gRPC handlers (security audit H1). The bearer should be
// a token issued for the user the MCP host is acting on behalf of.
Bearer string
// AuthorizerURL, when set, is propagated as `x-authorizer-url` metadata
// on every gRPC dispatch so JWT issuer validation resolves the host the
// bearer token was minted by (not the in-process "bufconn" authority).
// Required for identity-bearing tools when Bearer is set.
AuthorizerURL string
}
Options configures the MCP server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps an MCP server that bridges to an in-process gRPC server.
Design constraint: stdio is the ONLY supported transport. The MCP server has no auth/rate-limit/audit interceptors of its own — it relies entirely on the OS-level trust boundary of the subprocess (Claude Code spawns `authorizer mcp` as a child; only that process can write to its stdin). Exposing the MCP server over TCP / HTTP / SSE would invalidate that assumption and is intentionally NOT implementable: there is no RunHTTP / RunTCP / RunSSE method, and adding one without first implementing an auth layer is a security regression. The stdio-only contract is also enforced by TestServer_StdioOnly.
func New ¶
New builds an MCP server that exposes every gRPC method on `grpcSrv` whose proto annotation has `(authorizer.v1.mcp_tool).exposed = true`. The gRPC server is served over an in-process bufconn — same pattern as the REST gateway — so MCP tool invocations become local method calls with no extra network hop.
func (*Server) MCPServer ¶
MCPServer exposes the underlying *mcp.Server. Used by tests to drive the server with an in-memory transport pair.
type ToolBinding ¶
type ToolBinding struct {
// Name surfaced to MCP clients (e.g. "get_meta"). Defaults to
// snake_case(method) unless the proto annotation overrides it.
Name string
// Description from the RPC's leading comment, surfaced to the MCP host.
Description string
// Destructive hints to the MCP host that user confirmation is warranted.
Destructive bool
// FullMethod is the gRPC method name in `/pkg.Service/Method` form.
// Used directly with grpc.ClientConn.Invoke.
FullMethod string
// InputDescriptor / OutputDescriptor are the proto message descriptors
// for request/response. Used by the dispatcher to construct dynamic
// proto.Message instances for JSON unmarshalling/marshalling.
InputDescriptor protoreflect.MessageDescriptor
OutputDescriptor protoreflect.MessageDescriptor
}
ToolBinding is one MCP-exposed RPC: a tool name, plus enough metadata to dispatch a JSON-arg invocation back to the gRPC server.