simple-dynamsoft-mcp 6.3.0 → 7.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.
Files changed (47) hide show
  1. package/.env.example +35 -9
  2. package/README.md +156 -497
  3. package/package.json +13 -7
  4. package/scripts/prebuild-rag-index.mjs +1 -1
  5. package/scripts/run-gemini-tests.mjs +1 -1
  6. package/scripts/sync-submodules.mjs +1 -1
  7. package/scripts/verify-doc-resources.mjs +79 -0
  8. package/src/data/bootstrap.js +475 -0
  9. package/src/data/download-utils.js +99 -0
  10. package/src/data/hydration-mode.js +15 -0
  11. package/src/data/hydration-policy.js +39 -0
  12. package/src/data/repo-map.js +149 -0
  13. package/src/{data-root.js → data/root.js} +1 -1
  14. package/src/{submodule-sync.js → data/submodule-sync.js} +1 -1
  15. package/src/index.js +49 -1499
  16. package/src/observability/logging.js +51 -0
  17. package/src/rag/config.js +96 -0
  18. package/src/rag/index.js +266 -0
  19. package/src/rag/lexical-provider.js +170 -0
  20. package/src/rag/logger.js +46 -0
  21. package/src/rag/profile-config.js +48 -0
  22. package/src/rag/providers.js +585 -0
  23. package/src/rag/search-utils.js +166 -0
  24. package/src/rag/vector-cache.js +323 -0
  25. package/src/server/create-server.js +168 -0
  26. package/src/server/helpers/server-helpers.js +33 -0
  27. package/src/{resource-index → server/resource-index}/paths.js +2 -2
  28. package/src/{resource-index → server/resource-index}/samples.js +9 -1
  29. package/src/{resource-index.js → server/resource-index.js} +158 -93
  30. package/src/server/resources/register-resources.js +56 -0
  31. package/src/server/runtime-config.js +66 -0
  32. package/src/server/tools/register-index-tools.js +130 -0
  33. package/src/server/tools/register-project-tools.js +305 -0
  34. package/src/server/tools/register-quickstart-tools.js +572 -0
  35. package/src/server/tools/register-sample-tools.js +333 -0
  36. package/src/server/tools/register-version-tools.js +136 -0
  37. package/src/server/transports/http.js +84 -0
  38. package/src/server/transports/stdio.js +12 -0
  39. package/src/data-bootstrap.js +0 -255
  40. package/src/rag.js +0 -1203
  41. /package/src/{gemini-retry.js → rag/gemini-retry.js} +0 -0
  42. /package/src/{normalizers.js → server/normalizers.js} +0 -0
  43. /package/src/{resource-index → server/resource-index}/builders.js +0 -0
  44. /package/src/{resource-index → server/resource-index}/config.js +0 -0
  45. /package/src/{resource-index → server/resource-index}/docs-loader.js +0 -0
  46. /package/src/{resource-index → server/resource-index}/uri.js +0 -0
  47. /package/src/{resource-index → server/resource-index}/version-policy.js +0 -0
package/README.md CHANGED
@@ -1,592 +1,251 @@
1
1
  # Dynamsoft MCP Server
2
2
 
3
- MCP (Model Context Protocol) server that enables AI assistants to write correct code with Dynamsoft SDKs. It provides actual working code snippets, documentation links, and API guidance for:
3
+ MCP server that helps AI assistants generate accurate code and guidance for Dynamsoft SDKs.
4
4
 
5
- - **Dynamsoft Capture Vision (DCV)** - Unified workflows for VIN, MRZ, document normalization, driver license parsing, and more
6
- - **Dynamsoft Barcode Reader Mobile** - Android (Java/Kotlin) and iOS (Swift)
7
- - **Dynamsoft Barcode Reader Server/Desktop** - Python, .NET, Java, C++, Node.js
8
- - **Dynamsoft Barcode Reader Web** - JavaScript/TypeScript barcode scanning
9
- - **Dynamic Web TWAIN** - Document scanning from TWAIN/WIA/ICA/SANE scanners
10
- - **Dynamsoft Document Viewer** - Web document viewing and annotation
5
+ Supported products:
6
+ - Dynamsoft Capture Vision (DCV)
7
+ - Dynamsoft Barcode Reader (DBR): mobile, web, server/desktop
8
+ - Dynamic Web TWAIN (DWT)
9
+ - Dynamsoft Document Viewer (DDV)
10
+
11
+ Default transport is `stdio`. Native Streamable HTTP is also supported at `/mcp`.
11
12
 
12
13
  ## Demo Video
14
+
13
15
  https://github.com/user-attachments/assets/cc1c5f4b-1461-4462-897a-75abc20d62a6
14
16
 
17
+ ## Two Supported Usage Scenarios
15
18
 
16
- ## Features
19
+ This project is intentionally documented for two real-world usage paths:
17
20
 
