get_stock_summary
Retrieve inventory stock summary from TallyPrime for a given date to check stock quantities and values.
Instructions
Get the Stock Summary (inventory) from TallyPrime as of a date.
Args: as_of_date: Date YYYYMMDD (e.g. '20260516').
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| as_of_date | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The MCP tool handler for 'get_stock_summary'. It is decorated with @mcp.tool(), takes an as_of_date string parameter, calls client.get_stock_summary(), and returns the JSON result as a formatted string.
@mcp.tool() async def get_stock_summary(as_of_date: str) -> str: """ Get the Stock Summary (inventory) from TallyPrime as of a date. Args: as_of_date: Date YYYYMMDD (e.g. '20260516'). """ try: data = await client.get_stock_summary(as_of_date) return f"Stock Summary as of {as_of_date}:\n\n" + json.dumps(data, indent=2) except TallyError as e: return f"Error: {e}" - The TallyClient method that sends the stock summary XML request to TallyPrime and parses the response into a dict.
async def get_stock_summary(self, as_of_date: str) -> dict: from .xml_builder import get_stock_summary_xml return self._elem_to_dict(self._parse(await self.send_xml(get_stock_summary_xml(as_of_date)))) - Builds the XML request payload for the Stock Summary report, using the provided as_of_date.
def get_stock_summary_xml(as_of_date: str) -> str: return f"""<ENVELOPE> <HEADER> <TALLYREQUEST>Export Data</TALLYREQUEST> </HEADER> <BODY> <EXPORTDATA> <REQUESTDESC> <REPORTNAME>Stock Summary</REPORTNAME> <STATICVARIABLES> <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT> <SVTODATE>{as_of_date}</SVTODATE> </STATICVARIABLES> </REQUESTDESC> </EXPORTDATA> </BODY> </ENVELOPE>""" - src/tallyprime_mcp/tools/__init__.py:7-11 (registration)The register_all function that calls reports.register(mcp, client), which triggers the @mcp.tool() decorator and registers get_stock_summary as an MCP tool.
def register_all(mcp: FastMCP, client: TallyClient): company.register(mcp, client) ledgers.register(mcp, client) vouchers.register(mcp, client) reports.register(mcp, client) - src/tallyprime_mcp/tools/reports.py:11-11 (registration)The register function in reports.py that receives the mcp and client instances and defines the tool via @mcp.tool() decorator.
def register(mcp, client: TallyClient):