From 441ba313aa9d39cdb33d419e7ced7d7a2f8e20e8 Mon Sep 17 00:00:00 2001 From: Carsten Graf Date: Tue, 17 Feb 2026 17:29:40 +0100 Subject: [PATCH] Update Tabellen und Suchalgo --- mssql-mcp-readonly.js | 39 ++++++-- public/dev.html | 30 +++++-- public/images/icons/favicon.png | Bin 0 -> 46071 bytes public/images/icons/icon-120x120.png | Bin 0 -> 8804 bytes public/images/icons/icon-152x152.png | Bin 0 -> 12057 bytes public/images/icons/icon-167x167.png | Bin 0 -> 13417 bytes public/images/icons/icon-180x180.png | Bin 0 -> 14447 bytes public/images/icons/icon-192x192.png | Bin 0 -> 15555 bytes public/images/icons/icon-512x512.png | Bin 0 -> 57711 bytes public/index.html | 2 + server.js | 2 +- services/searchService.js | 128 +++++++++++++++------------ 12 files changed, 131 insertions(+), 70 deletions(-) create mode 100644 public/images/icons/favicon.png create mode 100644 public/images/icons/icon-120x120.png create mode 100644 public/images/icons/icon-152x152.png create mode 100644 public/images/icons/icon-167x167.png create mode 100644 public/images/icons/icon-180x180.png create mode 100644 public/images/icons/icon-192x192.png create mode 100644 public/images/icons/icon-512x512.png diff --git a/mssql-mcp-readonly.js b/mssql-mcp-readonly.js index 5e8c929..7785bf5 100644 --- a/mssql-mcp-readonly.js +++ b/mssql-mcp-readonly.js @@ -197,15 +197,38 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { case "search_parts": { const { search_term, limit = 50 } = args; + const escaped = String(search_term).replace(/'/g, "''"); + const pattern = `N'%${escaped}%'`; const searchQuery = ` - SELECT TOP ${parseInt(limit)} - 'TEILE' AS TableName, Teil, Art, Gruppe, Bez, Bez2, Hersteller, WarenNr - FROM TEILE - WHERE - LOWER(CAST(Teil AS NVARCHAR(MAX))) LIKE LOWER('%${search_term.replace(/'/g, "''")}%') - OR LOWER(CAST(Bez AS NVARCHAR(MAX))) LIKE LOWER('%${search_term.replace(/'/g, "''")}%') - OR LOWER(CAST(Bez2 AS NVARCHAR(MAX))) LIKE LOWER('%${search_term.replace(/'/g, "''")}%') - OR LOWER(CAST(Hersteller AS NVARCHAR(MAX))) LIKE LOWER('%${search_term.replace(/'/g, "''")}%') + SELECT TOP ${Math.max(1, parseInt(limit, 10) || 50)} + t.Teil, + t.Bez, + t.Bez2, + t.Ben7, + t.Ben8, + t.Hersteller, + txt.Text AS [Text], + ts.PrsVk AS PrsVK + FROM TEILE t WITH (NOLOCK) + OUTER APPLY ( + SELECT TOP 1 [Text] + FROM TEXT WITH (NOLOCK) + WHERE TextId = t.MemoID + ORDER BY LfdNr + ) txt + OUTER APPLY ( + SELECT TOP 1 PrsVk + FROM TSSAEF WITH (NOLOCK) + WHERE Teil = t.Teil + ORDER BY ISN + ) ts + WHERE + t.Teil LIKE ${pattern} COLLATE SQL_Latin1_General_CP1_CI_AS + OR t.Bez LIKE ${pattern} COLLATE SQL_Latin1_General_CP1_CI_AS + OR t.Bez2 LIKE ${pattern} COLLATE SQL_Latin1_General_CP1_CI_AS + OR t.Ben7 LIKE ${pattern} COLLATE SQL_Latin1_General_CP1_CI_AS + OR t.Ben8 LIKE ${pattern} COLLATE SQL_Latin1_General_CP1_CI_AS + OR t.Hersteller LIKE ${pattern} COLLATE SQL_Latin1_General_CP1_CI_AS `; const rows = await runQuery(searchQuery); return { diff --git a/public/dev.html b/public/dev.html index 98394d5..4e1d431 100644 --- a/public/dev.html +++ b/public/dev.html @@ -3,6 +3,8 @@ + + Infraviewer - Volltextsuche