@mhalder/qdrant-mcp-server 1.3.1 → 1.5.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/.codecov.yml +16 -0
- package/CHANGELOG.md +25 -0
- package/README.md +304 -9
- package/build/code/chunker/base.d.ts +19 -0
- package/build/code/chunker/base.d.ts.map +1 -0
- package/build/code/chunker/base.js +5 -0
- package/build/code/chunker/base.js.map +1 -0
- package/build/code/chunker/character-chunker.d.ts +22 -0
- package/build/code/chunker/character-chunker.d.ts.map +1 -0
- package/build/code/chunker/character-chunker.js +111 -0
- package/build/code/chunker/character-chunker.js.map +1 -0
- package/build/code/chunker/tree-sitter-chunker.d.ts +29 -0
- package/build/code/chunker/tree-sitter-chunker.d.ts.map +1 -0
- package/build/code/chunker/tree-sitter-chunker.js +213 -0
- package/build/code/chunker/tree-sitter-chunker.js.map +1 -0
- package/build/code/config.d.ts +11 -0
- package/build/code/config.d.ts.map +1 -0
- package/build/code/config.js +145 -0
- package/build/code/config.js.map +1 -0
- package/build/code/indexer.d.ts +42 -0
- package/build/code/indexer.d.ts.map +1 -0
- package/build/code/indexer.js +508 -0
- package/build/code/indexer.js.map +1 -0
- package/build/code/metadata.d.ts +32 -0
- package/build/code/metadata.d.ts.map +1 -0
- package/build/code/metadata.js +128 -0
- package/build/code/metadata.js.map +1 -0
- package/build/code/scanner.d.ts +35 -0
- package/build/code/scanner.d.ts.map +1 -0
- package/build/code/scanner.js +108 -0
- package/build/code/scanner.js.map +1 -0
- package/build/code/sync/merkle.d.ts +45 -0
- package/build/code/sync/merkle.d.ts.map +1 -0
- package/build/code/sync/merkle.js +116 -0
- package/build/code/sync/merkle.js.map +1 -0
- package/build/code/sync/snapshot.d.ts +41 -0
- package/build/code/sync/snapshot.d.ts.map +1 -0
- package/build/code/sync/snapshot.js +91 -0
- package/build/code/sync/snapshot.js.map +1 -0
- package/build/code/sync/synchronizer.d.ts +53 -0
- package/build/code/sync/synchronizer.d.ts.map +1 -0
- package/build/code/sync/synchronizer.js +132 -0
- package/build/code/sync/synchronizer.js.map +1 -0
- package/build/code/types.d.ts +98 -0
- package/build/code/types.d.ts.map +1 -0
- package/build/code/types.js +5 -0
- package/build/code/types.js.map +1 -0
- package/build/index.js +321 -6
- package/build/index.js.map +1 -1
- package/build/prompts/index.d.ts +7 -0
- package/build/prompts/index.d.ts.map +1 -0
- package/build/prompts/index.js +7 -0
- package/build/prompts/index.js.map +1 -0
- package/build/prompts/index.test.d.ts +2 -0
- package/build/prompts/index.test.d.ts.map +1 -0
- package/build/prompts/index.test.js +25 -0
- package/build/prompts/index.test.js.map +1 -0
- package/build/prompts/loader.d.ts +25 -0
- package/build/prompts/loader.d.ts.map +1 -0
- package/build/prompts/loader.js +81 -0
- package/build/prompts/loader.js.map +1 -0
- package/build/prompts/loader.test.d.ts +2 -0
- package/build/prompts/loader.test.d.ts.map +1 -0
- package/build/prompts/loader.test.js +417 -0
- package/build/prompts/loader.test.js.map +1 -0
- package/build/prompts/template.d.ts +20 -0
- package/build/prompts/template.d.ts.map +1 -0
- package/build/prompts/template.js +52 -0
- package/build/prompts/template.js.map +1 -0
- package/build/prompts/template.test.d.ts +2 -0
- package/build/prompts/template.test.d.ts.map +1 -0
- package/build/prompts/template.test.js +163 -0
- package/build/prompts/template.test.js.map +1 -0
- package/build/prompts/types.d.ts +34 -0
- package/build/prompts/types.d.ts.map +1 -0
- package/build/prompts/types.js +5 -0
- package/build/prompts/types.js.map +1 -0
- package/examples/code-search/README.md +271 -0
- package/package.json +13 -1
- package/prompts.example.json +96 -0
- package/src/code/chunker/base.ts +22 -0
- package/src/code/chunker/character-chunker.ts +131 -0
- package/src/code/chunker/tree-sitter-chunker.ts +250 -0
- package/src/code/config.ts +156 -0
- package/src/code/indexer.ts +613 -0
- package/src/code/metadata.ts +153 -0
- package/src/code/scanner.ts +124 -0
- package/src/code/sync/merkle.ts +136 -0
- package/src/code/sync/snapshot.ts +110 -0
- package/src/code/sync/synchronizer.ts +154 -0
- package/src/code/types.ts +117 -0
- package/src/index.ts +382 -5
- package/src/prompts/index.test.ts +29 -0
- package/src/prompts/index.ts +7 -0
- package/src/prompts/loader.test.ts +494 -0
- package/src/prompts/loader.ts +90 -0
- package/src/prompts/template.test.ts +212 -0
- package/src/prompts/template.ts +69 -0
- package/src/prompts/types.ts +37 -0
- package/tests/code/chunker/character-chunker.test.ts +141 -0
- package/tests/code/chunker/tree-sitter-chunker.test.ts +275 -0
- package/tests/code/fixtures/sample-py/calculator.py +32 -0
- package/tests/code/fixtures/sample-ts/async-operations.ts +120 -0
- package/tests/code/fixtures/sample-ts/auth.ts +31 -0
- package/tests/code/fixtures/sample-ts/config.ts +52 -0
- package/tests/code/fixtures/sample-ts/database.ts +50 -0
- package/tests/code/fixtures/sample-ts/index.ts +39 -0
- package/tests/code/fixtures/sample-ts/types-advanced.ts +132 -0
- package/tests/code/fixtures/sample-ts/utils.ts +105 -0
- package/tests/code/fixtures/sample-ts/validator.ts +169 -0
- package/tests/code/indexer.test.ts +828 -0
- package/tests/code/integration.test.ts +708 -0
- package/tests/code/metadata.test.ts +457 -0
- package/tests/code/scanner.test.ts +131 -0
- package/tests/code/sync/merkle.test.ts +406 -0
- package/tests/code/sync/snapshot.test.ts +360 -0
- package/tests/code/sync/synchronizer.test.ts +501 -0
- package/vitest.config.ts +1 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { renderTemplate, validateArguments } from "./template.js";
|
|
3
|
+
describe("renderTemplate", () => {
|
|
4
|
+
it("should render template with provided arguments", () => {
|
|
5
|
+
const template = "Search {{collection}} for {{query}}";
|
|
6
|
+
const args = { collection: "papers", query: "machine learning" };
|
|
7
|
+
const result = renderTemplate(template, args);
|
|
8
|
+
expect(result.text).toBe("Search papers for machine learning");
|
|
9
|
+
});
|
|
10
|
+
it("should handle multiple occurrences of the same variable", () => {
|
|
11
|
+
const template = "{{name}} said hello. {{name}} said goodbye.";
|
|
12
|
+
const args = { name: "Alice" };
|
|
13
|
+
const result = renderTemplate(template, args);
|
|
14
|
+
expect(result.text).toBe("Alice said hello. Alice said goodbye.");
|
|
15
|
+
});
|
|
16
|
+
it("should use default values for missing arguments", () => {
|
|
17
|
+
const template = "Return {{limit}} results";
|
|
18
|
+
const args = {};
|
|
19
|
+
const definitions = [
|
|
20
|
+
{ name: "limit", description: "Number of results", required: false, default: "5" },
|
|
21
|
+
];
|
|
22
|
+
const result = renderTemplate(template, args, definitions);
|
|
23
|
+
expect(result.text).toBe("Return 5 results");
|
|
24
|
+
});
|
|
25
|
+
it("should prefer provided arguments over defaults", () => {
|
|
26
|
+
const template = "Return {{limit}} results";
|
|
27
|
+
const args = { limit: "10" };
|
|
28
|
+
const definitions = [
|
|
29
|
+
{ name: "limit", description: "Number of results", required: false, default: "5" },
|
|
30
|
+
];
|
|
31
|
+
const result = renderTemplate(template, args, definitions);
|
|
32
|
+
expect(result.text).toBe("Return 10 results");
|
|
33
|
+
});
|
|
34
|
+
it("should keep placeholder if no value and no default", () => {
|
|
35
|
+
const template = "Search {{collection}} for {{query}}";
|
|
36
|
+
const args = { collection: "papers" };
|
|
37
|
+
const result = renderTemplate(template, args);
|
|
38
|
+
expect(result.text).toBe("Search papers for {{query}}");
|
|
39
|
+
});
|
|
40
|
+
it("should handle templates with no placeholders", () => {
|
|
41
|
+
const template = "This is a plain text template";
|
|
42
|
+
const args = { foo: "bar" };
|
|
43
|
+
const result = renderTemplate(template, args);
|
|
44
|
+
expect(result.text).toBe("This is a plain text template");
|
|
45
|
+
});
|
|
46
|
+
it("should handle empty template", () => {
|
|
47
|
+
const template = "";
|
|
48
|
+
const args = { foo: "bar" };
|
|
49
|
+
const result = renderTemplate(template, args);
|
|
50
|
+
expect(result.text).toBe("");
|
|
51
|
+
});
|
|
52
|
+
it("should handle empty args", () => {
|
|
53
|
+
const template = "Search {{collection}}";
|
|
54
|
+
const result = renderTemplate(template);
|
|
55
|
+
expect(result.text).toBe("Search {{collection}}");
|
|
56
|
+
});
|
|
57
|
+
it("should handle complex template with multiple variables and defaults", () => {
|
|
58
|
+
const template = "Search the '{{collection}}' collection for documents similar to: '{{query}}'. Return the top {{limit}} most relevant results.";
|
|
59
|
+
const args = { collection: "papers", query: "neural networks" };
|
|
60
|
+
const definitions = [
|
|
61
|
+
{ name: "collection", description: "Collection name", required: true },
|
|
62
|
+
{ name: "query", description: "Search query", required: true },
|
|
63
|
+
{ name: "limit", description: "Number of results", required: false, default: "5" },
|
|
64
|
+
];
|
|
65
|
+
const result = renderTemplate(template, args, definitions);
|
|
66
|
+
expect(result.text).toBe("Search the 'papers' collection for documents similar to: 'neural networks'. Return the top 5 most relevant results.");
|
|
67
|
+
});
|
|
68
|
+
it("should handle special characters in argument values", () => {
|
|
69
|
+
const template = "Query: {{query}}";
|
|
70
|
+
const args = { query: "What is $100 + $200?" };
|
|
71
|
+
const result = renderTemplate(template, args);
|
|
72
|
+
expect(result.text).toBe("Query: What is $100 + $200?");
|
|
73
|
+
});
|
|
74
|
+
it("should handle numeric-like values as strings", () => {
|
|
75
|
+
const template = "ID: {{id}}, Count: {{count}}";
|
|
76
|
+
const args = { id: "123", count: "456" };
|
|
77
|
+
const result = renderTemplate(template, args);
|
|
78
|
+
expect(result.text).toBe("ID: 123, Count: 456");
|
|
79
|
+
});
|
|
80
|
+
it("should handle whitespace in variable names", () => {
|
|
81
|
+
const template = "Value: {{key}}";
|
|
82
|
+
const args = { key: " spaced " };
|
|
83
|
+
const result = renderTemplate(template, args);
|
|
84
|
+
expect(result.text).toBe("Value: spaced ");
|
|
85
|
+
});
|
|
86
|
+
it("should not match invalid placeholder patterns", () => {
|
|
87
|
+
const template = "{{ invalid }} {missing} {{also invalid}} {{valid}}";
|
|
88
|
+
const args = { valid: "yes" };
|
|
89
|
+
const result = renderTemplate(template, args);
|
|
90
|
+
// Only {{valid}} should be replaced, others don't match \w+ pattern
|
|
91
|
+
expect(result.text).toBe("{{ invalid }} {missing} {{also invalid}} yes");
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe("validateArguments", () => {
|
|
95
|
+
it("should pass validation when all required arguments are provided", () => {
|
|
96
|
+
const args = { collection: "papers", query: "test" };
|
|
97
|
+
const definitions = [
|
|
98
|
+
{ name: "collection", description: "Collection name", required: true },
|
|
99
|
+
{ name: "query", description: "Search query", required: true },
|
|
100
|
+
];
|
|
101
|
+
expect(() => validateArguments(args, definitions)).not.toThrow();
|
|
102
|
+
});
|
|
103
|
+
it("should throw error when required argument is missing", () => {
|
|
104
|
+
const args = { collection: "papers" };
|
|
105
|
+
const definitions = [
|
|
106
|
+
{ name: "collection", description: "Collection name", required: true },
|
|
107
|
+
{ name: "query", description: "Search query", required: true },
|
|
108
|
+
];
|
|
109
|
+
expect(() => validateArguments(args, definitions)).toThrow("Missing required arguments: query");
|
|
110
|
+
});
|
|
111
|
+
it("should throw error when required argument is empty string", () => {
|
|
112
|
+
const args = { collection: "papers", query: "" };
|
|
113
|
+
const definitions = [
|
|
114
|
+
{ name: "collection", description: "Collection name", required: true },
|
|
115
|
+
{ name: "query", description: "Search query", required: true },
|
|
116
|
+
];
|
|
117
|
+
expect(() => validateArguments(args, definitions)).toThrow("Missing required arguments: query");
|
|
118
|
+
});
|
|
119
|
+
it("should throw error listing multiple missing arguments", () => {
|
|
120
|
+
const args = {};
|
|
121
|
+
const definitions = [
|
|
122
|
+
{ name: "collection", description: "Collection name", required: true },
|
|
123
|
+
{ name: "query", description: "Search query", required: true },
|
|
124
|
+
{ name: "filter", description: "Filter", required: true },
|
|
125
|
+
];
|
|
126
|
+
expect(() => validateArguments(args, definitions)).toThrow("Missing required arguments: collection, query, filter");
|
|
127
|
+
});
|
|
128
|
+
it("should not throw for missing optional arguments", () => {
|
|
129
|
+
const args = { collection: "papers", query: "test" };
|
|
130
|
+
const definitions = [
|
|
131
|
+
{ name: "collection", description: "Collection name", required: true },
|
|
132
|
+
{ name: "query", description: "Search query", required: true },
|
|
133
|
+
{ name: "limit", description: "Limit", required: false, default: "5" },
|
|
134
|
+
];
|
|
135
|
+
expect(() => validateArguments(args, definitions)).not.toThrow();
|
|
136
|
+
});
|
|
137
|
+
it("should pass validation with empty definitions", () => {
|
|
138
|
+
const args = { foo: "bar" };
|
|
139
|
+
const definitions = [];
|
|
140
|
+
expect(() => validateArguments(args, definitions)).not.toThrow();
|
|
141
|
+
});
|
|
142
|
+
it("should pass validation with no definitions", () => {
|
|
143
|
+
const args = { foo: "bar" };
|
|
144
|
+
expect(() => validateArguments(args, [])).not.toThrow();
|
|
145
|
+
});
|
|
146
|
+
it("should not require arguments that are not defined", () => {
|
|
147
|
+
const args = { collection: "papers", extra: "data" };
|
|
148
|
+
const definitions = [
|
|
149
|
+
{ name: "collection", description: "Collection name", required: true },
|
|
150
|
+
];
|
|
151
|
+
expect(() => validateArguments(args, definitions)).not.toThrow();
|
|
152
|
+
});
|
|
153
|
+
it("should handle mixed required and optional arguments", () => {
|
|
154
|
+
const args = { name: "test" };
|
|
155
|
+
const definitions = [
|
|
156
|
+
{ name: "name", description: "Name", required: true },
|
|
157
|
+
{ name: "limit", description: "Limit", required: false },
|
|
158
|
+
{ name: "filter", description: "Filter", required: false },
|
|
159
|
+
];
|
|
160
|
+
expect(() => validateArguments(args, definitions)).not.toThrow();
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
//# sourceMappingURL=template.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.test.js","sourceRoot":"","sources":["../../src/prompts/template.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlE,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,QAAQ,GAAG,qCAAqC,CAAC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AAE,QAAQ,EAAE,KAAK,EAAE;SAC3D,CAAC;QAEF,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration types for MCP prompts
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Argument definition for a prompt
|
|
6
|
+
*/
|
|
7
|
+
export interface PromptArgument {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
required: boolean;
|
|
11
|
+
default?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Individual prompt definition
|
|
15
|
+
*/
|
|
16
|
+
export interface PromptDefinition {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
arguments: PromptArgument[];
|
|
20
|
+
template: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Root configuration structure
|
|
24
|
+
*/
|
|
25
|
+
export interface PromptsConfig {
|
|
26
|
+
prompts: PromptDefinition[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parsed template with resolved arguments
|
|
30
|
+
*/
|
|
31
|
+
export interface RenderedPrompt {
|
|
32
|
+
text: string;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/prompts/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/prompts/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# Code Search Example
|
|
2
|
+
|
|
3
|
+
This example demonstrates how to use the code vectorization features to index and search codebases semantically.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Qdrant and Ollama running (see main README)
|
|
8
|
+
- Qdrant MCP server configured
|
|
9
|
+
|
|
10
|
+
## Example 1: Index a TypeScript Project
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Index your project
|
|
14
|
+
/mcp__qdrant__index_codebase /path/to/your/typescript/project
|
|
15
|
+
|
|
16
|
+
# Expected output:
|
|
17
|
+
# Scanning files...
|
|
18
|
+
# Found 247 files
|
|
19
|
+
# Chunking code...
|
|
20
|
+
# Generating embeddings...
|
|
21
|
+
# Storing chunks...
|
|
22
|
+
# ✓ Indexed 247 files (1,823 chunks) in 45.2s
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Example 2: Search for Authentication Code
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Natural language search
|
|
29
|
+
/mcp__qdrant__search_code /path/to/your/project "how does user authentication work?"
|
|
30
|
+
|
|
31
|
+
# Results will include:
|
|
32
|
+
# - File path and line numbers (e.g., src/auth/middleware.ts:15-42)
|
|
33
|
+
# - Code snippets
|
|
34
|
+
# - Relevance scores
|
|
35
|
+
# - Language information
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Example 3: Search with Filters
|
|
39
|
+
|
|
40
|
+
### Filter by File Type
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Only search TypeScript files
|
|
44
|
+
/mcp__qdrant__search_code /path/to/your/project "error handling" --fileTypes .ts,.tsx
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Filter by Path Pattern
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Only search in API routes
|
|
51
|
+
/mcp__qdrant__search_code /path/to/your/project "request validation" --pathPattern src/api/**
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Example 4: Incremental Updates
|
|
55
|
+
|
|
56
|
+
After making changes to your codebase:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Re-index only changed files
|
|
60
|
+
/mcp__qdrant__reindex_changes /path/to/your/project
|
|
61
|
+
|
|
62
|
+
# Expected output:
|
|
63
|
+
# Detecting changes...
|
|
64
|
+
# Found: +3 added, ~5 modified, -1 deleted
|
|
65
|
+
# Updating index...
|
|
66
|
+
# ✓ Updated in 8.3s
|
|
67
|
+
# Chunks: +47 added, -23 deleted
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Example 5: Check Index Status
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Get information about an indexed codebase
|
|
74
|
+
/mcp__qdrant__get_index_status /path/to/your/project
|
|
75
|
+
|
|
76
|
+
# Output:
|
|
77
|
+
# {
|
|
78
|
+
# "isIndexed": true,
|
|
79
|
+
# "collectionName": "code_a3f8d2e1",
|
|
80
|
+
# "chunksCount": 1823,
|
|
81
|
+
# "filesCount": 247,
|
|
82
|
+
# "lastUpdated": "2025-01-30T10:15:00Z",
|
|
83
|
+
# "languages": ["typescript", "javascript", "json"]
|
|
84
|
+
# }
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Example 6: Multi-Language Project
|
|
88
|
+
|
|
89
|
+
For projects with multiple languages:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Index a full-stack project
|
|
93
|
+
/mcp__qdrant__index_codebase /path/to/fullstack/project
|
|
94
|
+
|
|
95
|
+
# The indexer automatically detects:
|
|
96
|
+
# - Frontend: TypeScript, React, Vue
|
|
97
|
+
# - Backend: Python, Go, Java
|
|
98
|
+
# - Config: JSON, YAML, TOML
|
|
99
|
+
# - Scripts: Bash, Shell
|
|
100
|
+
|
|
101
|
+
# Search across all languages
|
|
102
|
+
/mcp__qdrant__search_code /path/to/fullstack/project "database connection pooling"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Example 7: Custom Ignore Patterns
|
|
106
|
+
|
|
107
|
+
Create a `.contextignore` file in your project root:
|
|
108
|
+
|
|
109
|
+
```gitignore
|
|
110
|
+
# .contextignore
|
|
111
|
+
**/test/**
|
|
112
|
+
**/*.test.ts
|
|
113
|
+
**/*.spec.ts
|
|
114
|
+
**/fixtures/**
|
|
115
|
+
**/mocks/**
|
|
116
|
+
**/__tests__/**
|
|
117
|
+
**/coverage/**
|
|
118
|
+
*.generated.ts
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Then index normally - these patterns will be automatically applied.
|
|
122
|
+
|
|
123
|
+
## Example 8: Force Re-index
|
|
124
|
+
|
|
125
|
+
If you need to completely re-index (e.g., after changing chunking settings):
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Force full re-index
|
|
129
|
+
/mcp__qdrant__index_codebase /path/to/your/project --forceReindex true
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Example 9: Custom File Extensions
|
|
133
|
+
|
|
134
|
+
Index non-standard file types:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Add custom extensions
|
|
138
|
+
/mcp__qdrant__index_codebase /path/to/your/project --extensions .proto,.graphql,.prisma
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Use Cases
|
|
142
|
+
|
|
143
|
+
### 1. New Developer Onboarding
|
|
144
|
+
|
|
145
|
+
**Scenario**: New developer needs to understand authentication flow
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Index the codebase once
|
|
149
|
+
/mcp__qdrant__index_codebase /workspace/company-app
|
|
150
|
+
|
|
151
|
+
# Then ask questions:
|
|
152
|
+
/mcp__qdrant__search_code /workspace/company-app "authentication middleware"
|
|
153
|
+
/mcp__qdrant__search_code /workspace/company-app "JWT token validation"
|
|
154
|
+
/mcp__qdrant__search_code /workspace/company-app "password hashing"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 2. Bug Investigation
|
|
158
|
+
|
|
159
|
+
**Scenario**: Production bug in payment processing
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Search for payment-related code
|
|
163
|
+
/mcp__qdrant__search_code /workspace/app "payment processing error handling"
|
|
164
|
+
|
|
165
|
+
# Narrow down to specific service
|
|
166
|
+
/mcp__qdrant__search_code /workspace/app "stripe payment" --pathPattern src/services/payment/**
|
|
167
|
+
|
|
168
|
+
# Find related tests
|
|
169
|
+
/mcp__qdrant__search_code /workspace/app "payment processing tests" --fileTypes .test.ts
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### 3. Code Review
|
|
173
|
+
|
|
174
|
+
**Scenario**: Understanding changes in a PR
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Index the feature branch
|
|
178
|
+
git checkout feature/new-api
|
|
179
|
+
/mcp__qdrant__index_codebase /workspace/app
|
|
180
|
+
|
|
181
|
+
# Search for specific implementations
|
|
182
|
+
/mcp__qdrant__search_code /workspace/app "new API endpoints"
|
|
183
|
+
/mcp__qdrant__search_code /workspace/app "validation logic"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### 4. Documentation Writing
|
|
187
|
+
|
|
188
|
+
**Scenario**: Writing API documentation
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# Find all API endpoints
|
|
192
|
+
/mcp__qdrant__search_code /workspace/app "REST API endpoints"
|
|
193
|
+
/mcp__qdrant__search_code /workspace/app "GraphQL resolvers"
|
|
194
|
+
|
|
195
|
+
# Find request/response schemas
|
|
196
|
+
/mcp__qdrant__search_code /workspace/app "API schema definitions"
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Performance Tips
|
|
200
|
+
|
|
201
|
+
1. **Use incremental updates**: After initial indexing, always use `reindex_changes` instead of full re-index
|
|
202
|
+
2. **Filter aggressively**: Use `fileTypes` and `pathPattern` to narrow search scope
|
|
203
|
+
3. **Batch indexing**: For very large codebases, consider indexing subdirectories separately
|
|
204
|
+
4. **Local embeddings**: Use Ollama for fastest indexing and complete privacy
|
|
205
|
+
5. **Monitor progress**: Check `get_index_status` to see indexing statistics
|
|
206
|
+
|
|
207
|
+
## Troubleshooting
|
|
208
|
+
|
|
209
|
+
### Slow Indexing
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Check current settings
|
|
213
|
+
echo $CODE_BATCH_SIZE # Default: 100
|
|
214
|
+
|
|
215
|
+
# Increase batch size (if you have good internet/API limits)
|
|
216
|
+
export CODE_BATCH_SIZE=200
|
|
217
|
+
|
|
218
|
+
# Or use local Ollama (fastest)
|
|
219
|
+
export EMBEDDING_PROVIDER=ollama
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Search Returns No Results
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
# Check if codebase is indexed
|
|
226
|
+
/mcp__qdrant__get_index_status /path/to/your/project
|
|
227
|
+
|
|
228
|
+
# If not indexed:
|
|
229
|
+
/mcp__qdrant__index_codebase /path/to/your/project
|
|
230
|
+
|
|
231
|
+
# Try broader queries
|
|
232
|
+
# Instead of: "getUserById"
|
|
233
|
+
# Try: "user retrieval functions"
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Files Not Being Indexed
|
|
237
|
+
|
|
238
|
+
Check ignore patterns:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# View .gitignore
|
|
242
|
+
cat /path/to/your/project/.gitignore
|
|
243
|
+
|
|
244
|
+
# Create .contextignore to override
|
|
245
|
+
echo "!tests/**" > /path/to/your/project/.contextignore
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Advanced Configuration
|
|
249
|
+
|
|
250
|
+
Set environment variables for customization:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# Larger chunks for more context
|
|
254
|
+
export CODE_CHUNK_SIZE=5000
|
|
255
|
+
export CODE_CHUNK_OVERLAP=500
|
|
256
|
+
|
|
257
|
+
# More results by default
|
|
258
|
+
export CODE_DEFAULT_LIMIT=10
|
|
259
|
+
|
|
260
|
+
# Custom file types
|
|
261
|
+
export CODE_CUSTOM_EXTENSIONS=".prisma,.proto,.graphql"
|
|
262
|
+
|
|
263
|
+
# Additional ignore patterns
|
|
264
|
+
export CODE_CUSTOM_IGNORE="**/*.generated.ts,**/dist/**"
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Next Steps
|
|
268
|
+
|
|
269
|
+
- Explore [hybrid search](../filters/) for better accuracy
|
|
270
|
+
- Set up [custom prompts](../../prompts.example.json) for code search workflows
|
|
271
|
+
- Integrate with your AI assistant for interactive code exploration
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mhalder/qdrant-mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "MCP server for semantic search using local Qdrant and Ollama (default) with support for OpenAI, Cohere, and Voyage AI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -32,13 +32,25 @@
|
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
+
"overrides": {
|
|
36
|
+
"tree-sitter": "^0.25.0"
|
|
37
|
+
},
|
|
35
38
|
"dependencies": {
|
|
36
39
|
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
37
40
|
"@qdrant/js-client-rest": "^1.12.0",
|
|
38
41
|
"bottleneck": "^2.19.5",
|
|
39
42
|
"cohere-ai": "^7.19.0",
|
|
40
43
|
"express": "^5.1.0",
|
|
44
|
+
"ignore": "^7.0.5",
|
|
41
45
|
"openai": "^4.77.3",
|
|
46
|
+
"tree-sitter": "^0.25.0",
|
|
47
|
+
"tree-sitter-bash": "^0.25.0",
|
|
48
|
+
"tree-sitter-go": "^0.25.0",
|
|
49
|
+
"tree-sitter-java": "^0.23.5",
|
|
50
|
+
"tree-sitter-javascript": "^0.25.0",
|
|
51
|
+
"tree-sitter-python": "^0.25.0",
|
|
52
|
+
"tree-sitter-rust": "^0.24.0",
|
|
53
|
+
"tree-sitter-typescript": "^0.23.2",
|
|
42
54
|
"zod": "^3.24.1"
|
|
43
55
|
},
|
|
44
56
|
"devDependencies": {
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"prompts": [
|
|
3
|
+
{
|
|
4
|
+
"name": "setup_rag_collection",
|
|
5
|
+
"description": "Create a new collection optimized for RAG workflows with hybrid search",
|
|
6
|
+
"arguments": [
|
|
7
|
+
{
|
|
8
|
+
"name": "name",
|
|
9
|
+
"description": "Name for the new collection",
|
|
10
|
+
"required": true
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"template": "Create a new Qdrant collection named '{{name}}' optimized for RAG (Retrieval-Augmented Generation) workflows:\n\n1. Create the collection with hybrid search enabled (enableHybrid: true) to combine semantic and keyword search for better retrieval accuracy\n2. Use Cosine distance metric (optimal for most embedding models)\n3. After creation, show the collection info and explain the configuration\n4. Provide guidance on adding documents with proper metadata structure for RAG use cases"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "analyze_and_optimize",
|
|
17
|
+
"description": "Analyze a collection and provide optimization recommendations",
|
|
18
|
+
"arguments": [
|
|
19
|
+
{
|
|
20
|
+
"name": "collection",
|
|
21
|
+
"description": "Name of the collection to analyze",
|
|
22
|
+
"required": true
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"template": "Perform a comprehensive analysis of the '{{collection}}' collection:\n\n1. Get the collection info (dimensions, document count, distance metric, hybrid search status)\n2. Analyze the configuration and provide insights:\n - Is the distance metric appropriate for the use case?\n - Should hybrid search be enabled for better results?\n - Is the document count sufficient for meaningful similarity search?\n3. Provide specific, actionable optimization recommendations\n4. If the collection seems suboptimal, suggest a migration strategy"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "compare_search_strategies",
|
|
29
|
+
"description": "Compare semantic vs hybrid search to determine best approach",
|
|
30
|
+
"arguments": [
|
|
31
|
+
{
|
|
32
|
+
"name": "collection",
|
|
33
|
+
"description": "Collection name (must have hybrid search enabled)",
|
|
34
|
+
"required": true
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "query",
|
|
38
|
+
"description": "Test query",
|
|
39
|
+
"required": true
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"template": "Compare search strategies for '{{query}}' in the '{{collection}}' collection:\n\n1. Perform semantic_search and show top 5 results with scores\n2. Perform hybrid_search and show top 5 results with scores\n3. Analyze the differences:\n - Which results appear in both? Which are unique to each method?\n - How do the relevance scores compare?\n - Which method seems more accurate for this query type?\n4. Recommend which search strategy to use based on:\n - Query characteristics (keyword-heavy vs conceptual)\n - Result quality and relevance\n - Use case requirements"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "migrate_to_hybrid",
|
|
46
|
+
"description": "Migrate an existing collection to use hybrid search",
|
|
47
|
+
"arguments": [
|
|
48
|
+
{
|
|
49
|
+
"name": "source",
|
|
50
|
+
"description": "Name of the existing collection to migrate",
|
|
51
|
+
"required": true
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "target",
|
|
55
|
+
"description": "Name for the new hybrid-enabled collection",
|
|
56
|
+
"required": true
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"template": "Migrate the '{{source}}' collection to a new hybrid search-enabled collection '{{target}}':\n\n1. First, analyze the source collection to understand its current configuration\n2. Create the target collection with hybrid search enabled, matching the source's distance metric\n3. Guide the user through retrieving documents from the source (note: you'll need to implement a retrieval mechanism or have the user provide the documents)\n4. Explain how to add the documents to the new hybrid collection\n5. Provide verification steps to ensure the migration was successful\n6. Ask if the user wants to delete the old collection after verification"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "debug_search_quality",
|
|
63
|
+
"description": "Debug poor search results and suggest improvements",
|
|
64
|
+
"arguments": [
|
|
65
|
+
{
|
|
66
|
+
"name": "collection",
|
|
67
|
+
"description": "Collection with poor search quality",
|
|
68
|
+
"required": true
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "problematic_query",
|
|
72
|
+
"description": "A query that returns poor results",
|
|
73
|
+
"required": true
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"template": "Debug search quality issues in '{{collection}}' for query '{{problematic_query}}':\n\n1. Get collection info to understand the configuration\n2. Perform a search with the problematic query and analyze the results:\n - Are the scores too low (< 0.5)? This suggests poor embedding quality or mismatched query/document domains\n - Are irrelevant results ranking highly? This suggests metadata or hybrid search could help\n3. Test if hybrid search is available and compare results\n4. Provide specific recommendations:\n - Should documents be re-embedded with a different model?\n - Would metadata filtering help narrow results?\n - Is the collection too small or missing relevant documents?\n - Should the distance metric be changed?\n5. Suggest concrete next steps to improve search quality"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "build_knowledge_base",
|
|
80
|
+
"description": "Guide for building a structured knowledge base with metadata",
|
|
81
|
+
"arguments": [
|
|
82
|
+
{
|
|
83
|
+
"name": "collection",
|
|
84
|
+
"description": "Collection name for the knowledge base",
|
|
85
|
+
"required": true
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"name": "domain",
|
|
89
|
+
"description": "Domain or topic of the knowledge base",
|
|
90
|
+
"required": true
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"template": "Build a structured knowledge base in '{{collection}}' for the {{domain}} domain:\n\n1. Create (or verify) the collection with hybrid search enabled for optimal retrieval\n2. Design a metadata schema appropriate for {{domain}}, such as:\n - category/topic fields for filtering\n - timestamps for temporal filtering\n - source/author for provenance\n - confidence/quality scores\n3. Provide guidance on document structure:\n - Optimal chunk sizes (typically 200-500 tokens)\n - How to maintain context across chunks\n - Metadata to include with each document\n4. Show example documents with proper formatting\n5. Explain search strategies for this knowledge base:\n - When to use metadata filters\n - When hybrid search adds value\n - How to handle multi-step queries"
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base interface for code chunkers
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { CodeChunk } from "../types.js";
|
|
6
|
+
|
|
7
|
+
export interface CodeChunker {
|
|
8
|
+
/**
|
|
9
|
+
* Split code into semantic chunks
|
|
10
|
+
*/
|
|
11
|
+
chunk(code: string, filePath: string, language: string): Promise<CodeChunk[]>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Check if language is supported by this chunker
|
|
15
|
+
*/
|
|
16
|
+
supportsLanguage(language: string): boolean;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get chunking strategy name
|
|
20
|
+
*/
|
|
21
|
+
getStrategyName(): string;
|
|
22
|
+
}
|