embarsy-qdrant-mcp 0.1.2 → 0.1.4
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/LICENSE +77 -0
- package/README.md +3 -1
- package/dist/chunker.js +14 -1
- package/dist/embeddings.js +8 -1
- package/dist/mcp-server.js +14 -1
- package/dist/walk.js +2 -2
- package/package.json +14 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Copyright © 2026 Arseniy Ganov
|
|
2
|
+
|
|
3
|
+
Embarsy is source-available software licensed under the PolyForm Strict
|
|
4
|
+
License 1.0.0, reproduced in full below and also available at
|
|
5
|
+
<https://polyformproject.org/licenses/strict/1.0.0/>.
|
|
6
|
+
|
|
7
|
+
This license permits only noncommercial use of the software. It does NOT
|
|
8
|
+
grant the right to distribute the software, to make changes or new works
|
|
9
|
+
based on it, or to use it for commercial purposes. Any such use — including
|
|
10
|
+
selling, redistributing, or modifying the software — requires a separate
|
|
11
|
+
written license from the licensor. To request one, contact
|
|
12
|
+
arsenyganov@gmail.com.
|
|
13
|
+
|
|
14
|
+
Bundled third-party components (e.g. Qdrant, Ollama, FastAPI) remain under
|
|
15
|
+
their own licenses; see THIRD_PARTY_NOTICES.
|
|
16
|
+
|
|
17
|
+
----------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
# PolyForm Strict License 1.0.0
|
|
20
|
+
|
|
21
|
+
<https://polyformproject.org/licenses/strict/1.0.0>
|
|
22
|
+
|
|
23
|
+
## Acceptance
|
|
24
|
+
|
|
25
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
26
|
+
|
|
27
|
+
## Copyright License
|
|
28
|
+
|
|
29
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose, other than distributing the software or making changes or new works based on the software.
|
|
30
|
+
|
|
31
|
+
## Patent License
|
|
32
|
+
|
|
33
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
34
|
+
|
|
35
|
+
## Noncommercial Purposes
|
|
36
|
+
|
|
37
|
+
Any noncommercial purpose is a permitted purpose.
|
|
38
|
+
|
|
39
|
+
## Personal Uses
|
|
40
|
+
|
|
41
|
+
Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
|
|
42
|
+
|
|
43
|
+
## Noncommercial Organizations
|
|
44
|
+
|
|
45
|
+
Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
|
|
46
|
+
|
|
47
|
+
## Fair Use
|
|
48
|
+
|
|
49
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
50
|
+
|
|
51
|
+
## No Other Rights
|
|
52
|
+
|
|
53
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
54
|
+
|
|
55
|
+
## Patent Defense
|
|
56
|
+
|
|
57
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
58
|
+
|
|
59
|
+
## Violations
|
|
60
|
+
|
|
61
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
62
|
+
|
|
63
|
+
## No Liability
|
|
64
|
+
|
|
65
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
66
|
+
|
|
67
|
+
## Definitions
|
|
68
|
+
|
|
69
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
70
|
+
|
|
71
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
72
|
+
|
|
73
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
74
|
+
|
|
75
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
76
|
+
|
|
77
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
package/README.md
CHANGED
|
@@ -62,4 +62,6 @@ QDRANT_COLLECTION_NAME=my-app embarsy-mcp --setup-claude
|
|
|
62
62
|
|
|
63
63
|
## License
|
|
64
64
|
|
|
65
|
-
PolyForm Strict 1.0.0 —
|
|
65
|
+
**[PolyForm Strict 1.0.0](LICENSE)** — source-available, **not** open source: noncommercial use
|
|
66
|
+
only, no redistribution or modification without a separate written license. The full text ships with
|
|
67
|
+
this package (`LICENSE`). Commercial or modification license → **arsenyganov@gmail.com**.
|
package/dist/chunker.js
CHANGED
|
@@ -39,13 +39,26 @@ export function chunkFile(content, cfg) {
|
|
|
39
39
|
if (nl > pos + Math.floor(maxChars / 2))
|
|
40
40
|
end = nl;
|
|
41
41
|
}
|
|
42
|
+
end = snapToCodePoint(content, end);
|
|
42
43
|
const text = content.slice(pos, end);
|
|
43
44
|
if (text.trim().length > 0) {
|
|
44
45
|
chunks.push({ startLine: lineAt(pos), endLine: lineAt(Math.max(pos, end - 1)), text });
|
|
45
46
|
}
|
|
46
47
|
if (end >= content.length)
|
|
47
48
|
break;
|
|
48
|
-
pos = Math.max(pos + 1, end - overlap);
|
|
49
|
+
pos = snapToCodePoint(content, Math.max(pos + 1, end - overlap));
|
|
49
50
|
}
|
|
50
51
|
return chunks;
|
|
51
52
|
}
|
|
53
|
+
/** A boundary that lands between the two halves of a surrogate pair would cut an emoji
|
|
54
|
+
* in half; the resulting lone surrogate is invalid Unicode that embedding backends
|
|
55
|
+
* reject (Python's UTF-8 encoder raises on it, turning the request into a 500).
|
|
56
|
+
* If the index points at a low surrogate, step back one unit to keep the pair whole. */
|
|
57
|
+
function snapToCodePoint(s, index) {
|
|
58
|
+
if (index > 0 && index < s.length) {
|
|
59
|
+
const code = s.charCodeAt(index);
|
|
60
|
+
if (code >= 0xdc00 && code <= 0xdfff)
|
|
61
|
+
return index - 1;
|
|
62
|
+
}
|
|
63
|
+
return index;
|
|
64
|
+
}
|
package/dist/embeddings.js
CHANGED
|
@@ -7,10 +7,17 @@ import { requestJSON } from "./http.js";
|
|
|
7
7
|
/** Absolute per-input cap (defense in depth on top of chunking) so no single text can overflow
|
|
8
8
|
* the model's context and crash the embedding backend, whatever produced it. */
|
|
9
9
|
const MAX_EMBED_CHARS = 8000;
|
|
10
|
+
/** Lone surrogates (an emoji cut in half by any UTF-16 slice) are invalid Unicode: the
|
|
11
|
+
* Embarsy API's UTF-8 re-encode for Ollama rejects them, failing the whole batch with
|
|
12
|
+
* a 500. Replace them with U+FFFD so one broken character can never sink an index run. */
|
|
13
|
+
const LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
|
|
14
|
+
function wellFormed(text) {
|
|
15
|
+
return text.replace(LONE_SURROGATE, "�");
|
|
16
|
+
}
|
|
10
17
|
export async function embedBatch(texts, cfg) {
|
|
11
18
|
if (texts.length === 0)
|
|
12
19
|
return [];
|
|
13
|
-
const input = texts.map((t) => (t.length > MAX_EMBED_CHARS ? t.slice(0, MAX_EMBED_CHARS) : t));
|
|
20
|
+
const input = texts.map((t) => wellFormed(t.length > MAX_EMBED_CHARS ? t.slice(0, MAX_EMBED_CHARS) : t));
|
|
14
21
|
const json = await requestJSON(`${cfg.openaiBaseUrl}/embeddings`, {
|
|
15
22
|
method: "POST",
|
|
16
23
|
headers: {
|
package/dist/mcp-server.js
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
1
3
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
4
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
5
|
import { z } from "zod";
|
|
4
6
|
import { embedOne } from "./embeddings.js";
|
|
5
7
|
import { search, collectionInfo } from "./qdrant.js";
|
|
8
|
+
/** The published package version — read from package.json (which ships in the tarball)
|
|
9
|
+
* so the MCP handshake never drifts from the real release. */
|
|
10
|
+
const PKG_VERSION = (() => {
|
|
11
|
+
try {
|
|
12
|
+
const pkgPath = fileURLToPath(new URL("../package.json", import.meta.url));
|
|
13
|
+
return JSON.parse(readFileSync(pkgPath, "utf8")).version ?? "0.0.0";
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return "0.0.0";
|
|
17
|
+
}
|
|
18
|
+
})();
|
|
6
19
|
/** Build and run the Embarsy MCP server over stdio (for Claude Code / Codex). */
|
|
7
20
|
export async function runMcpServer(cfg) {
|
|
8
|
-
const server = new McpServer({ name: "embarsy-qdrant", version:
|
|
21
|
+
const server = new McpServer({ name: "embarsy-qdrant", version: PKG_VERSION });
|
|
9
22
|
server.tool("search_code", "Semantic search over the indexed codebase. Returns the most relevant code chunks with " +
|
|
10
23
|
"their file path and line range. Use natural language (e.g. 'where is auth handled').", {
|
|
11
24
|
query: z.string().describe("Natural-language description of the code you are looking for."),
|
package/dist/walk.js
CHANGED
|
@@ -19,7 +19,7 @@ const CODE_EXT = new Set([
|
|
|
19
19
|
"md", "mdx", "json", "yaml", "yml", "toml", "html", "htm", "css", "scss", "sass", "less",
|
|
20
20
|
"vue", "svelte", "lua", "ex", "exs", "dart", "r", "pl", "pm", "proto", "graphql", "gql",
|
|
21
21
|
"tf", "gradle", "groovy", "m", "mm", "clj", "cljs", "edn", "elm", "erl", "hs", "ml", "nim",
|
|
22
|
-
"txt", "cfg", "ini",
|
|
22
|
+
"txt", "cfg", "ini",
|
|
23
23
|
]);
|
|
24
24
|
export async function discoverFiles(root, cfg) {
|
|
25
25
|
const rootAbs = path.resolve(root);
|
|
@@ -67,7 +67,7 @@ async function walk(dir, rootAbs, ig, cfg, out) {
|
|
|
67
67
|
if (ig.ignores(rel))
|
|
68
68
|
continue;
|
|
69
69
|
const ext = path.extname(entry.name).replace(/^\./, "").toLowerCase();
|
|
70
|
-
//
|
|
70
|
+
// Only index files with a known code/text extension.
|
|
71
71
|
if (!CODE_EXT.has(ext))
|
|
72
72
|
continue;
|
|
73
73
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "embarsy-qdrant-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Codebase-indexing MCP server for Embarsy — semantic code search over a local Qdrant + OpenAI-compatible embeddings stack. Routes embeddings and Qdrant through Embarsy's proxy so auth and Monitoring counters just work.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
|
-
"README.md"
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
13
14
|
],
|
|
14
15
|
"engines": {
|
|
15
16
|
"node": ">=18"
|
|
@@ -28,6 +29,17 @@
|
|
|
28
29
|
"claude-code",
|
|
29
30
|
"codex"
|
|
30
31
|
],
|
|
32
|
+
"author": "Arseniy Ganov <arsenyganov@gmail.com>",
|
|
33
|
+
"license": "PolyForm-Strict-1.0.0",
|
|
34
|
+
"homepage": "https://github.com/arsenyganov-pixel/embarsy-embedder/tree/main/tools/embarsy-qdrant-mcp#readme",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/arsenyganov-pixel/embarsy-embedder.git",
|
|
38
|
+
"directory": "tools/embarsy-qdrant-mcp"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/arsenyganov-pixel/embarsy-embedder/issues"
|
|
42
|
+
},
|
|
31
43
|
"dependencies": {
|
|
32
44
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
33
45
|
"ignore": "^5.3.2",
|
|
@@ -37,7 +49,6 @@
|
|
|
37
49
|
"@types/node": "^22.5.0",
|
|
38
50
|
"typescript": "^5.6.2"
|
|
39
51
|
},
|
|
40
|
-
"license": "PolyForm-Strict-1.0.0",
|
|
41
52
|
"publishConfig": {
|
|
42
53
|
"registry": "https://registry.npmjs.org/",
|
|
43
54
|
"access": "public"
|