Skip to main content
Glama

add_data_validation

给区域加数据验证(下拉列表 / 数值区间 / 日期区间)。

Instructions

给区域加数据验证(下拉列表 / 数值区间 / 日期区间)。

用途:表单类表格中限定某列只能选指定值(如"状态"列只能选 生效 / 作废 / 待审阅), 或限定数值范围(如金额必须 >= 0)。

参数:

  • file_path:工作簿路径

  • cell_range:目标区域,如 "D2:D100"

  • dv_type:list / whole / decimal / date / time / textLength / custom

  • formula1:

    • list:'"选项1,选项2,选项3)' —— 注意外层单引号内必须带双引号

    • whole / decimal:如 ">=0" 或 "1"(区间则配合 formula2)

  • formula2:区间上界,如 "<=100"

  • allow_blank:是否允许空值

返回:写入的规则信息(真实 OOXML 数据验证,Excel 中生效)。

Input Schema

NameRequiredDescriptionDefault
sheetNo
dv_typeNolist
formula1No
formula2No
file_pathYes
cell_rangeYes
allow_blankNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.3.1

TDQS

A4.2/5.0
Behavior3/5

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

No annotations are provided, so the description carries the full behavioral burden. It does disclose that the result is genuine OOXML validation that takes effect in Excel and what is returned, which is useful. However, it never says whether existing validation on the range is replaced, whether the workbook must be closed, or what permissions/locking are required for a write operation.

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?

Well front-loaded: purpose first, use cases second, then a compact parameter reference, then the return. Bullets and indentation make it scannable and no sentence is filler.

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 7-parameter mutation tool with no annotations and no output schema, the description is close to sufficient: it covers the write semantics, the return, and per-type formula formats. The gaps are the undocumented 'sheet' parameter and the unstated behavior when a range already has validation.

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%, so the description must compensate, and it largely does: it explains formula1 syntax per dv_type (including the double-quote-inside-single-quote rule for list) and lists the dv_type values that the schema does not enumerate. It omits the 'sheet' parameter entirely, so one of seven parameters remains undocumented in both places.

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 ('给区域加数据验证') and immediately scopes it with the three supported modes (dropdown list / numeric range / date range). This clearly separates it from the nearest sibling, add_conditional_format, and an agent can tell what it does without opening the 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 use-case context ('表单类表格中限定某列只能选指定值', '金额必须 >= 0'), which tells the agent when this tool is the right choice. It does not name alternatives or state exclusions (e.g. when to prefer conditional formatting), so it stops short of explicit routing.

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