18
- - **Code Snippets**: Real, working source code from official Dynamsoft samples
19
- - **Trial License Included**: Ready-to-use trial license for quick testing
20
- - **Multiple SDKs**: Capture Vision + Barcode Reader (Mobile/Web/Server) + Dynamic Web TWAIN + Document Viewer
21
- - **Multiple API Levels**: High-level (simple) and low-level (advanced) options
22
- - **Stdio MCP server**: Runs on stdio. Works with any MCP-capable client.
23
- - **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`.
24
- - **Submodule-backed resources**: Samples and docs are pulled from official upstream repositories under `data/samples/` and `data/documentation/`.
25
- - **Dual-mode data loading**: local clone uses submodules; `npx simple-dynamsoft-mcp` auto-downloads pinned archives into a local cache when submodules are unavailable.
26
- - **Latest-major policy**: The server only serves the latest major versions; older major requests are refused with legacy links when available.
21
+ 1. Local usage with `npx -y simple-dynamsoft-mcp@latest` and minimal config
22
+ 2. HTTP deployment on Ubuntu with full data + prebuilt indexes + Gemini embeddings
27
23
 
28
- ## Available Tools
24
+ If you need deep operator/dev settings, see `AGENTS.md` and `.env.example`.
29
25
 
30
- | Tool | Description |
31
- |------|-------------|
32
- | `get_index` | Compact index of products, editions, versions, samples, and docs |
33
- | `search` | Unified search across docs and samples; returns resource links |
34
- | `list_samples` | List available sample IDs and URIs for a scope |
35
- | `resolve_sample` | Resolve a sample_id (or sample URI) to matching sample URIs |
36
- | `resolve_version` | Resolve a concrete latest-major version for a product/edition |
37
- | `get_quickstart` | Opinionated quickstart for a target stack |
38
- | `generate_project` | Assemble a project structure from a sample (no AI generation) |
26
+ ## Scenario 1: Local Usage (Recommended Default)
39
27
 
40
- `npx simple-dynamsoft-mcp` is supported. If bundled submodule data is missing, the server auto-downloads pinned data archives on first run (network required).
28
+ For most users, this is enough.
41
29
 
42
- ## MCP Client Configuration
30
+ Command:
43
31
 
44
- ### OpenCode
45
- Location:
46
- - **macOS**: `~/.config/opencode/opencode.json`
47
- - **Windows**: `%USERPROFILE%\.config\opencode\opencode.json`
32
+ ```bash
33
+ npx -y simple-dynamsoft-mcp@latest
34
+ ```
48
35
 
49
- Configuration:
50
- ```json
51
- {
52
- "$schema": "https://opencode.ai/config.json",
53
- "mcp": {
54
- "dynamsoft": {
55
- "type": "local",
56
- "command": [
57
- "npx",
58
- "simple-dynamsoft-mcp"
59
- ]
60
- }
61
- }
62
- }
36
+ Notes:
37
+ - No explicit environment variables are required for the default path.
38
+ - Default profile is lightweight (`lite`) and avoids local embedding model downloads.
39
+ - If local data is missing, the package can bootstrap pinned data from cache/download sources.
40
+
41
+ ## Scenario 2: Ubuntu HTTP Deployment (Full Data + Gemini)
42
+
43
+ Use this when you host the server remotely and expose MCP over HTTP.
44
+
45
+ ### 1) Prepare host
46
+
47
+ ```bash
48
+ sudo apt update
49
+ sudo apt install -y git curl
50
+ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
51
+ sudo apt install -y nodejs
52
+ node -v
53
+ npm -v
63
54
  ```
64
55
 
65
- ### Claude Desktop
56
+ ### 2) Clone and install
66
57
 
67
- Location:
68
- - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
69
- - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
58
+ ```bash
59
+ git clone --recurse-submodules https://github.com/yushulx/simple-dynamsoft-mcp.git
60
+ cd simple-dynamsoft-mcp
61
+ npm ci
62
+ ```
70
63
 
71
- Configuration:
72
- ```json
73
- {
74
- "mcpServers": {
75
- "dynamsoft": {
76
- "command": "npx",
77
- "args": ["-y", "simple-dynamsoft-mcp"]
78
- }
79
- }
80
- }
64
+ If you did not clone with submodules:
65
+
66
+ ```bash
67
+ npm run data:bootstrap
68
+ npm run data:sync
81
69
  ```
82
70
 
83
- ### VS Code with GitHub Copilot
71
+ ### 3) Configure environment
84
72
 
85
- Global Location:
73
+ Create `.env` in repo root:
86
74
 
87
- - **macOS**: `~/Library/Application Support/Code/User/mcp.json`
88
- - **Windows**: `%APPDATA%\Code\User\mcp.json`
75
+ ```dotenv
76
+ GEMINI_API_KEY=your_key_here
89
77
 
90
- ```json
91
- {
92
- "servers": {
93
- "dynamsoft": {
94
- "command": "npx",
95
- "args": ["-y", "simple-dynamsoft-mcp"]
96
- }
97
- }
98
- }
78
+ MCP_PROFILE=semantic-gemini
79
+ RAG_PROVIDER=gemini
80
+ RAG_FALLBACK=lexical
81
+
82
+ MCP_DATA_HYDRATION_MODE=eager
83
+ MCP_DATA_AUTO_DOWNLOAD=true
84
+ MCP_DATA_REFRESH_ON_START=false
85
+
86
+ RAG_PREBUILT_INDEX_AUTO_DOWNLOAD=true
87
+
88
+ MCP_LOG_LEVEL=info
99
89
  ```
