Skip to main content
Glama
nichuan

sql-template-mcp

by nichuan

save_sql_template

Save a generated SQL query as a reusable template in the template library with metadata like scenario, category, placeholders, and verified status, enabling retrieval and reuse in future tasks.

Instructions

将一次生成的 SQL 步骤沉淀为模板,存入模板库(Supabase)。

参数:

  • title: 模板标题(如「询价单回退至报价中」)

  • category: 业务分类,建议取值:通用基础查询 / 询价单RFX / 征询单RF / 数据修复

  • scenario: 业务场景描述(检索主要依据,请写清楚用途)

  • sql_text: 完整 SQL 文本(保留 {...}<...> 占位符原样)

  • execution_flow: 执行过程伪代码(数据修复类模板强烈建议填写)。标准语法: [INPUT] <入参1>, <入参2> [STEP n: 步骤名] QUERY: 前置查询 SQL(用 {变量} 引用上一步提取的真实值) ASSERT: 断言(如「必须返回 1 行,提取 {tenant_id};0 行则终止报错」) CONDITION: 条件短路(如「IF {status} == 'X' THEN RETURN 无需修复」) ACTION: 修复语句(UPDATE/DELETE/INSERT,带乐观锁 object_version_number+1) 指导大模型分步调用 execute_sql,禁止跳过前置校验直接生成修复 SQL。

  • example_case: 脱敏示例(Few-Shot)。含:输入参数 → 各 STEP 中间结果 (如「Step 1 结果: tenant_id=155357」)→ 最终生成的可执行 SQL,消除大模型猜测。

  • doc_type: 单据类型(通用/询价单/招标单/征询单/数据修复)

  • keywords: 关键词/标签,逗号分隔(如「回退,报价中,延时消息」),用于检索

  • core_tables: 涉及核心表,逗号分隔(如「ssrc_rfx_header,spfm_pending_message」)

  • placeholders: 占位符清单,逗号分隔(如「tenant_id,rfx_header_id」)

  • verified: 是否「✅ 已验证」(验证过的模板可被技能免 MCP 校验复用)

  • verified_at: 验证日期(verified=True 时建议填写,如 2026-07-23)

  • template_no: 模板编号(如 2.6.6),便于与历史模板对应

  • created_by: 作者(为团队共享预留)

  • source: 来源标记(auto=技能自动沉淀 / migrated=手工迁移 / manual=手工新增)

  • skip_dup_check: 跳过相似去重检查直接写入

返回:保存结果(含模板 id)或相似模板提示。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYes
sourceNoauto
categoryYes
doc_typeNo通用
keywordsNo
scenarioYes
sql_textYes
verifiedNo
created_byNo
core_tablesNo
template_noNo
verified_atNo
example_caseNo
placeholdersNo
execution_flowNo
skip_dup_checkNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior3/5

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

无注解,描述承担全部行为披露责任。描述说明了保存到模板库的操作,但未提及是否有权限要求、是否可能覆盖现有模板、写入后如何验证等。提供了一些内部指导(如何生成执行流),但缺少副作用和前置条件信息。

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?

虽然描述较长,但每个参数都配有清晰说明和示例,结构化良好,关键信息靠前。有些内容可更精简,但整体信息密度高,未过度冗余。

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?

描述覆盖了所有 16 个参数的逐一解释,包括默认值、示例和关系(如 execution_flow 的语法),并说明了返回值概要和用途。对于创建型工具,上下文足够完整。

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?

输入 schema 没有提供任何描述(schema coverage 0%),描述承担了全部参数解释职责。每个参数都有详细含义、示例值和推荐填写场合,远超 schema 提供的信息,完全补偿了 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?

描述明确说明工具用途:将生成的 SQL 步骤沉淀为模板并存入模板库(Supabase)。动词“沉淀”+宾语“模板”+存储位置,清晰区分于兄弟工具(get/search/list/update/delete 等)。

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

Usage Guidelines3/5

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

描述包含详细的使用指导,如数据修复类模板强烈建议填写 execution_flow,并指导大模型分步调用 execute_sql。但未明确说明何时使用此工具 vs 兄弟工具(如 update_sql_template 或 list_sql_templates),也未说明替代方案。使用指南隐含在参数说明中,但缺少显式对比。

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/nichuan/sql-template-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server