# siyuan_query_sql

思源 SQL 查询工具 - 执行 SQLite 查询语句 你是思源小助手，你需要根据用户需求，编写符合思源笔记数据库结构的 SQL 查询语句。在必要时，解释查询结果的含义和用途。 要求 SQL 语法规范： 在默认的情况下，用户可以在思源的嵌入块中输入 SQL 代码查询，此时 SQL 查询语句必须以 select * from blocks 开头：只允许查询 block 表，且不允许单独查询字段 面向开发者的高级用法：用户还可以调用后端 API 接口，发送 SQL 查询，此时是可以使用更普遍的 SQL 语法结构的（查询别的表，返回特定字段） 使用 SQLite 的语法，如 strftime 函数处理时间。 默认情况下，查询结果最多返回 64 个块，除非明确指定了 limit xxx 输出：将查询语句放在一个 \

Agent View of the PolicyLayer registry record for `siyuan_query_sql`. HTML page: https://policylayer.com/tools/2234839-mcpserver/siyuan-query-sql

## Facts

- Tool: `siyuan_query_sql`
- Server: Martin MCP Toolbox (`2234839/mcpserver`) — https://policylayer.com/tools/2234839-mcpserver.md
- Homepage: https://github.com/2234839/mcpserver
- Risk category: Execute (High risk)
- Registry record: grade C, identity unverified
- Server rate-limited: no
- Parameters: 0
- Recommended policy verdict: Rate-limited

## Example call (MCP tools/call, JSON-RPC 2.0)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "siyuan_query_sql",
    "arguments": {}
  }
}
```

## Why siyuan_query_sql is rated High

This tool executes arbitrary SQLite SQL queries against SiYuan Notes' database. While the description emphasizes SELECT queries, it explicitly allows 'more universal SQL syntax' via the backend API, which could include destructive statements (DROP, DELETE, UPDATE). Even limited to SELECT, executing arbitrary queries against a local database is Execute-level risk.

From the tool's own definition: "执行 SQLite 查询语句 (execute SQLite query statements); 'siyuan_query_sql' runs arbitrary SQL including queries against multiple tables and specific fields via backend API"

## Use case

AI agents invoke siyuan_query_sql to trigger actions in Martin MCP Toolbox. What it does depends on the arguments the agent supplies, and its effects often reach beyond the immediate call: builds kicked off, notifications sent, workflows started.

## Recommended policy (PolicyLayer)

Verdict: **Rate-limited**. Enforced by the PolicyLayer MCP gateway (https://policylayer.com/mcp-gateway) before a call reaches Martin MCP Toolbox:

```json
{
  "version": "1",
  "default": "deny",
  "tools": {
    "siyuan_query_sql": {
      "limits": [
        {
          "counter": "siyuan_query_sql_rate",
          "window": "minute",
          "max": 10,
          "scope": "grant"
        }
      ]
    }
  }
}
```

## Other tools on Martin MCP Toolbox (13)

- `pollinations_generate_text` — Execute — https://policylayer.com/tools/2234839-mcpserver/pollinations-generate-text.md
- `advanced_web_search` — Read — https://policylayer.com/tools/2234839-mcpserver/advanced-web-search.md
- `analyze_video` — Read — https://policylayer.com/tools/2234839-mcpserver/analyze-video.md
- `get_block_kramdown` — Read — https://policylayer.com/tools/2234839-mcpserver/get-block-kramdown.md
- `pollinations_analyze_image` — Read — https://policylayer.com/tools/2234839-mcpserver/pollinations-analyze-image.md
- `read_image` — Read — https://policylayer.com/tools/2234839-mcpserver/read-image.md
- `siyuan_database_query` — Read — https://policylayer.com/tools/2234839-mcpserver/siyuan-database-query.md
- `siyuan_search_blocks` — Read — https://policylayer.com/tools/2234839-mcpserver/siyuan-search-blocks.md
- `web_search` — Read — https://policylayer.com/tools/2234839-mcpserver/web-search.md
- `generate_image` — Write — https://policylayer.com/tools/2234839-mcpserver/generate-image.md
- `pollinations_generate_audio` — Write — https://policylayer.com/tools/2234839-mcpserver/pollinations-generate-audio.md
- `pollinations_generate_image` — Write — https://policylayer.com/tools/2234839-mcpserver/pollinations-generate-image.md
- `update_block` — Write — https://policylayer.com/tools/2234839-mcpserver/update-block.md

## For agents

This record is a snapshot. Live verdicts and the full registry:

- Check every server in your MCP config at once: `npx -y policylayer stack`
- Vet a server before you add it: install the mcp-precheck skill — `npx skills add https://policylayer.com` (skill text: https://policylayer.com/skill.md)
- Query the registry over MCP: endpoint `https://api.policylayer.com/mcp` — tools `check_mcp_server`, `check_mcp_stack`, `check_tool`, `search_registry`, `get_change_events`

---

Source: the PolicyLayer MCP registry — one continuously verified record per MCP server. Full record: https://policylayer.com/registry?q=2234839-mcpserver · API: https://policylayer.com/registry/api · Policy library: https://policylayer.com/policies/2234839-mcpserver
