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'}`); } }

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