Implementation:0xSteph Pentest ai MCP Auth Bridge
| Knowledge Sources | |
|---|---|
| Domains | MCP, Authentication, Credential_Bridge |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Concrete tool for bridging MCP-facing credential shapes to internal auth types the WebAgent and probe registry expect, provided by the pentest-ai MCP server.
Description
The mcp_server.auth module provides three thin helpers that bridge between MCP-facing credential shapes and internal types: resolve_auth_profile_to_dict resolves an auth profile name to a free-form dict, resolve_auth_to_credentials converts a dict to AuthCredentials, and credentials_to_captured_auth converts AuthCredentials to the captured_auth dict shape that registry probes consume. Extracted from server.py in 0.13.0 cleanup.
Usage
Import these helpers when you need to resolve MCP-provided auth credentials for probes. Used by the MCP server's run_probe and http_request tools.
Code Reference
Source Location
- Repository: 0xSteph_Pentest_ai
- File: mcp_server/auth.py
- Lines: 1-197
Signature
def credentials_to_captured_auth(creds: Any) -> dict[str, Any] | None: ...
def resolve_auth_to_credentials(auth: dict[str, Any] | None) -> Any: ...
def resolve_auth_profile_to_dict(profile_name: str) -> dict[str, Any] | None: ...
Import
from mcp_server.auth import credentials_to_captured_auth, resolve_auth_to_credentials, resolve_auth_profile_to_dict
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| creds | AuthCredentials | Yes | Auth credentials with bearer_token or cookies |
| auth | None | Free-form auth dict from MCP | |
| profile_name | str | Yes | Auth profile name to resolve |
Outputs
| Name | Type | Description |
|---|---|---|
| captured_auth | None | Dict for probe auth runner, or None if no usable auth |
Usage Examples
Resolve Auth for Probes
from mcp_server.auth import resolve_auth_profile_to_dict, resolve_auth_to_credentials, credentials_to_captured_auth
# Resolve a named profile
auth_dict = resolve_auth_profile_to_dict("juice-shop")
# Convert to AuthCredentials
creds = resolve_auth_to_credentials(auth_dict)
# Convert to captured_auth for probes
captured = credentials_to_captured_auth(creds)
# {"token": "...", "kind": "bearer", "auth_header": "Authorization", ...}