100
90
 
101
- Or create workspace-specific `.vscode/mcp.json`:
91
+ ### 4) Start HTTP server
102
92
 
103
- ```json
104
- {
105
- "servers": {
106
- "dynamsoft": {
107
- "command": "npx",
108
- "args": ["-y", "simple-dynamsoft-mcp"]
109
- }
110
- }
111
- }
93
+ ```bash
94
+ node src/index.js --transport=http --host=0.0.0.0 --port=3333
112
95
  ```
113
96
 
114
- ### Cursor
97
+ Endpoint:
98
+ - `http://<server-ip>:3333/mcp`
99
+
100
+ ### 5) Optional: systemd service
101
+
102
+ Example `/etc/systemd/system/simple-dynamsoft-mcp.service`:
103
+
104
+ ```ini
105
+ [Unit]
106
+ Description=Simple Dynamsoft MCP Server
107
+ After=network.target
108
+
109
+ [Service]
110
+ Type=simple
111
+ WorkingDirectory=/opt/simple-dynamsoft-mcp
112
+ ExecStart=/usr/bin/node /opt/simple-dynamsoft-mcp/src/index.js --transport=http --host=0.0.0.0 --port=3333
113
+ EnvironmentFile=/opt/simple-dynamsoft-mcp/.env
114
+ Restart=always
115
+ RestartSec=3
116
+
117
+ [Install]
118
+ WantedBy=multi-user.target
119
+ ```
115
120
 
116
- Location:
117
- - **macOS**: `~/.cursor/mcp.json`
118
- - **Windows**: `%USERPROFILE%\.cursor\mcp.json`
121
+ Enable and start:
119
122
 
120
- Configuration:
123
+ ```bash
124
+ sudo systemctl daemon-reload
125
+ sudo systemctl enable simple-dynamsoft-mcp
126
+ sudo systemctl start simple-dynamsoft-mcp
127
+ sudo systemctl status simple-dynamsoft-mcp
128
+ ```
129
+
130
+ ## MCP Client Configuration
131
+
132
+ Use one of the following client configs.
133
+
134
+ ### OpenCode
135
+
136
+ Location:
137
+ - macOS: `~/.config/opencode/opencode.json`
138
+ - Windows: `%USERPROFILE%\.config\opencode\opencode.json`
121
139
 
122
140
  ```json
123
141
  {
124
- "mcpServers": {
142
+ "$schema": "https://opencode.ai/config.json",
143
+ "mcp": {
125
144
  "dynamsoft": {
126
- "command": "npx",
127
- "args": ["-y", "simple-dynamsoft-mcp"]
145
+ "type": "local",
146
+ "command": ["npx", "-y", "simple-dynamsoft-mcp@latest"]
128
147
  }
129
148
  }
130
149
  }
131
150
  ```
132
151
 
133
- ### Windsurf
152
+ ### Claude Desktop
134
153
 
135
154
  Location:
136
-
137
- - **macOS**: `~/.codeium/windsurf/mcp_config.json`
138
- - **Windows**: `%USERPROFILE%\.codeium\windsurf\mcp_config.json`
155
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
156
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
139
157
 
140
158
  ```json
141
159
  {
142
160
  "mcpServers": {
143
161
  "dynamsoft": {
144
162
  "command": "npx",
145
- "args": ["-y", "simple-dynamsoft-mcp"]
163
+ "args": ["-y", "simple-dynamsoft-mcp@latest"]
146
164
  }
147
165
  }
148
166
  }
149
167
  ```
150
168
 
169
+ ### VS Code with GitHub Copilot
151
170
 
152
- ### Alternative: Run from Local Clone
153
-
154
- If you prefer running from source:
171
+ Global location:
172
+ - macOS: `~/Library/Application Support/Code/User/mcp.json`
173
+ - Windows: `%APPDATA%\Code\User\mcp.json`
155
174
 
156
175
  ```json
157
176
  {
158
- "command": "node",
159
- "args": ["/absolute/path/to/simple-dynamsoft-mcp/src/index.js"]
177
+ "servers": {
178
+ "dynamsoft": {
179
+ "command": "npx",
180
+ "args": ["-y", "simple-dynamsoft-mcp@latest"]
181
+ }
182
+ }
160
183
  }
161
184
  ```
162
185
 
163
- ## Environment Variables in MCP Clients
186
+ Workspace alternative: `.vscode/mcp.json`
164
187
 
165
- When using `npx`, you can still configure the server by passing environment variables in your MCP client config.
188
+ ### Cursor
166
189
 
167
- Example:
190
+ Location:
191
+ - macOS: `~/.cursor/mcp.json`
192
+ - Windows: `%USERPROFILE%\.cursor\mcp.json`
168
193
 
