MCPcopy Create free account
hub / github.com/2234839/mcpserver / executeDatabaseQuery

Function executeDatabaseQuery

src/tools/siyuan/database-query.ts:22–45  ·  view source on GitHub ↗
(params: DatabaseQueryParams)

Source from the content-addressed store, hash-verified

20
21// 执行数据库查询的函数
22export async function executeDatabaseQuery(params: DatabaseQueryParams): Promise<DatabaseQueryResult> {
23 try {
24 const { stmt, limit, offset } = params;
25
26 // 构建查询语句(如果需要分页)
27 let queryStmt = stmt.trim();
28 if (limit !== undefined) {
29 queryStmt += ` LIMIT ${limit}`;
30 }
31 if (offset !== undefined) {
32 queryStmt += ` OFFSET ${offset}`;
33 }
34
35 const result = await makeSiYuanRequest<DatabaseQueryResult>({
36 endpoint: 'query/sql',
37 data: { stmt: queryStmt },
38 });
39
40 return result;
41 } catch (error) {
42 logger.error('Database query execution failed', { stmt: params.stmt, error });
43 throw error;
44 }
45}
46
47// 注册数据库查询工具
48export function registerDatabaseQueryTool(server: McpServer) {

Callers 1

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected