Skip to main content
Glama
WaHaiLong

Kingdee MCP Server

by WaHaiLong

kingdee_query_report

Read-onlyIdempotent

Queries Kingdee general ledger and financial reports via GetSysReportData, returning raw JSON report rows for a given report ID, account book, and period range.

Instructions

通过金蝶 WebAPI GetSysReportData(查询报表数据) 查询任意总账/财务报表。

端点:Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.GetSysReportData.common.kdsvc (实测确认:formid 必须作为独立 HTTP 表单字段、data 为内层参数的 JSON 字符串。 此前"表单标识为空"的根因是 formid 被嵌进了 data JSON 对象;KDSReportAPIService 端点实测也一律 Unknown Error,不可用。)

请求体为 HTTP 双字段:formid = 报表标识;data = JSON 字符串(即本工具 params.data)。 model 典型结构:FieldKeys(返回字段) + Model(过滤条件) + StartRow/Limit(分页)。 与单据查询(ExecuteBillQuery)不同,报表分页用 StartRow/Limit,不是 PageIndex/PageSize; 账簿用 FACCTBOOKID.FNumber(按编码,如 "001");期间用 FSTARTYEAR/FSTARTPERIOD/FENDYEAR/FENDPERIOD,层级用 FBALANCELEVEL。 ⚠️ FieldKeys 必须是报表真实列 Key——猜的列名会触发服务端 totalWidth 渲染错误; FBALANCELEVEL=0(全部级次)时必须配 FSHOWFULLNAME=true,否则 AccountBalanceStatement.UpdateAcctName 会因 PadLeft(-N) 抛 "totalWidth 要求非负数"。 💡 0 行结果通常是该账簿/期间 T_GL_BALANCE 本身无数据,并非查询失败 (book '001' 金蝶蓝海科技只有 2020 年演示数据,2026 年返回 0 行属于正常)。

已实测确认的报表 formId(财务会计 → 总账):

  • 科目余额表 = GL_RPT_AccountBalance

  • 总账账龄分析表 = GL_AgingSchedule(注意:无 RPT_ 前缀) 其余报表 formId 需在 BOS/ApiDoc 逐张查证(核算维度余额表、数量金额总账、日报表、 多账簿系列、试算平衡表、现金流量表、现金流量查询、报表项目 KDS_RptItem 等)。

params.data(model)权威结构——科目余额表(金蝶开发者社区官方案例 + 2026-08-05 实测 book '001' 金蝶蓝海科技 → 2020 年 2 月 期初/本期/本年累计/期末数据完整 72 行): {"FieldKeys":"FBALANCEID,FBALANCENAME,FACCTTYPE,FACCTGROUP,FCyName," "FBEGINDEBIT,FBEGINCREDIT,FDEBIT,FCREDIT," "FYTDDEBIT,FYTDCREDIT,FENDDEBIT,FENDCREDIT", "SchemeId":"","StartRow":0,"Limit":10, "IsVerifyBaseDataField":"true","FilterString":[], "Model":{"FACCTBOOKID":{"FNumber":"001"},"FCURRENCY":"1", "FSTARTYEAR":2020,"FSTARTPERIOD":2,"FENDYEAR":2020,"FENDPERIOD":2, "FBALANCELEVEL":1,"FSHOWDETAIL":false,"FFORBIDBALANCE":true, "FBALANCEZERO":true,"FPERIODNOBALANCE":true,"FYEARNOBALANCE":true, "FSHOWFULLNAME":true}}

返回:金蝶原始 JSON(含报表数据 Rows),前端/调用方按需解析。

Raises/Returns: str: JSON(成功为报表数据;失败为错误 JSON)

Input Schema

NameRequiredDescriptionDefault
paramsYes

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.2.4

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already mark it read-only, idempotent and non-destructive, and the description adds substantial operational context beyond that: the formid-must-be-a-separate-form-field root cause, the totalWidth/PadLeft crash when FBALANCELEVEL=0 without FSHOWFULLNAME, the StartRow/Limit vs PageIndex/PageSize distinction, and the fact that a 0-row result is normal rather than a failure. These are non-obvious failure modes an agent could not infer elsewhere.

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?

Front-loaded with the verb, endpoint and the key constraint, then structured into endpoint notes, verified formIds, and a worked model example. It loses a point because the full example model payload is duplicated almost verbatim inside the schema's data description, so some sentences do not earn their place twice.

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

Completeness5/5

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

For a complex, free-form JSON-passthrough report API with one opaque parameter, the description supplies the endpoint contract, verified ids, a working payload, the pagination convention and the known server-side errors. An output schema exists, so the brief return-value note is sufficient.

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 the reported 0% schema coverage on the declared parameter, the description carries the full burden and does so: it spells out the model structure (FieldKeys / Model / StartRow / Limit), names the filter field families (FACCTBOOKID.FNumber, FSTARTYEAR/FSTARTPERIOD/FENDYEAR/FENDPERIOD, FBALANCELEVEL), and annotates the field-name and level pitfalls. It also documents the form_id enumeration, including the no-RPT_-prefix exception.

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?

States a specific verb and resource: queries any GL/financial report via GetSysReportData, and names the exact endpoint. It explicitly contrasts itself with document query (ExecuteBillQuery) and with the unusable KDSReportAPIService, so an agent can separate it from kingdee_query_bills and friends without opening a schema.

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

Usage Guidelines4/5

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

Gives concrete when-to-use context (report queries vs. document queries), lists the two verified formIds with the exact selectors, and warns that most other report formIds must be verified in BOS/ApiDoc first. It falls just short of a 5 because it does not name the sibling tool to use for the document-query case, referencing only the underlying ExecuteBillQuery API.

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