Skip to content

request_handlers

Class info

🛈 DocStrings

Codex app-server client.

create_auto_approve_dict

create_auto_approve_dict() -> dict[str, ServerRequestHandler]

Register default handlers that auto-approve all server requests.

Convenience method for non-interactive use cases where all approvals should be automatically granted and tool calls return empty results.

Source code in src/codexed/request_handlers.py
def create_auto_approve_dict() -> dict[str, ServerRequestHandler]:
    """Register default handlers that auto-approve all server requests.

    Convenience method for non-interactive use cases where all approvals
    should be automatically granted and tool calls return empty results.
    """

    async def auto_approve_command(
        _params: ServerRequestParams,
    ) -> ServerRequestResponse:
        return CommandExecutionRequestApprovalResponse(decision="allow")

    async def auto_approve_file_change(
        _params: ServerRequestParams,
    ) -> ServerRequestResponse:
        return FileChangeRequestApprovalResponse(decision="allow")

    async def auto_approve_user_input(
        _params: ServerRequestParams,
    ) -> ServerRequestResponse:
        return ToolRequestUserInputResponse(answers={})

    async def auto_approve_dynamic_tool(
        _params: ServerRequestParams,
    ) -> ServerRequestResponse:
        return DynamicToolCallResponse(content_items=[], success=False)

    async def auto_approve_skill(
        _params: ServerRequestParams,
    ) -> ServerRequestResponse:
        return SkillRequestApprovalResponse(decision="allow")

    async def auto_decline_elicitation(
        _params: ServerRequestParams,
    ) -> ServerRequestResponse:
        return McpServerElicitationResponse(action="decline")

    dct: dict[str, ServerRequestHandler] = {}
    dct[SERVER_REQUEST_COMMAND_APPROVAL] = auto_approve_command
    dct[SERVER_REQUEST_FILE_CHANGE_APPROVAL] = auto_approve_file_change
    dct[SERVER_REQUEST_USER_INPUT] = auto_approve_user_input
    dct[SERVER_REQUEST_DYNAMIC_TOOL_CALL] = auto_approve_dynamic_tool
    dct[SERVER_REQUEST_SKILL_APPROVAL] = auto_approve_skill
    dct[SERVER_REQUEST_MCP_ELICITATION] = auto_decline_elicitation
    return dct