Skip to main content
Glama
svharivinod

TallyPrime MCP Server

by svharivinod

create_ledger

Create a new ledger in TallyPrime by specifying its name, parent group, and optional opening balance. Positive balance indicates debit, negative indicates credit.

Instructions

Create a new ledger in TallyPrime.

Args: name: Name for the new ledger. group: Parent group (e.g. 'Sundry Debtors', 'Bank Accounts'). opening_balance: Opening balance. Positive=Debit, Negative=Credit. Default 0.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
groupYes
opening_balanceNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'create_ledger' – decorated with @mcp.tool() inside register(). Takes name, group, opening_balance and delegates to client.create_ledger().
    @mcp.tool()
    async def create_ledger(name: str, group: str, opening_balance: float = 0.0) -> str:
        """
        Create a new ledger in TallyPrime.
    
        Args:
            name: Name for the new ledger.
            group: Parent group (e.g. 'Sundry Debtors', 'Bank Accounts').
            opening_balance: Opening balance. Positive=Debit, Negative=Credit. Default 0.
        """
        try:
            result = await client.create_ledger(name, group, opening_balance)
            if result["success"]:
                return f"Ledger '{name}' created successfully under '{group}'."
            return f"Failed to create ledger: {result['message']}"
        except TallyError as e:
            return f"Error: {e}"
  • The function signature serves as the schema – typed parameters (name: str, group: str, opening_balance: float = 0.0) with docstring describing each arg.
    async def create_ledger(name: str, group: str, opening_balance: float = 0.0) -> str:
        """
        Create a new ledger in TallyPrime.
    
        Args:
            name: Name for the new ledger.
            group: Parent group (e.g. 'Sundry Debtors', 'Bank Accounts').
            opening_balance: Opening balance. Positive=Debit, Negative=Credit. Default 0.
        """
  • Registration entry point – the register() function is called with the MCP server instance, which decorates all tool functions including create_ledger.
    def register(mcp, client: TallyClient):
  • TallyClient.create_ledger() – the client method that sends the XML request to TallyPrime. Delegates XML building to xml_builder.create_ledger_xml() and parses the import result.
    async def create_ledger(self, name: str, group: str, opening_balance: float = 0.0) -> dict:
        from .xml_builder import create_ledger_xml
        return self._check_import_result(self._parse(await self.send_xml(create_ledger_xml(name, group, opening_balance))))
  • create_ledger_xml() – builds the TallyPrime XML request string for creating a ledger, including optional opening balance tag (Dr/Cr based on sign).
    def create_ledger_xml(name: str, group: str, opening_balance: float = 0.0) -> str:
        bal_tag = ""
        if opening_balance != 0.0:
            dr_cr = "Dr" if opening_balance > 0 else "Cr"
            bal_tag = f"<OPENINGBALANCE>{abs(opening_balance)} {dr_cr}</OPENINGBALANCE>"
    
        return f"""<ENVELOPE>
      <HEADER>
        <TALLYREQUEST>Import Data</TALLYREQUEST>
      </HEADER>
      <BODY>
        <IMPORTDATA>
          <REQUESTDESC>
            <REPORTNAME>All Masters</REPORTNAME>
          </REQUESTDESC>
          <REQUESTDATA>
            <TALLYMESSAGE xmlns:UDF="TallyUDF">
              <LEDGER NAME="{name}" ACTION="Create">
                <NAME>{name}</NAME>
                <PARENT>{group}</PARENT>
                {bal_tag}
              </LEDGER>
            </TALLYMESSAGE>
          </REQUESTDATA>
        </IMPORTDATA>
      </BODY>
    </ENVELOPE>"""
Behavior2/5

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

No annotations are provided, so the description must convey behavioral traits. It only mentions the action and parameters, but does not disclose side effects, authorization requirements, error behavior, or whether the operation is idempotent. The sign convention for opening_balance is helpful, but overall behavioral context is minimal.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, with a clear first sentence stating the purpose, followed by parameter definitions in a structured list. It is efficient and front-loaded, though could be slightly more compact.

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?

The description adequately explains the parameters for a simple creation tool. It doesn't cover behavioral aspects like idempotency or error handling, which are important for a mutation tool. However, the presence of an output schema (not described) reduces the need to explain return values. Overall, it is minimally viable but leaves gaps.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by explaining each parameter: 'name' for the ledger name, 'group' with examples like 'Sundry Debtors', and 'opening_balance' with its sign convention (positive=Debit, negative=Credit) and default value of 0. This adds substantial meaning beyond the schema.

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

Purpose5/5

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

The description clearly states 'Create a new ledger in TallyPrime', specifying the action ('Create'), the resource ('ledger'), and the context ('in TallyPrime'). This distinguishes it from sibling tools like create_journal_voucher, which create different entities.

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?

The description does not provide any guidance on when to use this tool versus alternatives. It only describes the tool itself without indicating prerequisites, exclusivity, or situations where another tool would be more appropriate.

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