src.marcus_mcp.audit module#

Enhanced audit logging for Marcus MCP.

Provides comprehensive logging of all client actions for debugging, compliance, and usage analytics.

class src.marcus_mcp.audit.AuditLogger[source]#

Bases: object

Handles audit logging for Marcus operations.

__init__(log_dir=None)[source]#

Initialize the audit logger.

Parameters:

log_dir (Optional[Path]) – Directory for audit logs. Defaults to data/audit_logs/

async log_event(event_type, client_id, client_type, tool_name, details, success=True, error=None)[source]#

Log an audit event.

Parameters:
  • event_type (str) – Type of event (e.g., “tool_call”, “registration”, “error”)

  • client_id (Optional[str]) – ID of the client performing the action

  • client_type (Optional[str]) – Type of client (observer, developer, agent, admin)

  • tool_name (Optional[str]) – Name of the tool being called

  • details (Dict[str, Any]) – Additional event details

  • success (bool) – Whether the operation succeeded

  • error (Optional[str]) – Error message if operation failed

Return type:

None

async log_registration(client_id, client_type, role, metadata=None)[source]#

Log a client registration event.

Return type:

None

Parameters:
async log_tool_call(client_id, client_type, tool_name, arguments, result, duration_ms, success=True, error=None)[source]#

Log a tool call event.

Return type:

None

Parameters:
async log_access_denied(client_id, client_type, tool_name, reason, duration_ms=None)[source]#

Log an access denied event.

Return type:

None

Parameters:
  • client_id (str | None)

  • client_type (str | None)

  • tool_name (str)

  • reason (str)

  • duration_ms (float | None)

async log_session(event_type, session_id, transport, client_id=None, metadata=None)[source]#

Log session lifecycle events.

Return type:

None

Parameters:
async get_usage_stats(start_date=None, end_date=None)[source]#

Generate usage statistics from audit logs.

Parameters:
Returns:

Usage statistics

Return type:

Dict[str, Any]

src.marcus_mcp.audit.get_audit_logger()[source]#

Get the global audit logger instance.

Return type:

AuditLogger