domain-rag-mcp-server 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +137 -58
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// src/index.ts
|
|
3
|
+
// ../domain-rag-system/mcp-server/src/index.ts
|
|
4
4
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
6
|
import {
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { QdrantClient } from "@qdrant/js-client-rest";
|
|
11
11
|
import { v4 as uuidv4 } from "uuid";
|
|
12
12
|
|
|
13
|
-
// ../shared/src/config.ts
|
|
13
|
+
// ../domain-rag-system/shared/src/config.ts
|
|
14
14
|
import { config as dotenvConfig } from "dotenv";
|
|
15
15
|
import { existsSync } from "fs";
|
|
16
16
|
import { join } from "path";
|
|
@@ -240,7 +240,7 @@ function getSourceWeightsMap() {
|
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
// ../shared/src/embeddings/types.ts
|
|
243
|
+
// ../domain-rag-system/shared/src/embeddings/types.ts
|
|
244
244
|
var BaseEmbeddingProvider = class {
|
|
245
245
|
/**
|
|
246
246
|
* Default batch implementation - calls getEmbedding sequentially
|
|
@@ -256,7 +256,7 @@ var BaseEmbeddingProvider = class {
|
|
|
256
256
|
}
|
|
257
257
|
};
|
|
258
258
|
|
|
259
|
-
// ../shared/src/embeddings/ollama.ts
|
|
259
|
+
// ../domain-rag-system/shared/src/embeddings/ollama.ts
|
|
260
260
|
var OllamaProvider = class extends BaseEmbeddingProvider {
|
|
261
261
|
name = "ollama";
|
|
262
262
|
dimensions;
|
|
@@ -320,7 +320,7 @@ var OllamaProvider = class extends BaseEmbeddingProvider {
|
|
|
320
320
|
}
|
|
321
321
|
};
|
|
322
322
|
|
|
323
|
-
// ../shared/src/embeddings/openai.ts
|
|
323
|
+
// ../domain-rag-system/shared/src/embeddings/openai.ts
|
|
324
324
|
var OpenAIProvider = class extends BaseEmbeddingProvider {
|
|
325
325
|
name = "openai";
|
|
326
326
|
dimensions;
|
|
@@ -405,7 +405,7 @@ var OpenAIProvider = class extends BaseEmbeddingProvider {
|
|
|
405
405
|
}
|
|
406
406
|
};
|
|
407
407
|
|
|
408
|
-
// ../shared/src/embeddings/factory.ts
|
|
408
|
+
// ../domain-rag-system/shared/src/embeddings/factory.ts
|
|
409
409
|
function createEmbeddingProvider() {
|
|
410
410
|
const providerType = config.embeddings.provider;
|
|
411
411
|
switch (providerType) {
|
|
@@ -436,7 +436,7 @@ function getEmbeddingProvider() {
|
|
|
436
436
|
return _provider;
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
-
// ../shared/src/postgres/client.ts
|
|
439
|
+
// ../domain-rag-system/shared/src/postgres/client.ts
|
|
440
440
|
import pg from "pg";
|
|
441
441
|
var { Pool } = pg;
|
|
442
442
|
var pool = null;
|
|
@@ -484,7 +484,7 @@ async function checkHealth() {
|
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
486
|
|
|
487
|
-
// ../shared/src/postgres/search.ts
|
|
487
|
+
// ../domain-rag-system/shared/src/postgres/search.ts
|
|
488
488
|
async function searchAll(searchQuery, options = {}) {
|
|
489
489
|
const { limit = 30, sources } = options;
|
|
490
490
|
const includeJira = !sources || sources.includes("jira");
|
|
@@ -737,7 +737,7 @@ async function getStats() {
|
|
|
737
737
|
};
|
|
738
738
|
}
|
|
739
739
|
|
|
740
|
-
// src/index.ts
|
|
740
|
+
// ../domain-rag-system/mcp-server/src/index.ts
|
|
741
741
|
var SOURCE_WEIGHTS = getSourceWeightsMap();
|
|
742
742
|
var qdrant = new QdrantClient({
|
|
743
743
|
url: config.qdrant.url,
|
|
@@ -842,59 +842,13 @@ async function initPostgres() {
|
|
|
842
842
|
}
|
|
843
843
|
var tools = [
|
|
844
844
|
// ============================================
|
|
845
|
-
//
|
|
846
|
-
// Direct search on server filesystem repositories
|
|
847
|
-
// ============================================
|
|
848
|
-
{
|
|
849
|
-
name: "search_server_code",
|
|
850
|
-
description: "HIGHEST PRIORITY - Search source code on the server. Searches across all indexed repositories. Use for finding implementations, classes, functions, or any code patterns. Much faster than vector search for exact matches.",
|
|
851
|
-
inputSchema: {
|
|
852
|
-
type: "object",
|
|
853
|
-
properties: {
|
|
854
|
-
query: {
|
|
855
|
-
type: "string",
|
|
856
|
-
description: "Search query - code pattern, class name, function, or text to find"
|
|
857
|
-
},
|
|
858
|
-
mode: {
|
|
859
|
-
type: "string",
|
|
860
|
-
enum: ["content", "filename"],
|
|
861
|
-
description: 'Search mode: "content" for grep-like search in file contents, "filename" for file name pattern matching',
|
|
862
|
-
default: "content"
|
|
863
|
-
},
|
|
864
|
-
repos: {
|
|
865
|
-
type: "array",
|
|
866
|
-
items: { type: "string" },
|
|
867
|
-
description: 'Filter by repository names (optional). Example: ["frontend", "backend"]'
|
|
868
|
-
},
|
|
869
|
-
extensions: {
|
|
870
|
-
type: "array",
|
|
871
|
-
items: { type: "string" },
|
|
872
|
-
description: 'File extensions to search (optional). Example: [".ts", ".cs"]'
|
|
873
|
-
},
|
|
874
|
-
limit: {
|
|
875
|
-
type: "number",
|
|
876
|
-
description: "Maximum results (default: 20)",
|
|
877
|
-
default: 20
|
|
878
|
-
}
|
|
879
|
-
},
|
|
880
|
-
required: ["query"]
|
|
881
|
-
}
|
|
882
|
-
},
|
|
883
|
-
{
|
|
884
|
-
name: "list_server_repos",
|
|
885
|
-
description: "List all source code repositories available on the server for code search.",
|
|
886
|
-
inputSchema: {
|
|
887
|
-
type: "object",
|
|
888
|
-
properties: {}
|
|
889
|
-
}
|
|
890
|
-
},
|
|
891
|
-
// ============================================
|
|
892
|
-
// PostgreSQL Structured Search Tools (High Priority)
|
|
845
|
+
// PostgreSQL Structured Search Tools (HIGHEST PRIORITY)
|
|
893
846
|
// These provide SQL-based search with structured data
|
|
847
|
+
// Lightweight, fast, and context-friendly
|
|
894
848
|
// ============================================
|
|
895
849
|
{
|
|
896
850
|
name: "search_structured",
|
|
897
|
-
description: "HIGHEST PRIORITY - Search structured Jira/Confluence data in PostgreSQL. Returns well-organized results with full metadata. Use this
|
|
851
|
+
description: "HIGHEST PRIORITY - Search structured Jira/Confluence data in PostgreSQL. Returns well-organized results with full metadata. Use this FIRST for any business or documentation queries. Lightweight and context-friendly.",
|
|
898
852
|
inputSchema: {
|
|
899
853
|
type: "object",
|
|
900
854
|
properties: {
|
|
@@ -1034,6 +988,25 @@ var tools = [
|
|
|
1034
988
|
properties: {}
|
|
1035
989
|
}
|
|
1036
990
|
},
|
|
991
|
+
{
|
|
992
|
+
name: "raw_sql",
|
|
993
|
+
description: "Execute a raw SQL SELECT query on PostgreSQL database. ONLY SELECT queries are allowed. Use for complex queries that other tools cannot handle. Tables: persons, jira_projects, jira_issues, confluence_spaces, confluence_pages, git_commits, jira_issue_commits.",
|
|
994
|
+
inputSchema: {
|
|
995
|
+
type: "object",
|
|
996
|
+
properties: {
|
|
997
|
+
sql: {
|
|
998
|
+
type: "string",
|
|
999
|
+
description: "SQL SELECT query to execute. Example: SELECT issue_key, summary FROM jira_issues WHERE status = 'Done' LIMIT 10"
|
|
1000
|
+
},
|
|
1001
|
+
params: {
|
|
1002
|
+
type: "array",
|
|
1003
|
+
items: { type: "string" },
|
|
1004
|
+
description: "Query parameters for parameterized queries (optional). Use $1, $2, etc. in SQL."
|
|
1005
|
+
}
|
|
1006
|
+
},
|
|
1007
|
+
required: ["sql"]
|
|
1008
|
+
}
|
|
1009
|
+
},
|
|
1037
1010
|
// ============================================
|
|
1038
1011
|
// Vector Search Tools (Qdrant)
|
|
1039
1012
|
// ============================================
|
|
@@ -1234,6 +1207,56 @@ var tools = [
|
|
|
1234
1207
|
type: "object",
|
|
1235
1208
|
properties: {}
|
|
1236
1209
|
}
|
|
1210
|
+
},
|
|
1211
|
+
// ============================================
|
|
1212
|
+
// Server Code Search Tools (LOW PRIORITY - use last)
|
|
1213
|
+
// Direct grep on server filesystem repositories
|
|
1214
|
+
// WARNING: Returns large responses that consume context window.
|
|
1215
|
+
// Prefer search_as_architect, search_structured, or search_knowledge first.
|
|
1216
|
+
// Only use this for targeted lookups (exact class name, specific file).
|
|
1217
|
+
// ============================================
|
|
1218
|
+
{
|
|
1219
|
+
name: "search_server_code",
|
|
1220
|
+
description: "LOW PRIORITY - Direct grep search on server source code repositories. WARNING: returns large responses that consume AI context window quickly. Use search_as_architect or search_structured FIRST. Only use this tool as a LAST RESORT for targeted lookups when you need exact code matches (specific class name, function signature, or file) and other tools did not return enough detail. Always specify repos[] filter and keep limit low (5-10).",
|
|
1221
|
+
inputSchema: {
|
|
1222
|
+
type: "object",
|
|
1223
|
+
properties: {
|
|
1224
|
+
query: {
|
|
1225
|
+
type: "string",
|
|
1226
|
+
description: "Search query - code pattern, class name, function, or text to find"
|
|
1227
|
+
},
|
|
1228
|
+
mode: {
|
|
1229
|
+
type: "string",
|
|
1230
|
+
enum: ["content", "filename"],
|
|
1231
|
+
description: 'Search mode: "content" for grep-like search in file contents, "filename" for file name pattern matching',
|
|
1232
|
+
default: "content"
|
|
1233
|
+
},
|
|
1234
|
+
repos: {
|
|
1235
|
+
type: "array",
|
|
1236
|
+
items: { type: "string" },
|
|
1237
|
+
description: 'Filter by repository names (RECOMMENDED to reduce response size). Example: ["frontend", "backend"]'
|
|
1238
|
+
},
|
|
1239
|
+
extensions: {
|
|
1240
|
+
type: "array",
|
|
1241
|
+
items: { type: "string" },
|
|
1242
|
+
description: 'File extensions to search (optional). Example: [".ts", ".cs"]'
|
|
1243
|
+
},
|
|
1244
|
+
limit: {
|
|
1245
|
+
type: "number",
|
|
1246
|
+
description: "Maximum results (default: 10, keep low to avoid context overflow)",
|
|
1247
|
+
default: 10
|
|
1248
|
+
}
|
|
1249
|
+
},
|
|
1250
|
+
required: ["query"]
|
|
1251
|
+
}
|
|
1252
|
+
},
|
|
1253
|
+
{
|
|
1254
|
+
name: "list_server_repos",
|
|
1255
|
+
description: "List all source code repositories available on the server for code search.",
|
|
1256
|
+
inputSchema: {
|
|
1257
|
+
type: "object",
|
|
1258
|
+
properties: {}
|
|
1259
|
+
}
|
|
1237
1260
|
}
|
|
1238
1261
|
];
|
|
1239
1262
|
async function handleSearchServerCode(args) {
|
|
@@ -1565,6 +1588,59 @@ async function handleGetDbStats() {
|
|
|
1565
1588
|
}
|
|
1566
1589
|
return response;
|
|
1567
1590
|
}
|
|
1591
|
+
async function handleRawSql(args) {
|
|
1592
|
+
if (!pgAvailable) {
|
|
1593
|
+
return "PostgreSQL not available.";
|
|
1594
|
+
}
|
|
1595
|
+
const normalizedSql = args.sql.trim().toLowerCase();
|
|
1596
|
+
if (!normalizedSql.startsWith("select")) {
|
|
1597
|
+
return "Error: Only SELECT queries are allowed. Use SELECT to query data.";
|
|
1598
|
+
}
|
|
1599
|
+
const dangerousKeywords = ["insert", "update", "delete", "drop", "truncate", "alter", "create", "grant", "revoke"];
|
|
1600
|
+
for (const keyword of dangerousKeywords) {
|
|
1601
|
+
if (normalizedSql.includes(keyword)) {
|
|
1602
|
+
return `Error: Query contains forbidden keyword "${keyword}". Only SELECT queries are allowed.`;
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
try {
|
|
1606
|
+
const result = await query(args.sql, args.params);
|
|
1607
|
+
if (result.rows.length === 0) {
|
|
1608
|
+
return "Query returned no results.";
|
|
1609
|
+
}
|
|
1610
|
+
const columns = Object.keys(result.rows[0]);
|
|
1611
|
+
let response = `## Query Results
|
|
1612
|
+
|
|
1613
|
+
`;
|
|
1614
|
+
response += `Rows: ${result.rows.length}
|
|
1615
|
+
|
|
1616
|
+
`;
|
|
1617
|
+
response += "| " + columns.join(" | ") + " |\n";
|
|
1618
|
+
response += "|" + columns.map(() => "---").join("|") + "|\n";
|
|
1619
|
+
const maxRows = Math.min(result.rows.length, 100);
|
|
1620
|
+
for (let i = 0; i < maxRows; i++) {
|
|
1621
|
+
const row = result.rows[i];
|
|
1622
|
+
const values = columns.map((col) => {
|
|
1623
|
+
const val = row[col];
|
|
1624
|
+
if (val === null)
|
|
1625
|
+
return "NULL";
|
|
1626
|
+
if (typeof val === "object")
|
|
1627
|
+
return JSON.stringify(val).substring(0, 100);
|
|
1628
|
+
const str = String(val);
|
|
1629
|
+
return str.length > 100 ? str.substring(0, 100) + "..." : str;
|
|
1630
|
+
});
|
|
1631
|
+
response += "| " + values.join(" | ") + " |\n";
|
|
1632
|
+
}
|
|
1633
|
+
if (result.rows.length > 100) {
|
|
1634
|
+
response += `
|
|
1635
|
+
*Showing first 100 of ${result.rows.length} rows*
|
|
1636
|
+
`;
|
|
1637
|
+
}
|
|
1638
|
+
return response;
|
|
1639
|
+
} catch (error) {
|
|
1640
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
1641
|
+
return `SQL Error: ${message}`;
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1568
1644
|
async function handleSearchAsAnalyst(args) {
|
|
1569
1645
|
const results = await searchWithWeights({
|
|
1570
1646
|
query: args.query,
|
|
@@ -1777,6 +1853,9 @@ async function main() {
|
|
|
1777
1853
|
case "get_db_stats":
|
|
1778
1854
|
result = await handleGetDbStats();
|
|
1779
1855
|
break;
|
|
1856
|
+
case "raw_sql":
|
|
1857
|
+
result = await handleRawSql(args);
|
|
1858
|
+
break;
|
|
1780
1859
|
case "search_as_analyst":
|
|
1781
1860
|
result = await handleSearchAsAnalyst(args);
|
|
1782
1861
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "domain-rag-mcp-server",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "MCP server for domain RAG search — connects to Qdrant + PostgreSQL + Code Search API for hybrid search across Jira, Confluence, Git commits, and server-side code repositories",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|