From 08bde54d74c760bf72705a5b4b1b12a2c27a962c Mon Sep 17 00:00:00 2001 From: kaixianzheng Date: Thu, 20 Aug 2026 17:11:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=90=9C=E7=B4=A0=20?= =?UTF-8?q?API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ app/api/resources/route.ts | 12 ++++++++++++ lib/mcp-operations.ts | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 app/api/resources/route.ts diff --git a/.gitignore b/.gitignore index d6fb771..23b6066 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,9 @@ # misc .DS_Store *.pem +/.idea/ +AGENTS.md +CLAUDE.md # debug npm-debug.log* diff --git a/app/api/resources/route.ts b/app/api/resources/route.ts new file mode 100644 index 0000000..22d766b --- /dev/null +++ b/app/api/resources/route.ts @@ -0,0 +1,12 @@ +import { resourceSearch } from "../../../lib/mcp-operations"; + +export async function GET(request: Request) { + const searchParams = new URL(request.url).searchParams; + return Response.json( + await resourceSearch({ + query: searchParams.get("q") ?? "", + limit: Number(searchParams.get("limit")) || 50, + offset: Number(searchParams.get("offset")) || 0, + }), + ); +} diff --git a/lib/mcp-operations.ts b/lib/mcp-operations.ts index 7deca3f..8998247 100644 --- a/lib/mcp-operations.ts +++ b/lib/mcp-operations.ts @@ -362,7 +362,7 @@ function resourceWhere(input: ResourceFilters) { const bindings: unknown[] = []; if (input.query?.trim()) { conditions.push( - "(a.nickname LIKE ? ESCAPE '\\' OR a.public_account_id LIKE ? ESCAPE '\\' OR a.current_contact LIKE ? ESCAPE '\\' OR a.tags LIKE ? ESCAPE '\\' OR a.bio LIKE ? ESCAPE '\\')", + "(a.nickname LIKE ? ESCAPE '\\\\' OR a.public_account_id LIKE ? ESCAPE '\\\\' OR a.current_contact LIKE ? ESCAPE '\\\\' OR a.tags LIKE ? ESCAPE '\\\\' OR a.bio LIKE ? ESCAPE '\\\\')", ); const pattern = like(input.query.trim()); bindings.push(pattern, pattern, pattern, pattern, pattern); -- 2.49.1