@mhalder/qdrant-mcp-server 2.1.0 → 2.1.2
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/CHANGELOG.md +12 -0
- package/CONTRIBUTING.md +14 -2
- package/README.md +3 -2
- package/build/code/indexer.d.ts +5 -0
- package/build/code/indexer.d.ts.map +1 -1
- package/build/code/indexer.js +116 -14
- package/build/code/indexer.js.map +1 -1
- package/build/code/types.d.ts +4 -0
- package/build/code/types.d.ts.map +1 -1
- package/build/index.js +28 -831
- package/build/index.js.map +1 -1
- package/build/prompts/register.d.ts +10 -0
- package/build/prompts/register.d.ts.map +1 -0
- package/build/prompts/register.js +50 -0
- package/build/prompts/register.js.map +1 -0
- package/build/resources/index.d.ts +10 -0
- package/build/resources/index.d.ts.map +1 -0
- package/build/resources/index.js +60 -0
- package/build/resources/index.js.map +1 -0
- package/build/tools/code.d.ts +10 -0
- package/build/tools/code.d.ts.map +1 -0
- package/build/tools/code.js +132 -0
- package/build/tools/code.js.map +1 -0
- package/build/tools/collection.d.ts +12 -0
- package/build/tools/collection.d.ts.map +1 -0
- package/build/tools/collection.js +59 -0
- package/build/tools/collection.js.map +1 -0
- package/build/tools/document.d.ts +12 -0
- package/build/tools/document.d.ts.map +1 -0
- package/build/tools/document.js +84 -0
- package/build/tools/document.js.map +1 -0
- package/build/tools/index.d.ts +18 -0
- package/build/tools/index.d.ts.map +1 -0
- package/build/tools/index.js +30 -0
- package/build/tools/index.js.map +1 -0
- package/build/tools/schemas.d.ts +75 -0
- package/build/tools/schemas.d.ts.map +1 -0
- package/build/tools/schemas.js +114 -0
- package/build/tools/schemas.js.map +1 -0
- package/build/tools/search.d.ts +12 -0
- package/build/tools/search.d.ts.map +1 -0
- package/build/tools/search.js +79 -0
- package/build/tools/search.js.map +1 -0
- package/examples/code-search/README.md +19 -4
- package/package.json +1 -1
- package/src/code/indexer.ts +186 -38
- package/src/code/types.ts +5 -0
- package/src/index.ts +26 -983
- package/src/prompts/register.ts +71 -0
- package/src/resources/index.ts +79 -0
- package/src/tools/code.ts +195 -0
- package/src/tools/collection.ts +100 -0
- package/src/tools/document.ts +113 -0
- package/src/tools/index.ts +48 -0
- package/src/tools/schemas.ts +130 -0
- package/src/tools/search.ts +122 -0
- package/tests/code/indexer.test.ts +412 -74
- package/tests/code/integration.test.ts +239 -54
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool registration orchestrator
|
|
3
|
+
*/
|
|
4
|
+
import { registerCodeTools } from "./code.js";
|
|
5
|
+
import { registerCollectionTools } from "./collection.js";
|
|
6
|
+
import { registerDocumentTools } from "./document.js";
|
|
7
|
+
import { registerSearchTools } from "./search.js";
|
|
8
|
+
/**
|
|
9
|
+
* Register all MCP tools on the server
|
|
10
|
+
*/
|
|
11
|
+
export function registerAllTools(server, deps) {
|
|
12
|
+
registerCollectionTools(server, {
|
|
13
|
+
qdrant: deps.qdrant,
|
|
14
|
+
embeddings: deps.embeddings,
|
|
15
|
+
});
|
|
16
|
+
registerDocumentTools(server, {
|
|
17
|
+
qdrant: deps.qdrant,
|
|
18
|
+
embeddings: deps.embeddings,
|
|
19
|
+
});
|
|
20
|
+
registerSearchTools(server, {
|
|
21
|
+
qdrant: deps.qdrant,
|
|
22
|
+
embeddings: deps.embeddings,
|
|
23
|
+
});
|
|
24
|
+
registerCodeTools(server, {
|
|
25
|
+
codeIndexer: deps.codeIndexer,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
// Re-export schemas for external use
|
|
29
|
+
export * from "./schemas.js";
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAQlD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAiB,EACjB,IAAsB;IAEtB,uBAAuB,CAAC,MAAM,EAAE;QAC9B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,UAAU,EAAE,IAAI,CAAC,UAAU;KAC5B,CAAC,CAAC;IAEH,qBAAqB,CAAC,MAAM,EAAE;QAC5B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,UAAU,EAAE,IAAI,CAAC,UAAU;KAC5B,CAAC,CAAC;IAEH,mBAAmB,CAAC,MAAM,EAAE;QAC1B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,UAAU,EAAE,IAAI,CAAC,UAAU;KAC5B,CAAC,CAAC;IAEH,iBAAiB,CAAC,MAAM,EAAE;QACxB,WAAW,EAAE,IAAI,CAAC,WAAW;KAC9B,CAAC,CAAC;AACL,CAAC;AAED,qCAAqC;AACrC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consolidated Zod schemas for all MCP tools
|
|
3
|
+
*
|
|
4
|
+
* Note: Schemas are exported as plain objects (not wrapped in z.object()) because
|
|
5
|
+
* McpServer.registerTool() expects schemas in this format. The SDK internally
|
|
6
|
+
* converts these to JSON Schema for the MCP protocol. Each property is a Zod
|
|
7
|
+
* field definition that gets composed into the final schema by the SDK.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
export declare const CreateCollectionSchema: {
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
distance: z.ZodOptional<z.ZodEnum<["Cosine", "Euclid", "Dot"]>>;
|
|
13
|
+
enableHybrid: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
};
|
|
15
|
+
export declare const DeleteCollectionSchema: {
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
};
|
|
18
|
+
export declare const GetCollectionInfoSchema: {
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
};
|
|
21
|
+
export declare const AddDocumentsSchema: {
|
|
22
|
+
collection: z.ZodString;
|
|
23
|
+
documents: z.ZodArray<z.ZodObject<{
|
|
24
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
25
|
+
text: z.ZodString;
|
|
26
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
id: string | number;
|
|
29
|
+
text: string;
|
|
30
|
+
metadata?: Record<string, any> | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
id: string | number;
|
|
33
|
+
text: string;
|
|
34
|
+
metadata?: Record<string, any> | undefined;
|
|
35
|
+
}>, "many">;
|
|
36
|
+
};
|
|
37
|
+
export declare const DeleteDocumentsSchema: {
|
|
38
|
+
collection: z.ZodString;
|
|
39
|
+
ids: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
|
|
40
|
+
};
|
|
41
|
+
export declare const SemanticSearchSchema: {
|
|
42
|
+
collection: z.ZodString;
|
|
43
|
+
query: z.ZodString;
|
|
44
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
filter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
46
|
+
};
|
|
47
|
+
export declare const HybridSearchSchema: {
|
|
48
|
+
collection: z.ZodString;
|
|
49
|
+
query: z.ZodString;
|
|
50
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
filter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
52
|
+
};
|
|
53
|
+
export declare const IndexCodebaseSchema: {
|
|
54
|
+
path: z.ZodString;
|
|
55
|
+
forceReindex: z.ZodOptional<z.ZodBoolean>;
|
|
56
|
+
extensions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
57
|
+
ignorePatterns: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
58
|
+
};
|
|
59
|
+
export declare const SearchCodeSchema: {
|
|
60
|
+
path: z.ZodString;
|
|
61
|
+
query: z.ZodString;
|
|
62
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
fileTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
64
|
+
pathPattern: z.ZodOptional<z.ZodString>;
|
|
65
|
+
};
|
|
66
|
+
export declare const ReindexChangesSchema: {
|
|
67
|
+
path: z.ZodString;
|
|
68
|
+
};
|
|
69
|
+
export declare const GetIndexStatusSchema: {
|
|
70
|
+
path: z.ZodString;
|
|
71
|
+
};
|
|
72
|
+
export declare const ClearIndexSchema: {
|
|
73
|
+
path: z.ZodString;
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/tools/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,sBAAsB;;;;CAUlC,CAAC;AAEF,eAAO,MAAM,sBAAsB;;CAElC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;CAEnC,CAAC;AAGF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;CAgB9B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;CAKjC,CAAC;AAGF,eAAO,MAAM,oBAAoB;;;;;CAQhC,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;CAQ9B,CAAC;AAGF,eAAO,MAAM,mBAAmB;;;;;CAkB/B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;CAiB5B,CAAC;AAEF,eAAO,MAAM,oBAAoB;;CAEhC,CAAC;AAEF,eAAO,MAAM,oBAAoB;;CAEhC,CAAC;AAEF,eAAO,MAAM,gBAAgB;;CAE5B,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consolidated Zod schemas for all MCP tools
|
|
3
|
+
*
|
|
4
|
+
* Note: Schemas are exported as plain objects (not wrapped in z.object()) because
|
|
5
|
+
* McpServer.registerTool() expects schemas in this format. The SDK internally
|
|
6
|
+
* converts these to JSON Schema for the MCP protocol. Each property is a Zod
|
|
7
|
+
* field definition that gets composed into the final schema by the SDK.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
// Collection management schemas
|
|
11
|
+
export const CreateCollectionSchema = {
|
|
12
|
+
name: z.string().describe("Name of the collection"),
|
|
13
|
+
distance: z
|
|
14
|
+
.enum(["Cosine", "Euclid", "Dot"])
|
|
15
|
+
.optional()
|
|
16
|
+
.describe("Distance metric (default: Cosine)"),
|
|
17
|
+
enableHybrid: z
|
|
18
|
+
.boolean()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("Enable hybrid search with sparse vectors (default: false)"),
|
|
21
|
+
};
|
|
22
|
+
export const DeleteCollectionSchema = {
|
|
23
|
+
name: z.string().describe("Name of the collection to delete"),
|
|
24
|
+
};
|
|
25
|
+
export const GetCollectionInfoSchema = {
|
|
26
|
+
name: z.string().describe("Name of the collection"),
|
|
27
|
+
};
|
|
28
|
+
// Document operation schemas
|
|
29
|
+
export const AddDocumentsSchema = {
|
|
30
|
+
collection: z.string().describe("Name of the collection"),
|
|
31
|
+
documents: z
|
|
32
|
+
.array(z.object({
|
|
33
|
+
id: z
|
|
34
|
+
.union([z.string(), z.number()])
|
|
35
|
+
.describe("Unique identifier for the document"),
|
|
36
|
+
text: z.string().describe("Text content to embed and store"),
|
|
37
|
+
metadata: z
|
|
38
|
+
.record(z.any())
|
|
39
|
+
.optional()
|
|
40
|
+
.describe("Optional metadata to store with the document"),
|
|
41
|
+
}))
|
|
42
|
+
.describe("Array of documents to add"),
|
|
43
|
+
};
|
|
44
|
+
export const DeleteDocumentsSchema = {
|
|
45
|
+
collection: z.string().describe("Name of the collection"),
|
|
46
|
+
ids: z
|
|
47
|
+
.array(z.union([z.string(), z.number()]))
|
|
48
|
+
.describe("Array of document IDs to delete"),
|
|
49
|
+
};
|
|
50
|
+
// Search schemas
|
|
51
|
+
export const SemanticSearchSchema = {
|
|
52
|
+
collection: z.string().describe("Name of the collection to search"),
|
|
53
|
+
query: z.string().describe("Search query text"),
|
|
54
|
+
limit: z
|
|
55
|
+
.number()
|
|
56
|
+
.optional()
|
|
57
|
+
.describe("Maximum number of results (default: 5)"),
|
|
58
|
+
filter: z.record(z.any()).optional().describe("Optional metadata filter"),
|
|
59
|
+
};
|
|
60
|
+
export const HybridSearchSchema = {
|
|
61
|
+
collection: z.string().describe("Name of the collection to search"),
|
|
62
|
+
query: z.string().describe("Search query text"),
|
|
63
|
+
limit: z
|
|
64
|
+
.number()
|
|
65
|
+
.optional()
|
|
66
|
+
.describe("Maximum number of results (default: 5)"),
|
|
67
|
+
filter: z.record(z.any()).optional().describe("Optional metadata filter"),
|
|
68
|
+
};
|
|
69
|
+
// Code indexing schemas
|
|
70
|
+
export const IndexCodebaseSchema = {
|
|
71
|
+
path: z
|
|
72
|
+
.string()
|
|
73
|
+
.describe("Absolute or relative path to codebase root directory"),
|
|
74
|
+
forceReindex: z
|
|
75
|
+
.boolean()
|
|
76
|
+
.optional()
|
|
77
|
+
.describe("Force full re-index even if already indexed (default: false)"),
|
|
78
|
+
extensions: z
|
|
79
|
+
.array(z.string())
|
|
80
|
+
.optional()
|
|
81
|
+
.describe("Custom file extensions to index (e.g., ['.proto', '.graphql'])"),
|
|
82
|
+
ignorePatterns: z
|
|
83
|
+
.array(z.string())
|
|
84
|
+
.optional()
|
|
85
|
+
.describe("Additional patterns to ignore (e.g., ['**/test/**', '**/*.test.ts'])"),
|
|
86
|
+
};
|
|
87
|
+
export const SearchCodeSchema = {
|
|
88
|
+
path: z.string().describe("Path to codebase (must be indexed first)"),
|
|
89
|
+
query: z
|
|
90
|
+
.string()
|
|
91
|
+
.describe("Natural language search query (e.g., 'authentication logic')"),
|
|
92
|
+
limit: z
|
|
93
|
+
.number()
|
|
94
|
+
.optional()
|
|
95
|
+
.describe("Maximum number of results (default: 5, max: 100)"),
|
|
96
|
+
fileTypes: z
|
|
97
|
+
.array(z.string())
|
|
98
|
+
.optional()
|
|
99
|
+
.describe("Filter by file extensions (e.g., ['.ts', '.py'])"),
|
|
100
|
+
pathPattern: z
|
|
101
|
+
.string()
|
|
102
|
+
.optional()
|
|
103
|
+
.describe("Filter by path glob pattern (e.g., 'src/services/**')"),
|
|
104
|
+
};
|
|
105
|
+
export const ReindexChangesSchema = {
|
|
106
|
+
path: z.string().describe("Path to codebase"),
|
|
107
|
+
};
|
|
108
|
+
export const GetIndexStatusSchema = {
|
|
109
|
+
path: z.string().describe("Path to codebase"),
|
|
110
|
+
};
|
|
111
|
+
export const ClearIndexSchema = {
|
|
112
|
+
path: z.string().describe("Path to codebase"),
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/tools/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gCAAgC;AAChC,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IACnD,QAAQ,EAAE,CAAC;SACR,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;SACjC,QAAQ,EAAE;SACV,QAAQ,CAAC,mCAAmC,CAAC;IAChD,YAAY,EAAE,CAAC;SACZ,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,QAAQ,CAAC,2DAA2D,CAAC;CACzE,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GA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AEF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;IACrE,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,QAAQ,CAAC,8DAA8D,CAAC;IAC3E,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,kDAAkD,CAAC;IAC/D,SAAS,EAAE,CAAC;SACT,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,EAAE;SACV,QAAQ,CAAC,kDAAkD,CAAC;IAC/D,WAAW,EAAE,CAAC;SACX,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,uDAAuD,CAAC;CACrE,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;CAC9C,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;CAC9C,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;CAC9C,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search tools registration
|
|
3
|
+
*/
|
|
4
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
import type { EmbeddingProvider } from "../embeddings/base.js";
|
|
6
|
+
import type { QdrantManager } from "../qdrant/client.js";
|
|
7
|
+
export interface SearchToolDependencies {
|
|
8
|
+
qdrant: QdrantManager;
|
|
9
|
+
embeddings: EmbeddingProvider;
|
|
10
|
+
}
|
|
11
|
+
export declare function registerSearchTools(server: McpServer, deps: SearchToolDependencies): void;
|
|
12
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,iBAAiB,CAAC;CAC/B;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,sBAAsB,GAC3B,IAAI,CAuGN"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search tools registration
|
|
3
|
+
*/
|
|
4
|
+
import { BM25SparseVectorGenerator } from "../embeddings/sparse.js";
|
|
5
|
+
import * as schemas from "./schemas.js";
|
|
6
|
+
export function registerSearchTools(server, deps) {
|
|
7
|
+
const { qdrant, embeddings } = deps;
|
|
8
|
+
// semantic_search
|
|
9
|
+
server.registerTool("semantic_search", {
|
|
10
|
+
title: "Semantic Search",
|
|
11
|
+
description: "Search for documents using natural language queries. Returns the most semantically similar documents.",
|
|
12
|
+
inputSchema: schemas.SemanticSearchSchema,
|
|
13
|
+
}, async ({ collection, query, limit, filter }) => {
|
|
14
|
+
// Check if collection exists
|
|
15
|
+
const exists = await qdrant.collectionExists(collection);
|
|
16
|
+
if (!exists) {
|
|
17
|
+
return {
|
|
18
|
+
content: [
|
|
19
|
+
{
|
|
20
|
+
type: "text",
|
|
21
|
+
text: `Error: Collection "${collection}" does not exist.`,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
isError: true,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
// Generate embedding for query
|
|
28
|
+
const { embedding } = await embeddings.embed(query);
|
|
29
|
+
// Search
|
|
30
|
+
const results = await qdrant.search(collection, embedding, limit || 5, filter);
|
|
31
|
+
return {
|
|
32
|
+
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
// hybrid_search
|
|
36
|
+
server.registerTool("hybrid_search", {
|
|
37
|
+
title: "Hybrid Search",
|
|
38
|
+
description: "Perform hybrid search combining semantic vector search with keyword search using BM25. This provides better results by combining the strengths of both approaches. The collection must be created with enableHybrid set to true.",
|
|
39
|
+
inputSchema: schemas.HybridSearchSchema,
|
|
40
|
+
}, async ({ collection, query, limit, filter }) => {
|
|
41
|
+
// Check if collection exists
|
|
42
|
+
const exists = await qdrant.collectionExists(collection);
|
|
43
|
+
if (!exists) {
|
|
44
|
+
return {
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
type: "text",
|
|
48
|
+
text: `Error: Collection "${collection}" does not exist.`,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
isError: true,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Check if collection has hybrid search enabled
|
|
55
|
+
const collectionInfo = await qdrant.getCollectionInfo(collection);
|
|
56
|
+
if (!collectionInfo.hybridEnabled) {
|
|
57
|
+
return {
|
|
58
|
+
content: [
|
|
59
|
+
{
|
|
60
|
+
type: "text",
|
|
61
|
+
text: `Error: Collection "${collection}" does not have hybrid search enabled. Create a new collection with enableHybrid set to true.`,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
isError: true,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// Generate dense embedding for query
|
|
68
|
+
const { embedding } = await embeddings.embed(query);
|
|
69
|
+
// Generate sparse vector for query
|
|
70
|
+
const sparseGenerator = new BM25SparseVectorGenerator();
|
|
71
|
+
const sparseVector = sparseGenerator.generate(query);
|
|
72
|
+
// Perform hybrid search
|
|
73
|
+
const results = await qdrant.hybridSearch(collection, embedding, sparseVector, limit || 5, filter);
|
|
74
|
+
return {
|
|
75
|
+
content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEpE,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAOxC,MAAM,UAAU,mBAAmB,CACjC,MAAiB,EACjB,IAA4B;IAE5B,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAEpC,kBAAkB;IAClB,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,iBAAiB;QACxB,WAAW,EACT,uGAAuG;QACzG,WAAW,EAAE,OAAO,CAAC,oBAAoB;KAC1C,EACD,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;QAC7C,6BAA6B;QAC7B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,sBAAsB,UAAU,mBAAmB;qBAC1D;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,+BAA+B;QAC/B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEpD,SAAS;QACT,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,MAAM,CACjC,UA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,MAAM,YAAY,GAAG,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAErD,wBAAwB;QACxB,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,YAAY,CACvC,UAAU,EACV,SAAS,EACT,YAAY,EACZ,KAAK,IAAI,CAAC,EACV,MAAM,CACP,CAAC;QAEF,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;SACpE,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -69,21 +69,31 @@ After making changes to your codebase:
|
|
|
69
69
|
|
|
70
70
|
## Example 5: Check Index Status
|
|
71
71
|
|
|
72
|
+
The index status tracks three states: `not_indexed`, `indexing`, and `indexed`.
|
|
73
|
+
|
|
72
74
|
```bash
|
|
73
|
-
#
|
|
75
|
+
# Check status before indexing
|
|
76
|
+
/mcp__qdrant__get_index_status /path/to/your/project
|
|
77
|
+
# Output: Codebase at "/path/to/your/project" is not indexed. Use index_codebase to index it first.
|
|
78
|
+
|
|
79
|
+
# Check status during indexing (in another terminal/session)
|
|
74
80
|
/mcp__qdrant__get_index_status /path/to/your/project
|
|
81
|
+
# Output: Codebase at "/path/to/your/project" is currently being indexed. 523 chunks processed so far.
|
|
75
82
|
|
|
83
|
+
# Check status after indexing completes
|
|
84
|
+
/mcp__qdrant__get_index_status /path/to/your/project
|
|
76
85
|
# Output:
|
|
77
86
|
# {
|
|
78
87
|
# "isIndexed": true,
|
|
88
|
+
# "status": "indexed",
|
|
79
89
|
# "collectionName": "code_a3f8d2e1",
|
|
80
90
|
# "chunksCount": 1823,
|
|
81
|
-
# "
|
|
82
|
-
# "lastUpdated": "2025-01-30T10:15:00Z",
|
|
83
|
-
# "languages": ["typescript", "javascript", "json"]
|
|
91
|
+
# "lastUpdated": "2025-01-30T10:15:00Z"
|
|
84
92
|
# }
|
|
85
93
|
```
|
|
86
94
|
|
|
95
|
+
This is useful for monitoring long-running indexing operations on large codebases.
|
|
96
|
+
|
|
87
97
|
## Example 6: Multi-Language Project
|
|
88
98
|
|
|
89
99
|
For projects with multiple languages:
|
|
@@ -225,6 +235,11 @@ export EMBEDDING_PROVIDER=ollama
|
|
|
225
235
|
# Check if codebase is indexed
|
|
226
236
|
/mcp__qdrant__get_index_status /path/to/your/project
|
|
227
237
|
|
|
238
|
+
# Possible status responses:
|
|
239
|
+
# - "not indexed" → Run index_codebase first
|
|
240
|
+
# - "currently being indexed" → Wait for indexing to complete
|
|
241
|
+
# - JSON with status: "indexed" → Codebase is ready for search
|
|
242
|
+
|
|
228
243
|
# If not indexed:
|
|
229
244
|
/mcp__qdrant__index_codebase /path/to/your/project
|
|
230
245
|
|
package/package.json
CHANGED