MCP client example using MultiProtocolAuthProvider with API Key and Mutual TLS (placeholder).
- Uses
MultiProtocolAuthProviderand protocol selection from server discovery (PRM / WWW-Authenticate). - API Key: reads key from env
MCP_API_KEY(defaultdemo-api-key-12345), sendsX-API-Keyheader. - Mutual TLS: placeholder only; when selected, prints a message and exits (no client cert in this example).
- Start the multi-protocol resource server (e.g.
simple-auth-multiprotocolon port 8002). - From this directory:
uv run mcp-simple-auth-multiprotocol-clientoruv run python -m mcp_simple_auth_multiprotocol_client. - Optional:
MCP_SERVER_URL=http://localhost:8002/mcpto override server URL.
When the server supports API Key (e.g. simple-auth-multiprotocol with --api-keys), set:
MCP_API_KEY– your API key (e.g.demo-api-key-12345). The client sends it asX-API-Key.MCP_SERVER_URL– optional; default ishttp://localhost:8002/mcpwhen using the default client config.
Example (server on port 8002, no OAuth/AS required):
MCP_SERVER_URL=http://localhost:8002/mcp MCP_API_KEY=demo-api-key-12345 uv run mcp-simple-auth-multiprotocol-clientOne-command test from repo root:
./examples/clients/simple-auth-multiprotocol-client/run_multiprotocol_test.sh
starts the resource server and this client with API Key; at mcp> run list, call get_time {}, quit.
When the server has DPoP enabled (--dpop-enabled), use OAuth and DPoP together:
MCP_USE_OAUTH=1– enable OAuth (required for DPoP).MCP_DPOP_ENABLED=1– send DPoP-bound access tokens (DPoP proof in each request).
Example (server on port 8002 with DPoP, AS on 9000):
MCP_SERVER_URL=http://localhost:8002/mcp MCP_USE_OAUTH=1 MCP_DPOP_ENABLED=1 uv run mcp-simple-auth-multiprotocol-clientComplete OAuth in the browser; then at mcp> run list, call get_time {}, quit. Server logs should show "Authentication successful with DPoP".
One-command test from repo root:
./examples/clients/simple-auth-multiprotocol-client/run_dpop_test.sh — starts AS and RS with DPoP, then runs this client (OAuth+DPoP). Use MCP_SKIP_OAUTH=1 to run only the automated curl tests and skip the manual client step.
Mutual TLS is a placeholder in this example: the client registers the mutual_tls protocol but does not perform client certificate authentication. Selecting mTLS will show a "not implemented" style message.
MCP_AUTH_PROTOCOL=mutual_tlsruns this client in mTLS mode; the client will start but mTLS auth is not implemented.
One-command test from repo root:
MCP_AUTH_PROTOCOL=mutual_tls ./examples/clients/simple-auth-multiprotocol-client/run_multiprotocol_test.sh
list– list toolscall get_time– callget_timequit– exit