Skip to main content
Glama
apache

Doris MCP Server

Official
by apache

get_recent_audit_logs

Retrieve audit log records for a specified recent period, defaulting to the last 7 days and up to 100 records. Customize days and limit parameters for targeted log analysis.

Instructions

[Function Description]: Get audit log records for a recent period.

[Parameter Content]:

  • days (integer) [Optional] - Number of recent days of logs to retrieve, default is 7

  • limit (integer) [Optional] - Maximum number of records to return, default is 100

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNo
limitNo

Implementation Reference

  • Primary handler for the get_recent_audit_logs tool. Retrieves audit logs using async helper, converts to JSON, serializes datetimes, and formats MCP response.
    async def get_recent_audit_logs_for_mcp(self, days: int = 7, limit: int = 100) -> Dict[str, Any]:
        """Get recent audit log records - MCP interface"""
        logger.info(f"Getting audit logs: Days: {days}, Limit: {limit}")
        
        try:
            logs_df = await self.get_recent_audit_logs_async(days=days, limit=limit)
            
            # Convert DataFrame to JSON format
            if hasattr(logs_df, 'to_dict'):
                try:
                    logs_data = logs_df.to_dict('records')
                except Exception as e:
                    logger.warning(f"DataFrame.to_dict failed, trying manual conversion: {e}")
                    # Manually convert DataFrame to records format
                    logs_data = []
                    if not logs_df.empty:
                        for _, row in logs_df.iterrows():
                            logs_data.append(dict(row))
                # Serialize datetime objects
                logs_data = self._serialize_datetime_objects(logs_data)
            else:
                logs_data = self._serialize_datetime_objects(logs_df)
                
            return self._format_response(success=True, result=logs_data)
        except Exception as e:
            logger.error(f"Failed to get audit logs: {str(e)}", exc_info=True)
            return self._format_response(success=False, error=str(e), message="Error occurred while getting audit logs")
  • Helper function that executes the SQL query to fetch recent successful audit logs from __internal_schema.audit_log table, filtering non-trivial statements.
    async def get_recent_audit_logs_async(self, days: int = 7, limit: int = 100):
        """Async version: get recent audit logs and return a pandas DataFrame."""
        try:
            start_date = (datetime.now() - timedelta(days=days)).strftime('%Y-%m-%d')
            query = f"""
            SELECT client_ip, user, db, time, stmt_id, stmt, state, error_code
            FROM `__internal_schema`.`audit_log`
            WHERE `time` >= '{start_date}'
            AND state = 'EOF' AND error_code = 0
            AND `stmt` NOT LIKE 'SHOW%'
            AND `stmt` NOT LIKE 'DESC%'
            AND `stmt` NOT LIKE 'EXPLAIN%'
            AND `stmt` NOT LIKE 'SELECT 1%'
            ORDER BY time DESC
            LIMIT {limit}
            """
            rows = await self._execute_query_async(query)
            import pandas as pd
            return pd.DataFrame(rows or [])
        except Exception as e:
            logger.error(f"Error getting audit logs asynchronously: {str(e)}")
            import pandas as pd
            return pd.DataFrame()
  • MCP tool registration decorator defining the tool name, description, parameters (schema), and wrapper function that delegates to internal call_tool.
            @mcp.tool(
                "get_recent_audit_logs",
                description="""[Function Description]: Get audit log records for a recent period.
    
    [Parameter Content]:
    
    - days (integer) [Optional] - Number of recent days of logs to retrieve, default is 7
    
    - limit (integer) [Optional] - Maximum number of records to return, default is 100
    """,
            )
            async def get_recent_audit_logs_tool(
                days: int = 7, limit: int = 100
            ) -> str:
                """Get audit logs"""
                return await self.call_tool("get_recent_audit_logs", {
                    "days": days,
                    "limit": limit
                })
  • Tool manager routing handler that extracts parameters and delegates to MetadataExtractor.get_recent_audit_logs_for_mcp.
    async def _get_recent_audit_logs_tool(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
        """Get audit logs tool routing"""
        days = arguments.get("days", 7)
        limit = arguments.get("limit", 100)
        
        # Delegate to metadata extractor for processing
        return await self.metadata_extractor.get_recent_audit_logs_for_mcp(days, limit)
  • Explicit input schema definition for the tool in list_tools method (for stdio mode), matching the decorator parameters.
                Tool(
                    name="get_recent_audit_logs",
                    description="""[Function Description]: Get audit log records for a recent period.
    
    [Parameter Content]:
    
    - days (integer) [Optional] - Number of recent days of logs to retrieve, default is 7
    
    - limit (integer) [Optional] - Maximum number of records to return, default is 100
    """,
                    inputSchema={
                        "type": "object",
                        "properties": {
                            "days": {"type": "integer", "description": "Number of recent days", "default": 7},
                            "limit": {"type": "integer", "description": "Maximum number of records", "default": 100},
                        },
                    },
                ),
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions retrieving logs for a 'recent period' with defaults, but doesn't cover critical aspects like whether this requires specific permissions, what format the logs are returned in, if there are rate limits, or how the tool handles errors. For a read operation with zero annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description uses a structured format with sections, which is helpful, but includes redundant labeling like '[Function Description]' and '[Parameter Content]' that add little value. The content itself is reasonably concise, but the formatting could be more streamlined without sacrificing clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 2 parameters, no annotations, and no output schema, the description is incomplete. It covers basic parameter semantics but lacks information about return format, error handling, authentication requirements, and how it differs from sibling tools. Given the complexity of audit logs and the absence of structured metadata, more contextual guidance is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description provides meaningful semantic context for both parameters ('days' as 'Number of recent days of logs to retrieve' and 'limit' as 'Maximum number of records to return'), including their defaults. With 0% schema description coverage, this fully compensates by explaining what each parameter controls beyond just their types, though it doesn't specify constraints like minimum/maximum values.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('audit log records for a recent period'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'exec_query' or 'get_db_list', which could also potentially retrieve audit data, so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'exec_query' for custom queries or other sibling tools for database metadata. It only describes what the tool does, not when it's the appropriate choice, leaving the agent to infer usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/apache/doris-mcp-server'

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