Documentation
¶
Overview ¶
Package auth provides ready-made [mcpx.AuthFunc] implementations for the two most common authentication shapes carried in [mcpx.ServerConfig.Auth].
- Bearer — for {"auth": {"token": "..."}}; sets Authorization: Bearer <token>.
- HeaderToken — for {"auth": {"tokenName": "X-MCP-AUTH", "value": "..."}}; sets the named header verbatim, no Bearer prefix.
Pass the helper directly to [mcpx.WithAuthFunc]:
import (
mcpx "github.com/inhuman/mcp-multiplexer"
"github.com/inhuman/mcp-multiplexer/auth"
)
mx, err := mcpx.New(ctx, cfg, mcpx.WithAuthFunc(auth.Bearer))
For multi-scheme dispatch (mixing schemes per server) write your own [mcpx.AuthFunc] that switches on data["scheme"] and delegates to one of the helpers.
The package depends only on the standard library and the parent module — importing it does not pull additional third-party dependencies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bearer ¶
Bearer reads data["token"] (string) and sets `Authorization: Bearer <token>` on the request.
Expected JSON shape inside [mcpx.ServerConfig.Auth]:
{"auth": {"token": "..."}}
Returns an error if data["token"] is missing, not a string, or empty.
Compatible with [mcpx.AuthFunc]:
mcpx.New(ctx, cfg, mcpx.WithAuthFunc(auth.Bearer))
func HeaderToken ¶
HeaderToken reads data["tokenName"] (header name, string) and data["value"] (raw token, string) and sets that header on the request verbatim — no `Bearer ` prefix.
Expected JSON shape inside [mcpx.ServerConfig.Auth]:
{"auth": {"tokenName": "X-MCP-AUTH", "value": "..."}}
Returns an error if any required key is missing, not a string, or empty.
Compatible with [mcpx.AuthFunc]:
mcpx.New(ctx, cfg, mcpx.WithAuthFunc(auth.HeaderToken))
Types ¶
This section is empty.