Skip to main content
Glama
lokesh-sparrow

PNPC-MCP-Tally-Prime

query_sql

Read-only

Run read-only SQL SELECT queries against Tally data cached in memory to build custom reports, analyze movements, or reconcile ledgers without re-fetching from Tally.

Instructions

Run a read-only SQL SELECT query against this session's in-memory cache (gone when the session ends). Tables: ledgers(name, parent, closing_balance, trn, state, country), groups(name, parent), stock_items(name, parent, closing_balance), vouchers(guid, date, voucher_type, voucher_number, party_ledger, amount, narration), voucher_items(voucher_guid, date, voucher_type, voucher_number, stock_item, qty, rate, amount, is_deemed_positive, godown, batch), voucher_ledger_entries(voucher_guid, date, voucher_type, voucher_number, ledger, amount, is_deemed_positive, cost_centre, bill_name, bill_type) — all six populated only by explicitly calling sync_to_sql/sync_vouchers_to_sql/sync_voucher_items_to_sql/sync_voucher_ledger_entries_to_sql first. Movement analysis, godown-wise stock, and batch/ageing detail are just SELECTs over voucher_items — there is no separate report tool for them. Splitting a ledger's balance apart by voucher (e.g. a combined VAT ledger into Output vs Input), or reconciling a party ledger's movements voucher by voucher, is just a SELECT over voucher_ledger_entries the same way — voucher_ledger_entries.amount is signed (negative debit, positive credit), so GROUP BY ledger, voucher_type with SUM(amount) is the natural query. profit_and_loss(ledger_name, group_name, closing_balance, period_from, period_to), stock_summary(name, parent, opening_qty, closing_qty, opening_value, closing_value, as_of_date), balance_sheet(group_name, amount, as_of_date), trial_balance(name, debit_amount, credit_amount, period_from, period_to), vat_summary(ledger_name, category, closing_balance, period_from, period_to), and gst_summary(ledger_name, category, closing_balance, period_from, period_to) are populated automatically, no separate sync step — every get_profit_and_loss/get_stock_summary/get_balance_sheet/get_trial_balance/get_vat_liability_summary/get_gst_liability_summary call refreshes its table with that call's result, so a follow-up question about the same report can query it here instead of re-fetching from Tally. Each of these six only ever holds the most recent call's data, not a history — re-call the report tool if you need a different period. Every call here checks which company is actually open in Tally right now against what the cache was last synced/queried for, however that company was arrived at (set_company, Tally's own UI, or a connector restart) — a mismatch clears the stale cache and refuses to run, rather than silently answering with a previous company's rows under the new company's name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesA single SELECT statement

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.3

TDQS

A4.6/5.0
Behavior5/5

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

Although readOnlyHint=true already covers the safety profile, the description adds substantial behavioral context: the cache is session-scoped and gone when the session ends, six tables require explicit sync calls first, the six report tables only hold the most recent call's data with no history, and a company mismatch 'clears the stale cache and refuses to run'. This discloses data lifecycle, preconditions, and failure modes far beyond the annotations.

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

Conciseness3/5

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

Every sentence earns its place — the table inventory, sync preconditions, query patterns, and staleness semantics are all necessary for a SQL tool this complex. However, the structure is a single dense wall of text with tables crammed into long parentheticals, making it hard for an agent to scan. Appropriate size, poor formatting.

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

Completeness4/5

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

For a one-parameter tool with no output schema, the description is remarkably complete: it covers data availability, sync prerequisites, refresh semantics, company-mismatch refusal behavior, and alternative tool routing. The only gap is the absence of any statement about result format, row limits, or error behavior, which is understandable since SQL output is query-dependent but would still help an agent anticipate results.

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?

The schema already covers the sql parameter at 100% ('A single SELECT statement'), giving a baseline of 3. The description adds real value on top: it constrains the statement to SELECT-only, enumerates the valid query targets (table names and their columns), and even provides canonical query patterns such as 'GROUP BY ledger, voucher_type with SUM(amount)' using the signed amount semantics.

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 opening sentence states a specific verb-resource pair: 'Run a read-only SQL SELECT query against this session's in-memory cache'. It clearly distinguishes the tool from the get_* report tools (which fetch from Tally) and the sync_* tools (which populate the cache), by positioning it as the query layer over cached data.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit when-to-use conditions: after sync_* calls for cached tables, for movement/godown/batch analysis ('there is no separate report tool for them'), for ledger splitting/reconciliation, and for follow-up questions on auto-populated report tables 'instead of re-fetching from Tally'. It also states an exclusion: 're-call the report tool if you need a different period'. This is exemplary routing guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools