Skip to main content
Glama
svharivinod

TallyPrime MCP Server

by svharivinod

create_purchase_voucher

Create a purchase voucher in TallyPrime with supplier, purchase account, amount, date, and optional tax.

Instructions

Create a purchase invoice in TallyPrime.

Args: date: Voucher date YYYYMMDD. party_ledger: Supplier ledger name. purchase_ledger: Purchase account ledger name. amount: Invoice amount excluding tax. narration: Optional description. tax_ledger: GST or tax ledger name (optional). tax_amount: Tax amount (optional, default 0).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYes
party_ledgerYes
purchase_ledgerYes
amountYes
narrationNo
tax_ledgerNo
tax_amountNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'create_purchase_voucher'. Defined as an async function inside the `register()` closure, decorated with @mcp.tool(). Accepts date, party_ledger, purchase_ledger, amount, narration, tax_ledger, tax_amount. Calls `client.create_purchase_voucher(...)` and returns a formatted success/error string.
    @mcp.tool()
    async def create_purchase_voucher(
        date: str,
        party_ledger: str,
        purchase_ledger: str,
        amount: float,
        narration: str = "",
        tax_ledger: str = "",
        tax_amount: float = 0.0,
    ) -> str:
        """
        Create a purchase invoice in TallyPrime.
    
        Args:
            date: Voucher date YYYYMMDD.
            party_ledger: Supplier ledger name.
            purchase_ledger: Purchase account ledger name.
            amount: Invoice amount excluding tax.
            narration: Optional description.
            tax_ledger: GST or tax ledger name (optional).
            tax_amount: Tax amount (optional, default 0).
        """
        try:
            result = await client.create_purchase_voucher(
                date=date, party_ledger=party_ledger, purchase_ledger=purchase_ledger,
                amount=amount, narration=narration, tax_ledger=tax_ledger, tax_amount=tax_amount,
            )
            if result["success"]:
                total = amount + tax_amount
                msg = f"Purchase voucher created. Supplier: {party_ledger}, Amount: {amount:.2f}"
                if tax_amount:
                    msg += f" + Tax: {tax_amount:.2f}"
                msg += f", Total: {total:.2f}, Date: {date}"
                return msg
            return f"Failed: {result['message']}"
        except TallyError as e:
            return f"Error: {e}"
  • Docstring/input schema for create_purchase_voucher. Defines the expected parameters: date (YYYYMMDD), party_ledger (supplier), purchase_ledger, amount, narration, tax_ledger (optional), tax_amount (optional).
    """
    Create a purchase invoice in TallyPrime.
    
    Args:
        date: Voucher date YYYYMMDD.
        party_ledger: Supplier ledger name.
        purchase_ledger: Purchase account ledger name.
        amount: Invoice amount excluding tax.
        narration: Optional description.
        tax_ledger: GST or tax ledger name (optional).
        tax_amount: Tax amount (optional, default 0).
    """
  • Registration entry point. `register_all()` in tools/__init__.py calls `vouchers.register(mcp, client)`, which internally creates the 'create_purchase_voucher' tool via the @mcp.tool() decorator in vouchers.py.
    def register_all(mcp: FastMCP, client: TallyClient):
        company.register(mcp, client)
        ledgers.register(mcp, client)
        vouchers.register(mcp, client)
        reports.register(mcp, client)
  • TallyClient method that bridges the MCP handler to the XML builder. Calls `create_purchase_voucher_xml(**kwargs)` to build the XML, sends it via `send_xml`, parses the response, and checks the import result.
    async def create_purchase_voucher(self, **kwargs) -> dict:
        from .xml_builder import create_purchase_voucher_xml
        return self._check_import_result(self._parse(await self.send_xml(create_purchase_voucher_xml(**kwargs))))
  • XML builder for purchase vouchers. Constructs a TDL XML request string with VCHTYPE='Purchase'. Creates ledger entries: party_ledger (cr, positive total), purchase_ledger (dr, negative amount), and optional tax_ledger entry. Wraps in `_voucher_import_envelope`.
    def create_purchase_voucher_xml(
        date: str,
        party_ledger: str,
        purchase_ledger: str,
        amount: float,
        narration: str = "",
        tax_ledger: str = "",
        tax_amount: float = 0.0,
    ) -> str:
        total = amount + tax_amount
        tax_entry = ""
        if tax_ledger and tax_amount:
            tax_entry = f"""<ALLLEDGERENTRIES.LIST>
                <LEDGERNAME>{tax_ledger}</LEDGERNAME>
                <ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE>
                <AMOUNT>-{tax_amount}</AMOUNT>
              </ALLLEDGERENTRIES.LIST>"""
    
        voucher = f"""<VOUCHER ACTION="Create" VCHTYPE="Purchase">
              <DATE>{date}</DATE>
              <VOUCHERTYPENAME>Purchase</VOUCHERTYPENAME>
              <NARRATION>{narration}</NARRATION>
              <ALLLEDGERENTRIES.LIST>
                <LEDGERNAME>{party_ledger}</LEDGERNAME>
                <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE>
                <AMOUNT>{total}</AMOUNT>
              </ALLLEDGERENTRIES.LIST>
              <ALLLEDGERENTRIES.LIST>
                <LEDGERNAME>{purchase_ledger}</LEDGERNAME>
                <ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE>
                <AMOUNT>-{amount}</AMOUNT>
              </ALLLEDGERENTRIES.LIST>
              {tax_entry}
            </VOUCHER>"""
        return _voucher_import_envelope(voucher)
Behavior2/5

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

No annotations are provided, and the description lacks details on side effects, return values, prerequisites (e.g., ledger existence), or error conditions. It only describes the creation action without behavioral traits.

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 concise: one sentence summary followed by a bullet-point list of parameters. Every sentence adds value, and the structure is easy to parse for an AI agent.

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

Completeness2/5

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

Given the complexity (7 params, no annotations, output schema not described), the description lacks context on return values, prerequisites, and differentiation from sibling tools like create_payment_voucher. It is incomplete for full autonomous use.

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?

With 0% schema description coverage, the description adds essential meaning for all 7 parameters: date format, role of party_ledger and purchase_ledger, tax handling, and narration. Some parameter roles could be more explicit, but overall effective.

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 purchase invoice in TallyPrime', specifying the exact verb (create), resource (purchase invoice), and system. This uniquely identifies the tool among siblings like create_sales_voucher.

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 guidance on when to use this tool versus alternatives like create_sales_voucher or create_payment_voucher. The description does not mention scenarios or prerequisites, leaving usage context implicit.

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