Skip to main content
Glama
svharivinod

TallyPrime MCP Server

by svharivinod

get_ledger

Retrieve detailed information and recent voucher entries for any ledger in TallyPrime by providing its exact name.

Instructions

Get details and recent vouchers for a specific ledger.

Args: name: Exact ledger name as it appears in TallyPrime (case-sensitive).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'get_ledger' MCP tool handler function. It is an async function decorated with @mcp.tool(), registered inside the ledgers.register() function. Takes a ledger name, calls client.get_ledger(name), and returns the result as JSON.
    @mcp.tool()
    async def get_ledger(name: str) -> str:
        """
        Get details and recent vouchers for a specific ledger.
    
        Args:
            name: Exact ledger name as it appears in TallyPrime (case-sensitive).
        """
        try:
            data = await client.get_ledger(name)
            return json.dumps(data, indent=2)
        except TallyError as e:
            return f"Error: {e}"
  • The ledgers.register() function that registers all ledger-related tools including 'get_ledger' onto the FastMCP instance via the @mcp.tool() decorator.
    def register(mcp, client: TallyClient):
    
        @mcp.tool()
        async def get_all_ledgers() -> str:
            """Get all ledgers in TallyPrime with their group and closing balance."""
            try:
                ledgers = await client.get_all_ledgers()
                if not ledgers:
                    return "No ledgers found."
                text = f"Found {len(ledgers)} ledgers:\n\n"
                for l in ledgers:
                    text += f"  * {l['name']}  (Group: {l['group']},  Balance: {l['closing']})\n"
                return text
            except TallyError as e:
                return f"Error: {e}"
    
        @mcp.tool()
        async def get_ledger(name: str) -> str:
            """
            Get details and recent vouchers for a specific ledger.
    
            Args:
                name: Exact ledger name as it appears in TallyPrime (case-sensitive).
            """
            try:
                data = await client.get_ledger(name)
                return json.dumps(data, indent=2)
            except TallyError as e:
                return f"Error: {e}"
  • The TallyClient.get_ledger() method. It builds XML via get_ledger_xml(), sends it to TallyPrime, parses the response, and converts XML to a dict.
    async def get_ledger(self, name: str) -> dict:
        from .xml_builder import get_ledger_xml
        return self._elem_to_dict(self._parse(await self.send_xml(get_ledger_xml(name))))
  • The get_ledger_xml() function that builds the TDL XML request string using the 'Ledger Vouchers' report and a LEDGERNAME parameter.
    def get_ledger_xml(name: str) -> str:
        return f"""<ENVELOPE>
      <HEADER>
        <TALLYREQUEST>Export Data</TALLYREQUEST>
      </HEADER>
      <BODY>
        <EXPORTDATA>
          <REQUESTDESC>
            <REPORTNAME>Ledger Vouchers</REPORTNAME>
            <STATICVARIABLES>
              <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
              <LEDGERNAME>{name}</LEDGERNAME>
            </STATICVARIABLES>
          </REQUESTDESC>
        </EXPORTDATA>
      </BODY>
    </ENVELOPE>"""
  • The register_all() function in the tools package __init__.py that calls ledgers.register(mcp, client), which is where get_ledger gets registered.
    def register_all(mcp: FastMCP, client: TallyClient):
        company.register(mcp, client)
        ledgers.register(mcp, client)
        vouchers.register(mcp, client)
        reports.register(mcp, client)
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It only states 'Get' (implying read-only) but does not mention safety, idempotency, error behavior, authentication, or rate limits. This is insufficient for a tool with no annotations.

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 two sentences, front-loading the purpose, with no extraneous words. It is optimally concise for a simple tool with one parameter.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (1 required param, no nested objects, output schema exists), the description covers the core purpose and parameter semantics. However, it lacks details on what 'details' entail, whether pagination exists for vouchers, or error handling when the ledger is not found. The presence of an output schema mitigates the need to describe return values, but other gaps remain.

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

Parameters4/5

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

Schema coverage is 0% (no descriptions in schema), so the description compensates by adding that 'name' is the 'Exact ledger name as it appears in TallyPrime (case-sensitive).' This provides meaningful formatting and case-sensitivity details beyond the schema's type and title.

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

Purpose4/5

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

Description clearly states 'Get details and recent vouchers for a specific ledger,' using a specific verb and resource. It distinguishes from siblings like 'get_all_ledgers' (which returns all ledgers) and 'get_vouchers' (which lacks ledger specificity). However, 'details' is vague but acceptable.

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?

No explicit guidance on when to use this tool versus alternatives like 'get_all_ledgers' or 'get_vouchers.' The description implies usage for a specific ledger but does not state when not to use it or provide alternative recommendations.

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/svharivinod/tallyprime-mcp'

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