Skip to main content
Glama

log_action

Records agent actions and reasoning steps for audit trails and compliance tracking in quantitative finance workflows.

Instructions

Logs an agent action or reasoning step for audit purposes.

Args:
    action_type: Category (e.g., 'REASONING', 'TRADE_DECISION', 'ERROR').
    details: Description of the action.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
action_typeYes
detailsYes

Implementation Reference

  • The core handler function for the 'log_action' tool. It takes action_type and details, logs them formatted to the logger, and returns a success message. The function signature and docstring provide the input schema.
    def log_action(action_type: str, details: str) -> str:
        """
        Logs an agent action or reasoning step for audit purposes.
        
        Args:
            action_type: Category (e.g., 'REASONING', 'TRADE_DECISION', 'ERROR').
            details: Description of the action.
        """
        # Clean up details to remove excessive newlines or emojis if needed
        clean_details = details.strip()
        logger.info(f"[{action_type.upper()}] {clean_details}")
        return "Action logged successfully."
  • server.py:400-403 (registration)
    Registers the log_action function as an MCP tool by calling register_tools, which dynamically applies the @mcp.tool() decorator from FastMCP.
    register_tools(
        [log_action],
        "Logging"
    )
  • Helper function used to register MCP tools, including log_action, by applying the FastMCP decorator and logging the process.
    def register_tools(tools: List[Callable], category: str):
        """Helper to register multiple tools with logging."""
        for tool in tools:
            try:
                mcp.tool()(tool)
                logger.info(f"Registered {category} tool: {tool.__name__}")
            except Exception as e:
                logger.error(f"Failed to register {tool.__name__}: {e}")
                raise
  • app.py:312-313 (registration)
    Includes log_action in the tools_map dictionary used to generate Gradio interfaces for the tool, which are exposed via MCP when mcp_server=True.
        "Utils": [log_action],
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/N-lia/MonteWalk'

If you have feedback or need assistance with the MCP directory API, please join our Discord server