api

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package api provides HTTP routing configuration for the MCP server.

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module("api",
	fx.Provide(NewAllowedOrigins),
	fx.Provide(fx.Annotate(
		NewRouter,
		fx.ResultTags(`name:"mcp"`),
	)),
)

Module provides the HTTP router with the MCP handler mounted at /mcp.

Functions

func NewRouter

func NewRouter(params RouterParams) http.Handler

NewRouter constructs an HTTP router that mounts the MCP handler at /mcp with the full middleware stack applied, and registers OAuth endpoints.

Types

type AllowedOrigins

type AllowedOrigins []string

AllowedOrigins is the parsed and validated list of full origin URLs allowed for CORS.

func NewAllowedOrigins

func NewAllowedOrigins(raw RawAllowedOrigins) (AllowedOrigins, error)

NewAllowedOrigins parses and validates a RawAllowedOrigins value into an AllowedOrigins list. It splits by comma, trims whitespace, drops empty entries, and validates each entry is a full origin URL with scheme and host (e.g., http://localhost:3000).

type RawAllowedOrigins

type RawAllowedOrigins string

RawAllowedOrigins is the raw comma-separated flag value for allowed CORS origins, injected from main.go via DI.

type RouterParams

type RouterParams struct {
	fx.In

	MCPHandler                  http.Handler `name:"mcp-raw"`
	Origins                     AllowedOrigins
	AuthHandler                 *rest.Handler
	AuthorizationServerMetadata *appauth.AuthorizationServerMetadata
	ProtectedResourceMetadata   *oauthex.ProtectedResourceMetadata
	TokenVerifier               auth.TokenVerifier
	Issuer                      appauth.Issuer
}

RouterParams holds the DI-injected dependencies for the HTTP router.

Directories

Path Synopsis
Package rest provides OAuth 2.1 HTTP handlers for the MCP server.
Package rest provides OAuth 2.1 HTTP handlers for the MCP server.

Jump to

Keyboard shortcuts

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