simple-dynamsoft-mcp 4.0.0 → 5.0.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/.env.example +57 -0
- package/README.md +25 -2
- package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-foundational-api/hello-world-blazor/BlazorApp/obj/Debug/net8.0/BlazorApp.AssemblyInfo.cs +1 -1
- package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-rtu-api/obj/Debug/net8.0/BlazorApp.AssemblyInfo.cs +1 -1
- package/package.json +5 -2
- package/src/index.js +480 -1238
- package/src/normalizers.js +274 -0
- package/src/rag.js +589 -0
- package/src/resource-index.js +1220 -0
package/.env.example
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# RAG provider selection (primary + fallback)
|
|
2
|
+
# RAG_PROVIDER: auto | gemini | local | fuse
|
|
3
|
+
# - auto: gemini if GEMINI_API_KEY is set, otherwise local
|
|
4
|
+
# - gemini: remote embeddings via Google Gemini
|
|
5
|
+
# - local: local embeddings via @xenova/transformers
|
|
6
|
+
# - fuse: legacy fuzzy search only (no embeddings)
|
|
7
|
+
RAG_PROVIDER=auto
|
|
8
|
+
|
|
9
|
+
# RAG_FALLBACK: none | fuse | local
|
|
10
|
+
# - none: do not fall back if primary fails
|
|
11
|
+
# - fuse: fuzzy search fallback (fast, no embeddings)
|
|
12
|
+
# - local: local embeddings fallback (if primary is gemini)
|
|
13
|
+
RAG_FALLBACK=fuse
|
|
14
|
+
|
|
15
|
+
# Gemini remote embeddings (required when RAG_PROVIDER=gemini)
|
|
16
|
+
# * GEMINI_API_KEY: your Gemini API key (never commit to git)
|
|
17
|
+
# * GEMINI_EMBED_MODEL: models/embedding-001 | models/gemini-embedding-001 | gemini-embedding-001
|
|
18
|
+
# * GEMINI_API_BASE_URL: override for proxies (default https://generativelanguage.googleapis.com)
|
|
19
|
+
# * GEMINI_EMBED_BATCH_SIZE: batch size for Gemini embedding requests
|
|
20
|
+
# GEMINI_API_KEY=your_key
|
|
21
|
+
# GEMINI_EMBED_MODEL=gemini-embedding-001
|
|
22
|
+
# GEMINI_API_BASE_URL=https://generativelanguage.googleapis.com
|
|
23
|
+
# GEMINI_EMBED_BATCH_SIZE=16
|
|
24
|
+
|
|
25
|
+
# Local embeddings (used when RAG_PROVIDER=local or fallback=local)
|
|
26
|
+
# * RAG_LOCAL_MODEL: Hugging Face model id (default Xenova/all-MiniLM-L6-v2)
|
|
27
|
+
# * RAG_LOCAL_QUANTIZED: true|false (smaller/faster model download when true)
|
|
28
|
+
# RAG_LOCAL_MODEL=Xenova/all-MiniLM-L6-v2
|
|
29
|
+
# RAG_LOCAL_QUANTIZED=true
|
|
30
|
+
|
|
31
|
+
# Cache locations
|
|
32
|
+
# * RAG_CACHE_DIR: vector index cache (default data/.rag-cache)
|
|
33
|
+
# * RAG_MODEL_CACHE_DIR: local model cache (default data/.rag-cache/models)
|
|
34
|
+
# RAG_CACHE_DIR=data/.rag-cache
|
|
35
|
+
# RAG_MODEL_CACHE_DIR=data/.rag-cache/models
|
|
36
|
+
|
|
37
|
+
# Indexing + retrieval tuning
|
|
38
|
+
# * RAG_CHUNK_SIZE: max chars per chunk when embedding doc content
|
|
39
|
+
# * RAG_CHUNK_OVERLAP: overlap between chunks (helps context continuity)
|
|
40
|
+
# * RAG_MAX_CHUNKS_PER_DOC: cap chunks per doc to control index size
|
|
41
|
+
# * RAG_MAX_TEXT_CHARS: max chars per embedding input
|
|
42
|
+
# * RAG_MIN_SCORE: minimum cosine similarity to keep a hit (0 disables filtering). Default 0.2.
|
|
43
|
+
# * RAG_INCLUDE_SCORE: include similarity score in search results (debugging)
|
|
44
|
+
# RAG_CHUNK_SIZE=1200
|
|
45
|
+
# RAG_CHUNK_OVERLAP=200
|
|
46
|
+
# RAG_MAX_CHUNKS_PER_DOC=6
|
|
47
|
+
# RAG_MAX_TEXT_CHARS=4000
|
|
48
|
+
# RAG_MIN_SCORE=0.2
|
|
49
|
+
# RAG_INCLUDE_SCORE=false
|
|
50
|
+
|
|
51
|
+
# Cache/boot controls
|
|
52
|
+
# * RAG_REBUILD: true to ignore cache and rebuild on startup/search
|
|
53
|
+
# * RAG_PREWARM: true to build the embedding index at startup
|
|
54
|
+
# * RAG_PREWARM_BLOCK: true to block startup until prewarm completes
|
|
55
|
+
# RAG_REBUILD=false
|
|
56
|
+
# RAG_PREWARM=false
|
|
57
|
+
# RAG_PREWARM_BLOCK=false
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ https://github.com/user-attachments/assets/cc1c5f4b-1461-4462-897a-75abc20d62a6
|
|
|
19
19
|
- **Multiple SDKs**: Barcode Reader (Mobile/Python/Web) + Dynamic Web TWAIN + Document Viewer
|
|
20
20
|
- **Multiple API Levels**: High-level (simple) and low-level (advanced) options
|
|
21
21
|
- **Stdio MCP server**: Runs on stdio. Works with any MCP-capable client.
|
|
22
|
-
- **Resource-efficient discovery**: Resources are discovered via tools (
|
|
22
|
+
- **Resource-efficient discovery**: Resources are discovered via tools (semantic RAG search with fuzzy fallback + resource links). Only a small pinned set is listed by default; heavy content is fetched on-demand with `resources/read`.
|
|
23
23
|
- **Latest-major policy**: The server only serves the latest major versions; older major requests are refused with legacy links when available.
|
|
24
24
|
|
|
25
25
|
## Available Tools
|
|
@@ -28,6 +28,8 @@ https://github.com/user-attachments/assets/cc1c5f4b-1461-4462-897a-75abc20d62a6
|
|
|
28
28
|
|------|-------------|
|
|
29
29
|
| `get_index` | Compact index of products, editions, versions, samples, and docs |
|
|
30
30
|
| `search` | Unified search across docs and samples; returns resource links |
|
|
31
|
+
| `list_samples` | List available sample IDs and URIs for a scope |
|
|
32
|
+
| `resolve_sample` | Resolve a sample_id (or sample URI) to matching sample URIs |
|
|
31
33
|
| `resolve_version` | Resolve a concrete latest-major version for a product/edition |
|
|
32
34
|
| `get_quickstart` | Opinionated quickstart for a target stack |
|
|
33
35
|
| `generate_project` | Assemble a project structure from a sample (no AI generation) |
|
|
@@ -284,10 +286,31 @@ data/
|
|
|
284
286
|
## Using Search-Based Discovery (Recommended)
|
|
285
287
|
|
|
286
288
|
- On session start, let your client call `tools/list` and `resources/list` (pinned only, not exhaustive).
|
|
287
|
-
- For any query, call `search
|
|
289
|
+
- For any query, call `search`; it uses semantic RAG retrieval (with fuzzy fallback) and returns `resource_link` entries.
|
|
288
290
|
- Read only the links you need via `resources/read` to avoid bloating the context window.
|
|
289
291
|
- If unsure what to search, call `get_index` first to see what is available.
|
|
290
292
|
|
|
293
|
+
## RAG Configuration
|
|
294
|
+
|
|
295
|
+
Search providers are selected at runtime via environment variables (safe for public npm packages). Defaults to `auto` -> `gemini` if `GEMINI_API_KEY` is set, otherwise `local`, with `fuse` fallback on failure.
|
|
296
|
+
|
|
297
|
+
To keep the legacy fuzzy search (no model download), set `RAG_PROVIDER=fuse`.
|
|
298
|
+
|
|
299
|
+
Key env vars:
|
|
300
|
+
- `RAG_PROVIDER`: `auto` | `gemini` | `local` | `fuse`
|
|
301
|
+
- `RAG_FALLBACK`: `fuse` | `local` | `none`
|
|
302
|
+
- `GEMINI_API_KEY`: required for remote embeddings
|
|
303
|
+
- `GEMINI_EMBED_MODEL`: e.g. `models/embedding-001` or `models/gemini-embedding-001`
|
|
304
|
+
- `RAG_LOCAL_MODEL`: default `Xenova/all-MiniLM-L6-v2`
|
|
305
|
+
- `RAG_CACHE_DIR`: default `data/.rag-cache`
|
|
306
|
+
|
|
307
|
+
Local embeddings download the model on first run and cache under `data/.rag-cache/models`.
|
|
308
|
+
Advanced tuning:
|
|
309
|
+
- `RAG_CHUNK_SIZE`, `RAG_CHUNK_OVERLAP`, `RAG_MAX_CHUNKS_PER_DOC`, `RAG_MAX_TEXT_CHARS`
|
|
310
|
+
- `RAG_MIN_SCORE`, `RAG_INCLUDE_SCORE`, `RAG_REBUILD`, `RAG_PREWARM`, `RAG_PREWARM_BLOCK`, `RAG_LOCAL_QUANTIZED`, `GEMINI_EMBED_BATCH_SIZE`, `RAG_MODEL_CACHE_DIR`
|
|
311
|
+
|
|
312
|
+
For local dev, you can also use a `.env` file (see `.env.example`).
|
|
313
|
+
|
|
291
314
|
## Version Policy
|
|
292
315
|
|
|
293
316
|
- This MCP server serves only the latest major versions (DBR v11, DWT v19).
|
|
@@ -13,7 +13,7 @@ using System.Reflection;
|
|
|
13
13
|
[assembly: System.Reflection.AssemblyCompanyAttribute("BlazorApp")]
|
|
14
14
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
|
15
15
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
|
16
|
-
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+
|
|
16
|
+
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c15266272a4c5826609d9e0aa7b95eefb2073fbf")]
|
|
17
17
|
[assembly: System.Reflection.AssemblyProductAttribute("BlazorApp")]
|
|
18
18
|
[assembly: System.Reflection.AssemblyTitleAttribute("BlazorApp")]
|
|
19
19
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
|
@@ -13,7 +13,7 @@ using System.Reflection;
|
|
|
13
13
|
[assembly: System.Reflection.AssemblyCompanyAttribute("BlazorApp")]
|
|
14
14
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
|
15
15
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
|
16
|
-
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+
|
|
16
|
+
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c15266272a4c5826609d9e0aa7b95eefb2073fbf")]
|
|
17
17
|
[assembly: System.Reflection.AssemblyProductAttribute("BlazorApp")]
|
|
18
18
|
[assembly: System.Reflection.AssemblyTitleAttribute("BlazorApp")]
|
|
19
19
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simple-dynamsoft-mcp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "MCP server for Dynamsoft SDKs - Barcode Reader (Mobile/Python/Web), Dynamic Web TWAIN, and Document Viewer. Provides documentation, code snippets, and API guidance.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"src",
|
|
19
19
|
"data",
|
|
20
20
|
"code-snippet",
|
|
21
|
-
"README.md"
|
|
21
|
+
"README.md",
|
|
22
|
+
".env.example"
|
|
22
23
|
],
|
|
23
24
|
"scripts": {
|
|
24
25
|
"start": "node src/index.js",
|
|
@@ -41,6 +42,8 @@
|
|
|
41
42
|
],
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
45
|
+
"@xenova/transformers": "^2.17.2",
|
|
46
|
+
"dotenv": "^16.4.5",
|
|
44
47
|
"fuse.js": "^7.0.0",
|
|
45
48
|
"zod": "~3.24.0"
|
|
46
49
|
},
|