Skip to main content
Glama
leolulu

siyuan-mcp-server

by leolulu

execute_sql

Run read-only SQL SELECT queries to perform advanced cross-field and cross-table searches in the SiYuan knowledge base, with sensitive data automatically masked.

Instructions

直接对数据库执行只读的 SELECT 查询。

适用场景: - 需要跨字段、跨表的高级筛选能力。 - 内置查询工具无法覆盖的复杂检索。

使用方法: - 仅支持 SELECT 语句。 - 建议显式 LIMIT,避免一次返回过多数据。

注意事项: - 返回的字符串字段会进行敏感信息打码。 - 如需精确审计原始敏感字段值,不适合使用该工具。

Args: query (str): SQL SELECT 查询语句

Returns: List[Dict[str, Any]]: 查询结果列表

Raises: ValueError: 如果查询不是 SELECT 语句

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.31.0

TDQS

A5/5.0
Behavior5/5

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

With no annotations provided, the description carries the full disclosure burden and does well: it declares read-only behavior, restricts to SELECT, warns that returned string fields are masked, and explicitly says it cannot be used for raw audit of sensitive values. It also documents ValueError for non-SELECT queries.

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 well-structured with clear sections: core behavior, applicable scenarios, usage tips, cautions, and Args/Returns/Raises. Every section adds useful operational information and there is no redundant wording.

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 one-parameter SQL execution tool, the description covers what it does, when to use it, the exact parameter semantic, return type, error behavior, and a critical data-masking caveat. The presence of an output schema further reduces the need to detail the return format, yet the description still provides Returns and Raises.

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?

The schema only defines 'query' as a string with 0% description coverage. The description compensates by defining the parameter as 'query (str): SQL SELECT 查询语句', clarifying it must be a SQL SELECT statement, and it further recommends explicit LIMIT usage. This adds essential meaning beyond the raw type.

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 opens with a precise statement: '直接对数据库执行只读的 SELECT 查询' (execute read-only SELECT queries directly against the database). It further narrows scope with '仅支持 SELECT 语句' and positions the tool relative to built-in query tools, making its purpose distinct from siblings like search_blocks or find_documents.

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 '适用场景' section explicitly states when to use the tool: cross-field/cross-table advanced filtering and complex retrieval not covered by built-in query tools. The caution also gives a when-not case: '如需精确审计原始敏感字段值,不适合使用该工具'. This is clear usage guidance with exclusions.

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