get_all_groups
Retrieve all account groups defined in TallyPrime to manage and view your ledger categories.
Instructions
Get all account groups defined in TallyPrime.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_all_groups"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- MCP tool handler function for 'get_all_groups'. Calls client.get_all_groups() and formats the results as a string listing group names (with optional parent). Registered via @mcp.tool() decorator inside the register() function.
@mcp.tool() async def get_all_groups() -> str: """Get all account groups defined in TallyPrime.""" try: groups = await client.get_all_groups() if not groups: return "No groups found." text = f"Found {len(groups)} groups:\n\n" for g in groups: parent = f" (under: {g['parent']})" if g["parent"] else "" text += f" * {g['name']}{parent}\n" return text except TallyError as e: return f"Error: {e}" - Client method that sends the XML request to TallyPrime to fetch all groups. Builds the XML via get_all_groups_xml(), sends it, parses the response, and extracts group name + parent for each GROUP element.
async def get_all_groups(self) -> list: from .xml_builder import get_all_groups_xml raw = await self.send_xml(get_all_groups_xml()) root = self._parse(raw) return [{"name": (g.findtext("NAME") or g.get("NAME") or "").strip(), "parent": (g.findtext("PARENT") or "").strip()} for g in root.iter("GROUP")] - XML builder function that constructs the TallyPrime XML request to fetch all groups. Uses REPORTNAME 'List of Accounts' with ACCOUNTTYPE 'Groups' to filter for groups only.
def get_all_groups_xml() -> str: return """<ENVELOPE> <HEADER> <TALLYREQUEST>Export Data</TALLYREQUEST> </HEADER> <BODY> <EXPORTDATA> <REQUESTDESC> <REPORTNAME>List of Accounts</REPORTNAME> <STATICVARIABLES> <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT> <ACCOUNTTYPE>Groups</ACCOUNTTYPE> </STATICVARIABLES> </REQUESTDESC> </EXPORTDATA> </BODY> </ENVELOPE>""" - src/tallyprime_mcp/tools/ledgers.py:36-49 (registration)The tool is registered via the @mcp.tool() decorator applied to the get_all_groups async function inside the register() function which receives the MCP server instance.
@mcp.tool() async def get_all_groups() -> str: """Get all account groups defined in TallyPrime.""" try: groups = await client.get_all_groups() if not groups: return "No groups found." text = f"Found {len(groups)} groups:\n\n" for g in groups: parent = f" (under: {g['parent']})" if g["parent"] else "" text += f" * {g['name']}{parent}\n" return text except TallyError as e: return f"Error: {e}"