169
194
  ```json
170
195
  {
171
196
  "mcpServers": {
172
197
  "dynamsoft": {
173
198
  "command": "npx",
174
- "args": ["-y", "simple-dynamsoft-mcp"],
175
- "env": {
176
- "RAG_PROVIDER": "auto",
177
- "MCP_DATA_AUTO_DOWNLOAD": "true",
178
- "MCP_DATA_REFRESH_ON_START": "false"
179
- }
199
+ "args": ["-y", "simple-dynamsoft-mcp@latest"]
180
200
  }
181
201
  }
182
202
  }
183
203
  ```
184
204
 
185
- Commonly used settings:
186
- - `RAG_PROVIDER`: `auto` | `gemini` | `local` | `fuse`
187
- - `RAG_FALLBACK`: `fuse` | `local` | `none`
188
- - `RAG_PREBUILT_INDEX_AUTO_DOWNLOAD`: `true` by default; auto-fetch prebuilt local index when local embeddings are selected
189
- - `RAG_PREBUILT_INDEX_URL`: override release asset URL for prebuilt index archive
190
- - `RAG_PREBUILT_INDEX_TIMEOUT_MS`: download timeout for prebuilt index fetch
191
- - `MCP_DATA_DIR`: use a preloaded local data folder (`metadata/`, `samples/`, `documentation/`)
192
- - `MCP_DATA_AUTO_DOWNLOAD`: allow startup archive download when bundled data is unavailable
193
- - `MCP_DATA_REFRESH_ON_START`: force re-download of pinned archives on startup
194
- - `MCP_DATA_CACHE_DIR`: customize downloaded data cache location
195
-
196
- If you want no embedding/model/network dependency for search, set `RAG_PROVIDER=fuse`.
197
-
198
- For the complete list and defaults, see `.env.example` and the sections `Submodule Setup` and `RAG Configuration` below.
199
-
200
- ## Use Release Assets In A Local Project
201
-
202
- Use this when you want to run from a built `.tgz` package and reuse a prebuilt local RAG index.
203
-
204
- 1. Download release assets from GitHub Releases for the same version:
205
- - `simple-dynamsoft-mcp-<version>.tgz`
206
- - `prebuilt-rag-index-<version>.tar.gz`
207
- 2. In your project folder, create a local tools folder, for example:
208
- - `<project>/.tools/simple-dynamsoft-mcp/`
209
- 3. Copy assets into that folder and extract the prebuilt index:
210
- - Keep `simple-dynamsoft-mcp-<version>.tgz` as-is for `npx --package`.
211
- - Extract `prebuilt-rag-index-<version>.tar.gz`.
212
- - Expected cache output path: `<project>/.tools/simple-dynamsoft-mcp/prebuilt-rag/cache/*.json`.
213
- 4. Configure project-local `.vscode/mcp.json` to use the local package and cache path.
205
+ ### Windsurf
214
206
 
215
- Example (`.vscode/mcp.json`):
207
+ Location:
208
+ - macOS: `~/.codeium/windsurf/mcp_config.json`
209
+ - Windows: `%USERPROFILE%\.codeium\windsurf\mcp_config.json`
216
210
 
217
211
  ```json
218
212
  {
219
- "servers": {
213
+ "mcpServers": {
220
214
  "dynamsoft": {
221
215
  "command": "npx",
222
- "args": [
223
- "-y",
224
- "--package",
225
- ".tools/simple-dynamsoft-mcp/simple-dynamsoft-mcp-<version>.tgz",
226
- "simple-dynamsoft-mcp"
227
- ],
228
- "env": {
229
- "RAG_PROVIDER": "auto",
230
- "RAG_FALLBACK": "local",
231
- "RAG_REBUILD": "false",
232
- "RAG_LOCAL_MODEL": "Xenova/all-MiniLM-L6-v2",
233
- "RAG_LOCAL_QUANTIZED": "true",
234
- "RAG_CACHE_DIR": ".tools/simple-dynamsoft-mcp/prebuilt-rag/cache"
235
- }
216
+ "args": ["-y", "simple-dynamsoft-mcp@latest"]
236
217
  }
237
218
  }
238
219
  }
239
220
  ```
240
221
 
