Skip to content

StaticTokenAuthenticator

The default McpAuthenticatorInterface: a single shared secret from the mcp.auth_token setting.

A null/empty configured token always rejects — there is no “auth disabled by an empty token” footgun; use mcp.auth = 'none' to actually disable auth.

final class StaticTokenAuthenticator implements McpAuthenticatorInterface

ImplementsMcpAuthenticatorInterface
SourceAuth/StaticTokenAuthenticator.php

public function __construct(?string $expectedToken): mixed

ParameterTypeDescription
$expectedToken?``string

Returns mixed

MethodDescription
authenticate(string $token): boolCompares $token against the configured secret in constant time.

public function authenticate(string $token): bool

Compares $token against the configured secret in constant time.

Returns false whenever either the configured token or the presented one is null or empty, so a missing mcp.auth_token denies every request rather than accepting any.

ParameterTypeDescription
$tokenstring

Returns bool