Help us shape the future of Go! Take the 2026 Go Developer Survey

mcpserver

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package mcpserver mounts the MCP surface at /mcp (ADR 0016). It is a projection of the external /api contract, not a second implementation: tools are generated from the embedded OpenAPI document and each call is dispatched in-process through the same ogen server with the caller's own Bearer token, so workspace scoping, token scopes, validation and RFC 7807 errors are the /api ones by construction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(spec []byte, api http.Handler, auth Authenticator, opts ...Option) (http.Handler, error)

New builds the /mcp http.Handler: Streamable HTTP, stateless, one tool per non-hidden operation of the OpenAPI spec. api is the external API handler serving under /api; auth validates the connecting Bearer token.

With WithResourceMetadataURL, 401 responses carry a WWW-Authenticate challenge pointing OAuth clients (claude.ai connectors) at the protected resource metadata.

Types

type Authenticator

type Authenticator interface {
	HandleBearerAuth(ctx context.Context, op externalapi.OperationName, t externalapi.BearerAuth) (context.Context, error)
}

Authenticator validates a Bearer API token (the external API's security handler).

type Option

type Option func(*options)

Option configures New.

func WithResourceMetadataURL

func WithResourceMetadataURL(u string) Option

WithResourceMetadataURL advertises the RFC 9728 protected resource metadata URL in the WWW-Authenticate header of 401 responses (MCP authorization spec).

Jump to

Keyboard shortcuts

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