241
- Notes:
242
- - Use absolute paths if your MCP client does not resolve relative paths from workspace root.
243
- - `RAG_REBUILD` must stay `false` to reuse prebuilt cache files.
244
- - Runtime auto-download is enabled by default (`RAG_PREBUILT_INDEX_AUTO_DOWNLOAD=true`) when provider resolution reaches local embeddings (primary or fallback).
245
- - Default prebuilt URL pattern: `https://github.com/yushulx/simple-dynamsoft-mcp/releases/download/v<version>/prebuilt-rag-index-<version>.tar.gz`.
246
- - Downloaded prebuilt cache is accepted when package version matches (with provider/model/payload sanity checks).
247
- - Prebuilt cache is used whenever provider execution resolves to local embeddings (primary or fallback).
248
-
249
- ## Supported SDKs
250
-
251
- ### Dynamsoft Capture Vision (DCV)
252
-
253
- DCV is a superset architecture that aggregates DBR, DLR, DDN, DCP, and DCE into one pluggable pipeline.
254
-
255
- Use **DBR** when you only need barcode decoding.
256
- Use **DCV** when your workflow includes VIN, MRZ/passport/ID, driver license parsing, document detection/normalization/auto-capture/cropping, or multi-task capture-vision pipelines.
257
-
258
- **DCV editions covered in this MCP server:**
259
- - **Core docs** - architecture and cross-product concepts
260
- - **Web (JavaScript)**
261
- - **Server/Desktop** - Python, .NET, Java, C++, Node.js
262
- - **Mobile** - Android, iOS, Flutter, React Native, .NET MAUI (+ SPM package sample)
263
-
264
- ### Dynamsoft Barcode Reader Mobile (latest)
265
-
266
- **Platforms:** Android, iOS, Flutter, React Native, .NET MAUI
267
-
268
- **API Levels:**
269
- - **High-Level (BarcodeScanner)**: Simple ready-to-use barcode scanning UI
270
- - **Low-Level (CaptureVisionRouter)**: Full control over the scanning pipeline
271
-
272
- **Android Samples:**
273
- - ScanSingleBarcode, ScanMultipleBarcodes, ScenarioOrientedSamples
274
- - DecodeWithCameraEnhancer, DecodeWithCameraX, DecodeFromAnImage
275
- - GeneralSettings, DriversLicenseScanner, TinyBarcodeDecoding, ReadGS1AI
276
-
277
- **iOS Samples:**
278
- - ScanSingleBarcode, ScanMultipleBarcodes, ScanSingleBarcodeSwiftUI
279
- - DecodeWithCameraEnhancer, DecodeWithAVCaptureSession, DecodeFromAnImage
280
-
281
- ### Dynamsoft Barcode Reader Server/Desktop (latest)
282
-
283
- **Platforms:** Python, .NET, Java, C++, Node.js
284
-
285
- **Python installation:** `pip install dynamsoft-barcode-reader-bundle`
286
-
287
- **Server/Desktop samples:** Pulled from platform-specific sample repositories in `data/samples/`.
288
-
289
- ### Dynamsoft Barcode Reader Web (latest)
290
-
291
- **Installation:** `npm install dynamsoft-barcode-reader-bundle`
292
-
293
- **CDN:** `https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@latest/dist/dbr.bundle.min.js`
294
-
295
- **Samples:**
296
- - **hello-world** - Basic barcode scanning from camera
297
- - **read-an-image** - Decode from image files
298
- - **frameworks/** - React, Vue, Angular, Next.js, PWA samples
299
- - **scenarios/** - Multi-image reading, localize an item, driver license parsing
300
-
301
- ### Dynamic Web TWAIN (latest)
302
-
303
- **Installation:** `npm install dwt`
304
-
305
- **CDN:** `https://cdn.jsdelivr.net/npm/dwt@latest/dist/dynamsoft.webtwain.min.js`
306
-
307
- **Sample Categories:**
308
- - **scan** - Basic document scanning (basic-scan, read-barcode, etc.)
309
- - **input-options** - Load from files, URLs, local drive
310
- - **output-options** - Save, upload, convert to PDF/Base64/Blob
311
- - **classification** - Document classification and tagging
312
- - **UI-customization** - Customize viewer and scan UI
313
-
314
- ### Dynamsoft Document Viewer (latest)
315
-
316
- **Installation:** `npm install dynamsoft-document-viewer`
317
-
318
- **CDN:** `https://cdn.jsdelivr.net/npm/dynamsoft-document-viewer@latest/dist/ddv.js`
319
-
320
- **Samples:**
321
- - **hello-world** - Basic viewer setup
322
- - **angular**, **react-vite**, **vue**, **next** - Framework starter samples
323
-
324
- ## Trial License
325
- https://www.dynamsoft.com/customer/license/trialLicense/?product=dcv&package=cross-platform
326
-
327
- ## Example AI Prompts
328
-
329
- After connecting the MCP server, you can ask your AI assistant:
330
-
331
- ### Mobile Barcode Scanner
332
- - "Create an Android app that scans a single barcode"
333
- - "Show me how to use CaptureVisionRouter in iOS Swift"
334
- - "Get the Gradle configuration for Dynamsoft Barcode Reader"
335
- - "How do I initialize the Dynamsoft license in Kotlin?"
336
-
337
- ### Server/Desktop Barcode Reader
338
- - "Show me how to read barcodes from an image in Python"
339
- - "Get me a Node.js barcode reader sample"
340
- - "List DBR .NET samples and generate one project"
341
-
342
- ### Web Barcode Reader
343
- - "Create a web page that scans barcodes from a camera"
344
- - "Show me the web barcode reader hello world sample"
345
- - "Get the React sample for web barcode scanning"
346
- - "How do I decode barcodes from an image in JavaScript?"
347
-
348
- ### Capture Vision (DCV)
349
- - "Find a DCV sample for MRZ scanning in Python"
350
- - "Get a VIN scanning sample for Java or C++"
351
- - "Show me DCV document normalization samples for mobile"
352
- - "I need driver license parsing; should I use DBR or DCV?"
353
- - "List DCV server samples and generate a project from MRZScanner"
354
-
355
- ### Dynamic Web TWAIN
356
- - "Create a web page that scans documents from a TWAIN scanner"
357
- - "Show me how to save scanned documents as PDF"
358
- - "Get the DWT sample for reading barcodes from scanned documents"
359
- - "Search the DWT docs for how to load images from files"
360
- - "Get the DWT documentation about OCR"
361
- - "How do I configure the PDF rasterizer in DWT?"
222
+ ## Available Tools
362
223
 
363
- ## SDK Documentation
224
+ The server exposes this minimal tool surface:
364
225
 
365
- - **DCV Core**: https://www.dynamsoft.com/capture-vision/docs/core/
366
- - **DCV Mobile**: https://www.dynamsoft.com/capture-vision/docs/mobile/
367
- - **DCV Server/Desktop**: https://www.dynamsoft.com/capture-vision/docs/server/
368
- - **DCV Web**: https://www.dynamsoft.com/capture-vision/docs/web/
369
- - **Mobile Android**: https://www.dynamsoft.com/barcode-reader/docs/mobile/programming/android/user-guide.html
370
- - **Mobile iOS**: https://www.dynamsoft.com/barcode-reader/docs/mobile/programming/objectivec-swift/user-guide.html
371
- - **Python**: https://www.dynamsoft.com/barcode-reader/docs/server/programming/python/user-guide.html
372
- - **Web JavaScript**: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/index.html
373
- - **Dynamic Web TWAIN**: https://www.dynamsoft.com/web-twain/docs/introduction/index.html
226
+ - `get_index`
227
+ - `search`
228
+ - `list_samples`
229
+ - `resolve_sample`
230
+ - `resolve_version`
231
+ - `get_quickstart`
232
+ - `generate_project`
374
233
 
375
- ## Data Repository Structure
234
+ ## Quick Troubleshooting
376
235
 
377
- ```
378
- data/
379
- |-- metadata/
380
- | |-- dynamsoft_sdks.json
381
- | `-- data-manifest.json # Pinned repo commits for runtime bootstrap
382
- |-- samples/ # Git submodules
383
- | |-- dynamsoft-barcode-reader
384
- | |-- dynamsoft-barcode-reader-mobile
385
- | |-- dynamsoft-barcode-reader-maui
386
- | |-- dynamsoft-barcode-reader-react-native
387
- | |-- dynamsoft-barcode-reader-flutter
388
- | |-- dynamsoft-barcode-reader-python
389
- | |-- dynamsoft-barcode-reader-dotnet
390
- | |-- dynamsoft-barcode-reader-java
391
- | |-- dynamsoft-barcode-reader-c-cpp
392
- | |-- dynamsoft-capture-vision-nodejs
393
- | |-- dynamsoft-capture-vision-c-cpp
394
- | |-- dynamsoft-capture-vision-dotnet
395
- | |-- dynamsoft-capture-vision-java
396
- | |-- dynamsoft-capture-vision-python
397
- | |-- dynamsoft-capture-vision-mobile
398
- | |-- dynamsoft-capture-vision-javascript
399
- | |-- dynamsoft-capture-vision-react-native
400
- | |-- dynamsoft-capture-vision-maui
401
- | |-- dynamsoft-capture-vision-flutter
402
- | |-- dynamsoft-capture-vision-spm
403
- | |-- dynamic-web-twain
404
- | `-- dynamsoft-document-viewer
405
- |-- documentation/ # Git submodules
406
- | |-- barcode-reader-docs-js
407
- | |-- barcode-reader-docs-mobile
408
- | |-- barcode-reader-docs-server
409
- | |-- capture-vision-docs
410
- | |-- capture-vision-docs-js
411
- | |-- capture-vision-docs-server
412
- | |-- capture-vision-docs-mobile
413
- | |-- web-twain-docs
414
- | `-- document-viewer-docs
415
- `-- .rag-cache/
416
- ```
236
+ - If startup says data is incomplete, run `npm run data:bootstrap` and `npm run data:sync` in clone-based deployments.
237
+ - For HTTP deployments, check service logs first:
238
+ - `journalctl -u simple-dynamsoft-mcp -f`
239
+ - For Gemini mode, confirm `GEMINI_API_KEY` is present in service environment.
240
+ - Structured startup logs include `[data]`, `[transport]`, and `[rag]` event lines.
417
241
 
418
- ## Source Code Structure
242
+ ## Advanced Configuration And Operator Docs
419
243
 
420
- ```
421
- src/
422
- |-- index.js # MCP server + tool handlers
423
- |-- data-bootstrap.js # Runtime data resolver/downloader (npx mode)
424
- |-- data-root.js # Shared resolved data root selection
425
- |-- rag.js # Search provider selection and retrieval
426
- |-- normalizers.js # Product/platform/edition normalization
427
- |-- submodule-sync.js # Optional startup fast-forward sync
428
- |-- resource-index.js # Resource index composition layer
429
- `-- resource-index/ # Split modules for maintainability
430
- |-- config.js
431
- |-- paths.js
432
- |-- docs-loader.js
433
- |-- samples.js
434
- |-- uri.js
435
- |-- version-policy.js
436
- `-- builders.js
437
- scripts/
438
- |-- sync-submodules.mjs # CLI wrapper for data:sync
439
- |-- update-sdk-versions.mjs # Sync SDK versions from docs structures
440
- |-- update-data-lock.mjs # Generate data-manifest from submodule HEADs
441
- |-- verify-data-lock.mjs # Verify manifest matches submodule HEADs
442
- `-- prebuild-rag-index.mjs # Build local RAG index cache artifacts
443
- test/
444
- `-- integration/
445
- |-- helpers.js # Shared MCP client/process helpers
446
- |-- stdio.test.js # stdio integration tests
447
- |-- http-gateway.test.js # supergateway streamable HTTP integration tests
448
- `-- package-runtime.test.js # npm pack + package runtime integration test
449
- ```
244
+ Advanced settings, CI/runbook details, and maintenance workflows live in:
450
245
 
451
- `src/` contains runtime server code. `scripts/` contains operational helpers used by npm scripts.
452
-
453
- ## Submodule Setup
454
-
455
- - Clone with submodules:
456
- - `git clone --recurse-submodules <repo-url>`
457
- - If already cloned:
458
- - `npm run data:bootstrap`
459
- - Check status:
460
- - `npm run data:status`
461
- - Sync submodules to configured branches (fast-forward only):
462
- - `npm run data:sync`
463
- - Refresh lock manifest after submodule updates:
464
- - `npm run data:lock`
465
- - Verify lock manifest matches submodule HEADs:
466
- - `npm run data:verify-lock`
467
- - Sync SDK versions from docs sources:
468
- - `npm run data:versions`
469
- - Strict source-structure verification (fail on unresolved sources):
470
- - `npm run data:verify-versions:strict`
471
-
472
- Optional startup sync:
473
- - `DATA_SYNC_ON_START=true`
474
- - `DATA_SYNC_TIMEOUT_MS=30000`
475
-
476
- Optional runtime data bootstrap (mainly for npm/npx installs):
477
- - `MCP_DATA_DIR=<existing data root>`
478
- - `MCP_DATA_AUTO_DOWNLOAD=true`
479
- - `MCP_DATA_CACHE_DIR=<cache path>`
480
- - `MCP_DATA_REFRESH_ON_START=false`
481
-
482
- Default cache location when `MCP_DATA_CACHE_DIR` is not set:
483
- - Windows: `%LOCALAPPDATA%\simple-dynamsoft-mcp\data`
484
- - Linux/macOS: `~/.cache/simple-dynamsoft-mcp/data`
485
-
486
- At startup, the server logs data mode/path to stderr:
487
- - `[data] mode=downloaded ... source=fresh-download|cache`
488
- - `[data] mode=bundled ...`
489
- - `[data] mode=custom ...`
490
-
491
- ## Automation
492
-
493
- - CI workflow: `.github/workflows/ci.yml`
494
- - CI jobs:
495
- - `test_fuse` on `ubuntu-latest` runs `npm run test:fuse` (stdio + HTTP gateway + package-runtime with fuse provider)
496
- - `test_local_provider` on `ubuntu-latest` restores RAG caches, runs `npm run rag:prebuild`, then `npm run test:local`
497
- - `test_gemini_provider` on `ubuntu-latest` (when `GEMINI_API_KEY` secret exists) prebuilds gemini RAG cache, then runs `npm run test:gemini`
498
- - Daily data-lock refresh workflow: `.github/workflows/update-data-lock.yml`
499
- - Refresh schedule: daily at 08:00 UTC (`0 8 * * *`) and manual trigger supported.
500
- - Refresh workflow runs strict source checks (`data:versions:strict`, `data:verify-versions:strict`) to fail fast when external docs/sample structures drift.
501
- - Refresh workflow creates/updates PR `chore/daily-data-refresh` and enables auto-merge when checks pass (requires repo settings support).
502
- - Release workflow: `.github/workflows/release.yml`
503
- - Release behavior:
504
- - Creates GitHub release when `package.json` version changes on `main`
505
- - Attaches `npm pack` artifact and prebuilt RAG index artifact (release workflow requires `GEMINI_API_KEY` for gemini prebuild path)
506
- - Publishes the package to npm from the release workflow (OIDC trusted publishing)
507
-
508
- ## Testing
509
-
510
- - `npm test`: default test entry (currently `npm run test:fuse`)
511
- - `npm run test:unit`: unit tests (retry/backoff/config helpers)
512
- - `npm run test:fuse`: integration coverage for fuse provider
513
- - `npm run test:local`: integration coverage for local provider
514
- - `npm run test:gemini`: integration coverage for gemini provider (requires `GEMINI_API_KEY`)
515
- - `npm run test:stdio`: stdio transport integration tests
516
- - `npm run test:http`: streamable HTTP (supergateway) integration tests
517
- - `npm run test:package`: `npm pack` + `npm exec --package` runtime test
518
- - Optional env toggles:
519
- - `RUN_FUSE_PROVIDER_TESTS=true|false`
520
- - `RUN_LOCAL_PROVIDER_TESTS=true|false`
521
- - `RUN_GEMINI_PROVIDER_TESTS=true|false`
522
-
523
- ## Using Search-Based Discovery (Recommended)
524
-
525
- - On session start, let your client call `tools/list` and `resources/list` (pinned only, not exhaustive).
526
- - Read pinned `doc://product-selection` first to choose DBR vs DCV correctly for the scenario.
527
- - For any query, call `search`; it uses semantic RAG retrieval (with fuzzy fallback) and returns `resource_link` entries.
528
- - Read only the links you need via `resources/read` to avoid bloating the context window.
529
- - If unsure what to search, call `get_index` first to see what is available.
530
-
531
- ## RAG Configuration
532
-
533
- 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.
534
-
535
- To keep the legacy fuzzy search (no model download), set `RAG_PROVIDER=fuse`.
536
-
537
- Key env vars:
538
- - `RAG_PROVIDER`: `auto` | `gemini` | `local` | `fuse`
539
- - `RAG_FALLBACK`: `fuse` | `local` | `none`
540
- - `GEMINI_API_KEY`: required for remote embeddings
541
- - `GEMINI_EMBED_MODEL`: e.g. `models/embedding-001` or `models/gemini-embedding-001`
542
- - `GEMINI_RETRY_MAX_ATTEMPTS`: max retry attempts for retryable errors (default `5`)
543
- - `GEMINI_RETRY_BASE_DELAY_MS`: exponential backoff base delay (default `500`)
544
- - `GEMINI_RETRY_MAX_DELAY_MS`: exponential backoff max delay cap (default `10000`)
545
- - `GEMINI_REQUEST_THROTTLE_MS`: fixed delay between Gemini requests (default `0`)
546
- - `RAG_LOCAL_MODEL`: default `Xenova/all-MiniLM-L6-v2`
547
- - `RAG_CACHE_DIR`: default `data/.rag-cache`
548
- - `RAG_PREBUILT_INDEX_AUTO_DOWNLOAD`: default `true`
549
- - `RAG_PREBUILT_INDEX_URL`: override release prebuilt index asset URL
550
- - `RAG_PREBUILT_INDEX_TIMEOUT_MS`: default `180000`
551
-
552
- Local embeddings download the model on first run and cache under `data/.rag-cache/models`.
553
- Advanced tuning:
554
- - `RAG_CHUNK_SIZE`, `RAG_CHUNK_OVERLAP`, `RAG_MAX_CHUNKS_PER_DOC`, `RAG_MAX_TEXT_CHARS`
555
- - `RAG_MIN_SCORE`, `RAG_INCLUDE_SCORE`, `RAG_REBUILD`, `RAG_PREWARM`, `RAG_PREWARM_BLOCK`, `RAG_LOCAL_QUANTIZED`, `GEMINI_EMBED_BATCH_SIZE`, `RAG_MODEL_CACHE_DIR`
556
-
557
- Gemini hardening behavior:
558
- - Retryable responses (`429`, `503`, transient `5xx`) use exponential backoff with jitter.
559
- - Optional throttling can pace request bursts with `GEMINI_REQUEST_THROTTLE_MS`.
560
- - Batch embedding adaptively downgrades batch size on repeated rate-limit responses.
561
- - Index build progress is checkpointed to disk and resumes from checkpoints after failures.
562
-
563
- For local dev, you can also use a `.env` file (see `.env.example`).
564
-
565
- ## Version Policy
566
-
567
- - This MCP server serves only the latest major version for each product (DCV, DBR, DWT, DDV).
568
- - DBR legacy docs are linked for v9 and v10. Requests below v9 are refused.
569
- - DCV has no legacy archive links in this server.
570
- - DWT archived docs are available for v16.1.1+ (specific versions are hardcoded).
571
- - DDV has no legacy archive links in this server.
572
-
573
- ## Roadmap
574
-
575
- - Deferred release automation plan and implementation notes are tracked in `TODO.md`.
576
- - If you are continuing release pipeline work, start with the checklist in `TODO.md`.
577
-
578
- ## Extending the Server
579
-
580
- ### Add New Samples
581
-
582
- Update the corresponding submodule under `data/samples/`.
583
-
584
- ### Update SDK Info
585
-
586
- Use `npm run data:versions` (or `npm run data:versions:strict`) to refresh SDK versions from docs sources.
587
- Edit `data/metadata/dynamsoft_sdks.json` manually only for non-version metadata updates (for example docs URLs, installation commands, or platform definitions).
246
+ - `AGENTS.md`
247
+ - `.env.example`
588
248
 
589
249
  ## License
590
250
 
591
251
  MIT
592
-