Skip to main content
Glama
SiYuan MCP Server
by MyrkoF

siyuan_sql

Run read-only SQL SELECT queries against SiYuan's SQLite database to retrieve blocks, documents, tags, backlinks, and search results; use read_database for Attribute View data.

Instructions

Execute a SQL SELECT on SiYuan's SQLite database. Use for ALL reads: blocks, documents, tags, backlinks, search. Read the siyuan://static/sql-schema resource for table schema and example queries. NOTE: Attribute View (database) data is NOT in SQLite — use read_database instead.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "stmt": "<stmt>"
    },
    "name": "siyuan_sql"
  }
}

Input Schema

NameRequiredDescriptionDefault
stmtYesSQL SELECT statement (read-only). Example: SELECT * FROM blocks WHERE type='d' LIMIT 10

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.1.1

TDQS

A4.6/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does reasonably well: it declares the operation is SELECT-only, that the backing store is SQLite, and that it points at a schema resource before writing queries. It does not say whether large result sets are truncated, whether there is a row cap or timeout, or what errors look like, which leaves a mutation-free but resource-heavy tool partly opaque.

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?

Three short sentences: capability first, usage rule second, the exclusion/alternative last. Nothing is redundant with the title or schema, and the most decision-relevant constraint (use read_database for Attribute View data) is placed where it will be read before the call.

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 and no annotations, the definition covers what to query, where to find table structure, and which sibling handles excluded data. The remaining gap is return behavior — row limits, truncation, and result shape — which matters for an arbitrary-SQL tool but is not addressed.

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 100% for the single stmt parameter, so the baseline is 3; the description earns above that by telling the agent the dialect is SQLite and that a siyuan://static/sql-schema resource documents available tables and example queries — essential meaning for composing a valid statement that the schema itself cannot supply.

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 ("Execute a SQL SELECT on SiYuan's SQLite database") and immediately scopes what it covers: blocks, documents, tags, backlinks, search. It also distinguishes itself from read_database by name, so an agent can route between the two without opening either schema.

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?

"Use for ALL reads" is an explicit positive rule, and the closing note gives an explicit exclusion plus the correct alternative: Attribute View data is not in SQLite, use read_database instead. Both the when and the when-not are stated, with the sibling named.

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