Skip to main content
Glama

run_report

Execute ERPNext reports to extract business data with optional filters for analysis and decision-making.

Instructions

Run an ERPNext report

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
report_nameYesName of the report
filtersNoReport filters (optional)

Implementation Reference

  • MCP tool call handler for 'run_report': checks authentication, extracts report_name and optional filters from arguments, calls erpnext.runReport, returns JSON result or error message.
    case "run_report": {
      if (!erpnext.isAuthenticated()) {
        return {
          content: [{
            type: "text",
            text: "Not authenticated with ERPNext. Please configure API key authentication."
          }],
          isError: true
        };
      }
      
      const reportName = String(request.params.arguments?.report_name);
      const filters = request.params.arguments?.filters as Record<string, any> | undefined;
      
      if (!reportName) {
        throw new McpError(
          ErrorCode.InvalidParams,
          "Report name is required"
        );
      }
      
      try {
        const result = await erpnext.runReport(reportName, filters);
        return {
          content: [{
            type: "text",
            text: JSON.stringify(result, null, 2)
          }]
        };
      } catch (error: any) {
        return {
          content: [{
            type: "text",
            text: `Failed to run report ${reportName}: ${error?.message || 'Unknown error'}`
          }],
          isError: true
        };
      }
    }
  • Input schema for the 'run_report' tool, defining report_name as required string and optional filters object.
    {
      name: "run_report",
      description: "Run an ERPNext report",
      inputSchema: {
        type: "object",
        properties: {
          report_name: {
            type: "string",
            description: "Name of the report"
          },
          filters: {
            type: "object",
            additionalProperties: true,
            description: "Report filters (optional)"
          }
        },
        required: ["report_name"]
      }
    }
  • src/index.ts:324-442 (registration)
    Registration of the 'run_report' tool via the ListToolsRequest handler, which includes its name, description, and input schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "get_doctypes",
            description: "Get a list of all available DocTypes",
            inputSchema: {
              type: "object",
              properties: {}
            }
          },
          {
            name: "get_doctype_fields",
            description: "Get fields list for a specific DocType",
            inputSchema: {
              type: "object",
              properties: {
                doctype: {
                  type: "string",
                  description: "ERPNext DocType (e.g., Customer, Item)"
                }
              },
                required: ["doctype"]
            }
          },
          {
            name: "get_documents",
            description: "Get a list of documents for a specific doctype",
            inputSchema: {
              type: "object",
              properties: {
                doctype: {
                  type: "string",
                  description: "ERPNext DocType (e.g., Customer, Item)"
                },
                fields: {
                  type: "array",
                  items: {
                    type: "string"
                  },
                  description: "Fields to include (optional)"
                },
                filters: {
                  type: "object",
                  additionalProperties: true,
                  description: "Filters in the format {field: value} (optional)"
                },
                limit: {
                  type: "number",
                  description: "Maximum number of documents to return (optional)"
                }
              },
              required: ["doctype"]
            }
          },
          {
            name: "create_document",
            description: "Create a new document in ERPNext",
            inputSchema: {
              type: "object",
              properties: {
                doctype: {
                  type: "string",
                  description: "ERPNext DocType (e.g., Customer, Item)"
                },
                data: {
                  type: "object",
                  additionalProperties: true,
                  description: "Document data"
                }
              },
              required: ["doctype", "data"]
            }
          },
          {
            name: "update_document",
            description: "Update an existing document in ERPNext",
            inputSchema: {
              type: "object",
              properties: {
                doctype: {
                  type: "string",
                  description: "ERPNext DocType (e.g., Customer, Item)"
                },
                name: {
                  type: "string",
                  description: "Document name/ID"
                },
                data: {
                  type: "object",
                  additionalProperties: true,
                  description: "Document data to update"
                }
              },
              required: ["doctype", "name", "data"]
            }
          },
          {
            name: "run_report",
            description: "Run an ERPNext report",
            inputSchema: {
              type: "object",
              properties: {
                report_name: {
                  type: "string",
                  description: "Name of the report"
                },
                filters: {
                  type: "object",
                  additionalProperties: true,
                  description: "Report filters (optional)"
                }
              },
              required: ["report_name"]
            }
          }
        ]
      };
    });
  • ERPNextClient.runReport helper method that performs the actual API call to ERPNext's frappe.desk.query_report.run endpoint with report_name and filters.
    // Run a report
    async runReport(reportName: string, filters?: Record<string, any>): Promise<any> {
      try {
        const response = await this.axiosInstance.get(`/api/method/frappe.desk.query_report.run`, {
          params: {
            report_name: reportName,
            filters: filters ? JSON.stringify(filters) : undefined
          }
        });
        return response.data.message;
      } catch (error: any) {
        throw new Error(`Failed to run report ${reportName}: ${error?.message || 'Unknown error'}`);
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Run an ERPNext report' implies an action but does not specify whether it's read-only, destructive, requires authentication, has rate limits, or what the output entails (e.g., data, file, or status). This leaves critical behavioral traits undisclosed, making it inadequate for a tool with potential complexity.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero waste. It is front-loaded and appropriately sized for the tool's apparent scope, avoiding unnecessary elaboration. Every word earns its place, making it highly concise and well-structured.

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?

Given the complexity of running reports (which may involve data processing, permissions, or output generation), the description is incomplete. No annotations or output schema exist to clarify behavior or results, and the description does not address these gaps. For a tool with potential side effects or rich outputs, this minimal description is insufficient for effective use.

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

Parameters3/5

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

The input schema has 100% description coverage, documenting both parameters ('report_name' and 'filters') clearly. The description adds no additional meaning beyond the schema, such as examples of report names or filter formats. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description neither compensates nor detracts.

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

Purpose3/5

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

The description 'Run an ERPNext report' states the action ('Run') and resource ('ERPNext report'), providing a basic purpose. However, it lacks specificity about what 'run' entails (e.g., execute, generate, or retrieve results) and does not differentiate from sibling tools like 'get_documents' or 'create_document', which could also involve reports. This makes it vague but not tautological or misleading.

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. It does not mention prerequisites, context (e.g., for data analysis vs. document creation), or exclusions. With sibling tools like 'get_documents' that might retrieve report data, there is no explicit or implied differentiation, leaving usage unclear.

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/Web3ViraLabs/ERPNext-MCP-Server'

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