get_balance_sheet
Retrieve the Balance Sheet from TallyPrime for any specified date. Use this to view financial position at a glance.
Instructions
Get the Balance Sheet from TallyPrime as of a specific date.
Args: as_of_date: Date YYYYMMDD (e.g. '20250331').
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| as_of_date | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/tallyprime_mcp/tools/reports.py:28-40 (registration)The MCP tool registration (via @mcp.tool()) and handler for 'get_balance_sheet'. This function defines the tool, its docstring/args, calls the TallyClient to fetch data, and returns a formatted JSON string.
@mcp.tool() async def get_balance_sheet(as_of_date: str) -> str: """ Get the Balance Sheet from TallyPrime as of a specific date. Args: as_of_date: Date YYYYMMDD (e.g. '20250331'). """ try: data = await client.get_balance_sheet(as_of_date) return f"Balance Sheet as of {as_of_date}:\n\n" + json.dumps(data, indent=2) except TallyError as e: return f"Error: {e}" - The client-side handler that builds the XML request via get_balance_sheet_xml, sends it to Tally, parses the response XML, and converts it to a Python dict.
async def get_balance_sheet(self, as_of_date: str) -> dict: from .xml_builder import get_balance_sheet_xml return self._elem_to_dict(self._parse(await self.send_xml(get_balance_sheet_xml(as_of_date)))) - Helper function that builds the XML envelope for the Balance Sheet report request, parameterized by as_of_date.
def get_balance_sheet_xml(as_of_date: str) -> str: return f"""<ENVELOPE> <HEADER> <TALLYREQUEST>Export Data</TALLYREQUEST> </HEADER> <BODY> <EXPORTDATA> <REQUESTDESC> <REPORTNAME>Balance Sheet</REPORTNAME> <STATICVARIABLES> <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT> <SVTODATE>{as_of_date}</SVTODATE> </STATICVARIABLES> </REQUESTDESC> </EXPORTDATA> </BODY> </ENVELOPE>"""