Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xSteph Pentest ai MCP Auth Cache

From Leeroopedia
Knowledge Sources
Domains MCP, Caching, Authentication
Last Updated 2026-10-23 00:00 GMT

Overview

Concrete tool for process-local caching of resolved auth credentials keyed by engagement, provided by the pentest-ai MCP server.

Description

The mcp_server.auth_cache module provides a simple process-local dict cache for resolved auth credentials. When start_engagement resolves an auth_profile, it stashes the captured_auth dict here so later http_request and run_probe calls can reuse the same session without re-running the login flow. Lost on MCP-server restart; callers fall back to passing auth_profile explicitly per call.

Usage

Import this module when you need to cache or retrieve engagement auth in the MCP server. Used by the MCP server's start_engagement, run_probe, and http_request tools.

Code Reference

Source Location

Signature

def set_engagement_auth(engagement_id: str, captured_auth: dict[str, Any] | None) -> None: ...
def get_engagement_auth(engagement_id: str) -> dict[str, Any] | None: ...
def clear_engagement_auth(engagement_id: str) -> None: ...

Import

from mcp_server.auth_cache import set_engagement_auth, get_engagement_auth, clear_engagement_auth

I/O Contract

Inputs

Name Type Required Description
engagement_id str Yes Engagement UUID key
captured_auth None Yes (set) Auth dict to cache

Outputs

Name Type Description
cached auth None Cached auth dict or None if not set

Usage Examples

Cache and Retrieve Auth

from mcp_server.auth_cache import set_engagement_auth, get_engagement_auth

# Cache auth after login
set_engagement_auth("eng-abc-123", {"token": "Bearer xyz", "kind": "bearer"})

# Retrieve for later probes
auth = get_engagement_auth("eng-abc-123")
if auth:
    print(f"Using cached {auth['kind']} auth")

# Clear on engagement end
clear_engagement_auth("eng-abc-123")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment