Skip to main content
Glama

get_report_columns

Retrieve column structure for Frappe reports to understand data fields and customize views. Apply optional filters to focus on specific data subsets.

Instructions

    Get the column structure for a specific report.
    
    Args:
        report_name: Name of the report
        filters: Filter string (optional). Uses custom syntax to bypass MCP validation issues.
    
    Filter Syntax: Use the same string-based syntax as count_documents and list_documents.
    Examples: "status:Open", "date:>=:2025-01-01", "status:in:Open|Working"
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
report_nameYes
filtersNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'get_report_columns' tool. It fetches column structure for a Frappe report using the API, with fallback to metadata, and handles errors.
    @mcp.tool()
    async def get_report_columns(
        report_name: str,
        filters: Optional[str] = None
    ) -> str:
        """
        Get the column structure for a specific report.
        
        Args:
            report_name: Name of the report
            filters: Filter string (optional). Uses custom syntax to bypass MCP validation issues.
        
        Filter Syntax: Use the same string-based syntax as count_documents and list_documents.
        Examples: "status:Open", "date:>=:2025-01-01", "status:in:Open|Working"
        """
        try:
            client = get_client()
            
            # Get report columns using the report.get_columns method
            parsed_filters = format_filters_for_api(filters) or {}
            request_data = {
                "cmd": "frappe.desk.query_report.get_columns",
                "report_name": report_name,
                "filters": json.dumps(parsed_filters)
            }
            
            response = await client.post("api/method/frappe.desk.query_report.get_columns", json_data=request_data)
            
            if "message" in response:
                columns = response["message"]
                
                formatted_result = {
                    "report_name": report_name,
                    "columns": columns
                }
                
                return json.dumps(formatted_result, indent=2)
            else:
                # Fallback: get columns from report metadata
                meta_response = await client.get(f"api/resource/Report/{report_name}")
                if "data" in meta_response:
                    columns = meta_response["data"].get("columns", [])
                    return json.dumps({"report_name": report_name, "columns": columns}, indent=2)
                else:
                    return json.dumps(response, indent=2)
                
        except Exception as error:
            return _format_error_response(error, "get_report_columns")
  • The @mcp.tool() decorator registers the get_report_columns function as an MCP tool.
    @mcp.tool()
  • Input schema defined by function parameters with type hints: report_name (str, required), filters (Optional[str], optional). Output is str (JSON).
    async def get_report_columns(
        report_name: str,
        filters: Optional[str] = None
    ) -> str:
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses that filters use 'custom syntax to bypass MCP validation issues' and provides syntax examples, which adds valuable behavioral context. However, it doesn't mention authentication requirements, rate limits, or what happens with invalid report names.

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

Conciseness4/5

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

The description is well-structured with a clear purpose statement followed by parameter documentation and examples. Every sentence adds value, though the filter syntax explanation could be slightly more concise. It's appropriately sized for a tool with 2 parameters.

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

Completeness4/5

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

Given 2 parameters with 0% schema coverage and an output schema present, the description provides good coverage of input semantics and behavioral context. The presence of an output schema means the description doesn't need to explain return values, making it reasonably complete for this tool's complexity.

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?

Schema description coverage is 0%, so the description must compensate. It clearly explains both parameters: report_name ('Name of the report') and filters ('Filter string (optional)'), including detailed syntax examples and references to sibling tools. This adds significant meaning beyond the bare schema.

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

Purpose5/5

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

The description clearly states the verb ('Get') and resource ('column structure for a specific report'), making the purpose explicit. It distinguishes from siblings like get_report_meta (metadata) and run_doctype_report (executing reports), providing specific differentiation.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool (to retrieve column structure for reports) and references sibling tools (count_documents, list_documents) for filter syntax consistency. However, it doesn't explicitly state when NOT to use it or name direct alternatives like get_report_meta.

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

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/appliedrelevance/frappe-mcp-server'

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