simple-dynamsoft-mcp 6.4.0 → 7.0.1

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 (48) hide show
  1. package/.env.example +29 -7
  2. package/README.md +157 -506
  3. package/data/metadata/data-manifest.json +2 -2
  4. package/package.json +12 -7
  5. package/scripts/prebuild-rag-index.mjs +1 -1
  6. package/scripts/run-gemini-tests.mjs +1 -1
  7. package/scripts/sync-submodules.mjs +1 -1
  8. package/scripts/verify-doc-resources.mjs +1 -1
  9. package/src/data/bootstrap.js +475 -0
  10. package/src/data/download-utils.js +99 -0
  11. package/src/data/hydration-mode.js +15 -0
  12. package/src/data/hydration-policy.js +39 -0
  13. package/src/data/repo-map.js +149 -0
  14. package/src/{data-root.js → data/root.js} +1 -1
  15. package/src/{submodule-sync.js → data/submodule-sync.js} +1 -1
  16. package/src/index.js +49 -1499
  17. package/src/observability/logging.js +51 -0
  18. package/src/rag/config.js +96 -0
  19. package/src/rag/index.js +266 -0
  20. package/src/rag/lexical-provider.js +170 -0
  21. package/src/rag/logger.js +46 -0
  22. package/src/rag/profile-config.js +48 -0
  23. package/src/rag/providers.js +585 -0
  24. package/src/rag/search-utils.js +166 -0
  25. package/src/rag/vector-cache.js +323 -0
  26. package/src/server/create-server.js +168 -0
  27. package/src/server/helpers/server-helpers.js +33 -0
  28. package/src/{resource-index → server/resource-index}/paths.js +2 -2
  29. package/src/{resource-index → server/resource-index}/samples.js +9 -1
  30. package/src/{resource-index.js → server/resource-index.js} +117 -92
  31. package/src/server/resources/register-resources.js +56 -0
  32. package/src/server/runtime-config.js +66 -0
  33. package/src/server/tools/register-index-tools.js +130 -0
  34. package/src/server/tools/register-project-tools.js +305 -0
  35. package/src/server/tools/register-quickstart-tools.js +572 -0
  36. package/src/server/tools/register-sample-tools.js +333 -0
  37. package/src/server/tools/register-version-tools.js +136 -0
  38. package/src/server/transports/http.js +84 -0
  39. package/src/server/transports/stdio.js +12 -0
  40. package/src/data-bootstrap.js +0 -255
  41. package/src/rag.js +0 -1245
  42. /package/src/{gemini-retry.js → rag/gemini-retry.js} +0 -0
  43. /package/src/{normalizers.js → server/normalizers.js} +0 -0
  44. /package/src/{resource-index → server/resource-index}/builders.js +0 -0
  45. /package/src/{resource-index → server/resource-index}/config.js +0 -0
  46. /package/src/{resource-index → server/resource-index}/docs-loader.js +0 -0
  47. /package/src/{resource-index → server/resource-index}/uri.js +0 -0
  48. /package/src/{resource-index → server/resource-index}/version-policy.js +0 -0
package/README.md CHANGED
@@ -1,600 +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
+ ```
120
+
121
+ Enable and start:
122
+
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.
115
133
 
116
- Location:
117
- - **macOS**: `~/.cursor/mcp.json`
118
- - **Windows**: `%USERPROFILE%\.cursor\mcp.json`
134
+ ### OpenCode
119
135
 
120
- Configuration:
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 index when local or gemini embeddings are selected
189
- - `RAG_PREBUILT_INDEX_URL`: global override release asset URL for prebuilt index archive
190
- - `RAG_PREBUILT_INDEX_URL_LOCAL`: override release asset URL for local prebuilt index archive
191
- - `RAG_PREBUILT_INDEX_URL_GEMINI`: override release asset URL for gemini prebuilt index archive
192
- - `RAG_PREBUILT_INDEX_TIMEOUT_MS`: download timeout for prebuilt index fetch
193
- - `MCP_DATA_DIR`: use a preloaded local data folder (`metadata/`, `samples/`, `documentation/`)
194
- - `MCP_DATA_AUTO_DOWNLOAD`: allow startup archive download when bundled data is unavailable
195
- - `MCP_DATA_REFRESH_ON_START`: force re-download of pinned archives on startup
196
- - `MCP_DATA_CACHE_DIR`: customize downloaded data cache location
197
-
198
- If you want no embedding/model/network dependency for search, set `RAG_PROVIDER=fuse`.
199
-
200
- For the complete list and defaults, see `.env.example` and the sections `Submodule Setup` and `RAG Configuration` below.
201
-
202
- ## Use Release Assets In A Local Project
203
-
204
- Use this when you want to run from a built `.tgz` package and reuse prebuilt RAG indexes.
205
-
206
- 1. Download release assets from GitHub Releases for the same version:
207
- - `simple-dynamsoft-mcp-<version>.tgz`
208
- - `prebuilt-rag-index-local-<version>.tar.gz`
209
- - `prebuilt-rag-index-gemini-<version>.tar.gz` (only needed if `RAG_PROVIDER=gemini`)
210
- 2. In your project folder, create a local tools folder, for example:
211
- - `<project>/.tools/simple-dynamsoft-mcp/`
212
- 3. Copy assets into that folder and extract the prebuilt index you plan to use:
213
- - Keep `simple-dynamsoft-mcp-<version>.tgz` as-is for `npx --package`.
214
- - Extract `prebuilt-rag-index-local-<version>.tar.gz` for local embeddings.
215
- - Extract `prebuilt-rag-index-gemini-<version>.tar.gz` for gemini embeddings.
216
- - Expected cache output path: `<project>/.tools/simple-dynamsoft-mcp/prebuilt-rag/<provider>/cache/*.json`.
217
- 4. Configure project-local `.vscode/mcp.json` to use the local package and cache path.
218
-
219
- Example (`.vscode/mcp.json`):
205
+ ### Windsurf
206
+
207
+ Location:
208
+ - macOS: `~/.codeium/windsurf/mcp_config.json`
209
+ - Windows: `%USERPROFILE%\.codeium\windsurf\mcp_config.json`
220
210
 
221
211
  ```json
222
212
  {
223
- "servers": {
213
+ "mcpServers": {
224
214
  "dynamsoft": {
225
215
  "command": "npx",
226
- "args": [
227
- "-y",
228
- "--package",
229
- ".tools/simple-dynamsoft-mcp/simple-dynamsoft-mcp-<version>.tgz",
230
- "simple-dynamsoft-mcp"
231
- ],
232
- "env": {
233
- "RAG_PROVIDER": "auto",
234
- "RAG_FALLBACK": "local",
235
- "RAG_REBUILD": "false",
236
- "RAG_LOCAL_MODEL": "Xenova/all-MiniLM-L6-v2",
237
- "RAG_LOCAL_QUANTIZED": "true",
238
- "RAG_CACHE_DIR": ".tools/simple-dynamsoft-mcp/prebuilt-rag/local/cache"
239
- }
216
+ "args": ["-y", "simple-dynamsoft-mcp@latest"]
240
217
  }
241
218
  }
242
219
  }
243
220
  ```
244
221
 
245
- Notes:
246
- - Use absolute paths if your MCP client does not resolve relative paths from workspace root.
247
- - `RAG_REBUILD` must stay `false` to reuse prebuilt cache files.
248
- - Runtime auto-download is enabled by default (`RAG_PREBUILT_INDEX_AUTO_DOWNLOAD=true`) when provider resolution reaches local embeddings (primary or fallback).
249
- - Default prebuilt URL patterns:
250
- - `https://github.com/yushulx/simple-dynamsoft-mcp/releases/download/v<version>/prebuilt-rag-index-local-<version>.tar.gz`
251
- - `https://github.com/yushulx/simple-dynamsoft-mcp/releases/download/v<version>/prebuilt-rag-index-gemini-<version>.tar.gz`
252
- - Downloaded prebuilt cache is accepted when package version matches (with provider/model/payload sanity checks).
253
- - Prebuilt cache is used whenever provider execution resolves to local or gemini embeddings (primary or fallback).
254
-
255
- ## Supported SDKs
256
-
257
- ### Dynamsoft Capture Vision (DCV)
258
-
259
- DCV is a superset architecture that aggregates DBR, DLR, DDN, DCP, and DCE into one pluggable pipeline.
260
-
261
- Use **DBR** when you only need barcode decoding.
262
- 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.
263
-
264
- **DCV editions covered in this MCP server:**
265
- - **Core docs** - architecture and cross-product concepts
266
- - **Web (JavaScript)**
267
- - **Server/Desktop** - Python, .NET, Java, C++, Node.js
268
- - **Mobile** - Android, iOS, Flutter, React Native, .NET MAUI (+ SPM package sample)
269
-
270
- ### Dynamsoft Barcode Reader Mobile (latest)
271
-
272
- **Platforms:** Android, iOS, Flutter, React Native, .NET MAUI
273
-
274
- **API Levels:**
275
- - **High-Level (BarcodeScanner)**: Simple ready-to-use barcode scanning UI
276
- - **Low-Level (CaptureVisionRouter)**: Full control over the scanning pipeline
277
-
278
- **Android Samples:**
279
- - ScanSingleBarcode, ScanMultipleBarcodes, ScenarioOrientedSamples
280
- - DecodeWithCameraEnhancer, DecodeWithCameraX, DecodeFromAnImage
281
- - GeneralSettings, DriversLicenseScanner, TinyBarcodeDecoding, ReadGS1AI
282
-
283
- **iOS Samples:**
284
- - ScanSingleBarcode, ScanMultipleBarcodes, ScanSingleBarcodeSwiftUI
285
- - DecodeWithCameraEnhancer, DecodeWithAVCaptureSession, DecodeFromAnImage
286
-
287
- ### Dynamsoft Barcode Reader Server/Desktop (latest)
288
-
289
- **Platforms:** Python, .NET, Java, C++, Node.js
290
-
291
- **Python installation:** `pip install dynamsoft-barcode-reader-bundle`
292
-
293
- **Server/Desktop samples:** Pulled from platform-specific sample repositories in `data/samples/`.
294
-
295
- ### Dynamsoft Barcode Reader Web (latest)
296
-
297
- **Installation:** `npm install dynamsoft-barcode-reader-bundle`
298
-
299
- **CDN:** `https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@latest/dist/dbr.bundle.min.js`
300
-
301
- **Samples:**
302
- - **hello-world** - Basic barcode scanning from camera
303
- - **read-an-image** - Decode from image files
304
- - **frameworks/** - React, Vue, Angular, Next.js, PWA samples
305
- - **scenarios/** - Multi-image reading, localize an item, driver license parsing
306
-
307
- ### Dynamic Web TWAIN (latest)
308
-
309
- **Installation:** `npm install dwt`
310
-
311
- **CDN:** `https://cdn.jsdelivr.net/npm/dwt@latest/dist/dynamsoft.webtwain.min.js`
312
-
313
- **Sample Categories:**
314
- - **scan** - Basic document scanning (basic-scan, read-barcode, etc.)
315
- - **input-options** - Load from files, URLs, local drive
316
- - **output-options** - Save, upload, convert to PDF/Base64/Blob
317
- - **classification** - Document classification and tagging
318
- - **UI-customization** - Customize viewer and scan UI
319
-
320
- ### Dynamsoft Document Viewer (latest)
321
-
322
- **Installation:** `npm install dynamsoft-document-viewer`
323
-
324
- **CDN:** `https://cdn.jsdelivr.net/npm/dynamsoft-document-viewer@latest/dist/ddv.js`
325
-
326
- **Samples:**
327
- - **hello-world** - Basic viewer setup
328
- - **angular**, **react-vite**, **vue**, **next** - Framework starter samples
329
-
330
- ## Trial License
331
- https://www.dynamsoft.com/customer/license/trialLicense/?product=dcv&package=cross-platform
332
-
333
- ## Example AI Prompts
334
-
335
- After connecting the MCP server, you can ask your AI assistant:
336
-
337
- ### Mobile Barcode Scanner
338
- - "Create an Android app that scans a single barcode"
339
- - "Show me how to use CaptureVisionRouter in iOS Swift"
340
- - "Get the Gradle configuration for Dynamsoft Barcode Reader"
341
- - "How do I initialize the Dynamsoft license in Kotlin?"
342
-
343
- ### Server/Desktop Barcode Reader
344
- - "Show me how to read barcodes from an image in Python"
345
- - "Get me a Node.js barcode reader sample"
346
- - "List DBR .NET samples and generate one project"
347
-
348
- ### Web Barcode Reader
349
- - "Create a web page that scans barcodes from a camera"
350
- - "Show me the web barcode reader hello world sample"
351
- - "Get the React sample for web barcode scanning"
352
- - "How do I decode barcodes from an image in JavaScript?"
353
-
354
- ### Capture Vision (DCV)
355
- - "Find a DCV sample for MRZ scanning in Python"
356
- - "Get a VIN scanning sample for Java or C++"
357
- - "Show me DCV document normalization samples for mobile"
358
- - "I need driver license parsing; should I use DBR or DCV?"
359
- - "List DCV server samples and generate a project from MRZScanner"
360
-
361
- ### Dynamic Web TWAIN
362
- - "Create a web page that scans documents from a TWAIN scanner"
363
- - "Show me how to save scanned documents as PDF"
364
- - "Get the DWT sample for reading barcodes from scanned documents"
365
- - "Search the DWT docs for how to load images from files"
366
- - "Get the DWT documentation about OCR"
367
- - "How do I configure the PDF rasterizer in DWT?"
222
+ ## Available Tools
368
223
 
369
- ## SDK Documentation
224
+ The server exposes this minimal tool surface:
370
225
 
371
- - **DCV Core**: https://www.dynamsoft.com/capture-vision/docs/core/
372
- - **DCV Mobile**: https://www.dynamsoft.com/capture-vision/docs/mobile/
373
- - **DCV Server/Desktop**: https://www.dynamsoft.com/capture-vision/docs/server/
374
- - **DCV Web**: https://www.dynamsoft.com/capture-vision/docs/web/
375
- - **Mobile Android**: https://www.dynamsoft.com/barcode-reader/docs/mobile/programming/android/user-guide.html
376
- - **Mobile iOS**: https://www.dynamsoft.com/barcode-reader/docs/mobile/programming/objectivec-swift/user-guide.html
377
- - **Python**: https://www.dynamsoft.com/barcode-reader/docs/server/programming/python/user-guide.html
378
- - **Web JavaScript**: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/index.html
379
- - **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`
380
233
 
381
- ## Data Repository Structure
234
+ ## Quick Troubleshooting
382
235
 
383
- ```
384
- data/
385
- |-- metadata/
386
- | |-- dynamsoft_sdks.json
387
- | `-- data-manifest.json # Pinned repo commits for runtime bootstrap
388
- |-- samples/ # Git submodules
389
- | |-- dynamsoft-barcode-reader
390
- | |-- dynamsoft-barcode-reader-mobile
391
- | |-- dynamsoft-barcode-reader-maui
392
- | |-- dynamsoft-barcode-reader-react-native
393
- | |-- dynamsoft-barcode-reader-flutter
394
- | |-- dynamsoft-barcode-reader-python
395
- | |-- dynamsoft-barcode-reader-dotnet
396
- | |-- dynamsoft-barcode-reader-java
397
- | |-- dynamsoft-barcode-reader-c-cpp
398
- | |-- dynamsoft-capture-vision-nodejs
399
- | |-- dynamsoft-capture-vision-c-cpp
400
- | |-- dynamsoft-capture-vision-dotnet
401
- | |-- dynamsoft-capture-vision-java
402
- | |-- dynamsoft-capture-vision-python
403
- | |-- dynamsoft-capture-vision-mobile
404
- | |-- dynamsoft-capture-vision-javascript
405
- | |-- dynamsoft-capture-vision-react-native
406
- | |-- dynamsoft-capture-vision-maui
407
- | |-- dynamsoft-capture-vision-flutter
408
- | |-- dynamsoft-capture-vision-spm
409
- | |-- dynamic-web-twain
410
- | `-- dynamsoft-document-viewer
411
- |-- documentation/ # Git submodules
412
- | |-- barcode-reader-docs-js
413
- | |-- barcode-reader-docs-mobile
414
- | |-- barcode-reader-docs-server
415
- | |-- capture-vision-docs
416
- | |-- capture-vision-docs-js
417
- | |-- capture-vision-docs-server
418
- | |-- capture-vision-docs-mobile
419
- | |-- web-twain-docs
420
- | `-- document-viewer-docs
421
- `-- .rag-cache/
422
- ```
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.
423
241
 
424
- ## Source Code Structure
242
+ ## Advanced Configuration And Operator Docs
425
243
 
426
- ```
427
- src/
428
- |-- index.js # MCP server + tool handlers
429
- |-- data-bootstrap.js # Runtime data resolver/downloader (npx mode)
430
- |-- data-root.js # Shared resolved data root selection
431
- |-- rag.js # Search provider selection and retrieval
432
- |-- normalizers.js # Product/platform/edition normalization
433
- |-- submodule-sync.js # Optional startup fast-forward sync
434
- |-- resource-index.js # Resource index composition layer
435
- `-- resource-index/ # Split modules for maintainability
436
- |-- config.js
437
- |-- paths.js
438
- |-- docs-loader.js
439
- |-- samples.js
440
- |-- uri.js
441
- |-- version-policy.js
442
- `-- builders.js
443
- scripts/
444
- |-- sync-submodules.mjs # CLI wrapper for data:sync
445
- |-- update-sdk-versions.mjs # Sync SDK versions from docs structures
446
- |-- update-data-lock.mjs # Generate data-manifest from submodule HEADs
447
- |-- verify-data-lock.mjs # Verify manifest matches submodule HEADs
448
- `-- prebuild-rag-index.mjs # Build local RAG index cache artifacts
449
- test/
450
- `-- integration/
451
- |-- helpers.js # Shared MCP client/process helpers
452
- |-- stdio.test.js # stdio integration tests
453
- |-- http-gateway.test.js # supergateway streamable HTTP integration tests
454
- `-- package-runtime.test.js # npm pack + package runtime integration test
455
- ```
244
+ Advanced settings, CI/runbook details, and maintenance workflows live in:
456
245
 
457
- `src/` contains runtime server code. `scripts/` contains operational helpers used by npm scripts.
458
-
459
- ## Submodule Setup
460
-
461
- - Clone with submodules:
462
- - `git clone --recurse-submodules <repo-url>`
463
- - If already cloned:
464
- - `npm run data:bootstrap`
465
- - Check status:
466
- - `npm run data:status`
467
- - Sync submodules to configured branches (fast-forward only):
468
- - `npm run data:sync`
469
- - Refresh lock manifest after submodule updates:
470
- - `npm run data:lock`
471
- - Verify lock manifest matches submodule HEADs:
472
- - `npm run data:verify-lock`
473
- - Sync SDK versions from docs sources:
474
- - `npm run data:versions`
475
- - Strict source-structure verification (fail on unresolved sources):
476
- - `npm run data:verify-versions:strict`
477
-
478
- Optional startup sync:
479
- - `DATA_SYNC_ON_START=true`
480
- - `DATA_SYNC_TIMEOUT_MS=30000`
481
-
482
- Optional runtime data bootstrap (mainly for npm/npx installs):
483
- - `MCP_DATA_DIR=<existing data root>`
484
- - `MCP_DATA_AUTO_DOWNLOAD=true`
485
- - `MCP_DATA_CACHE_DIR=<cache path>`
486
- - `MCP_DATA_REFRESH_ON_START=false`
487
-
488
- Default cache location when `MCP_DATA_CACHE_DIR` is not set:
489
- - Windows: `%LOCALAPPDATA%\simple-dynamsoft-mcp\data`
490
- - Linux/macOS: `~/.cache/simple-dynamsoft-mcp/data`
491
-
492
- At startup, the server logs data mode/path to stderr:
493
- - `[data] mode=downloaded ... source=fresh-download|cache`
494
- - `[data] mode=bundled ...`
495
- - `[data] mode=custom ...`
496
-
497
- ## Automation
498
-
499
- - CI workflow: `.github/workflows/ci.yml`
500
- - CI jobs:
501
- - `test_fuse` on `ubuntu-latest` runs `npm run test:fuse` (stdio + HTTP gateway + package-runtime with fuse provider)
502
- - `test_local_provider` on `ubuntu-latest` restores RAG caches, runs `npm run rag:prebuild`, then `npm run test:local`
503
- - `test_gemini_provider` on `ubuntu-latest` (when `GEMINI_API_KEY` secret exists) prebuilds gemini RAG cache, then runs `npm run test:gemini`
504
- - Daily data-lock refresh workflow: `.github/workflows/update-data-lock.yml`
505
- - Refresh schedule: daily at 08:00 UTC (`0 8 * * *`) and manual trigger supported.
506
- - Refresh workflow runs strict source checks (`data:versions:strict`, `data:verify-versions:strict`) to fail fast when external docs/sample structures drift.
507
- - Refresh workflow creates/updates PR `chore/daily-data-refresh` and enables auto-merge when checks pass (requires repo settings support).
508
- - Release workflow: `.github/workflows/release.yml`
509
- - Release behavior:
510
- - Creates GitHub release when `package.json` version changes on `main`
511
- - Attaches `npm pack` artifact plus separate prebuilt RAG index archives for local and gemini providers (release workflow requires `GEMINI_API_KEY` for gemini prebuild path)
512
- - Publishes the package to npm from the release workflow (OIDC trusted publishing)
513
-
514
- ## Testing
515
-
516
- - `npm test`: default test entry (currently `npm run test:fuse`)
517
- - `npm run test:unit`: unit tests (retry/backoff/config helpers)
518
- - `npm run test:fuse`: integration coverage for fuse provider
519
- - `npm run test:local`: integration coverage for local provider
520
- - `npm run test:gemini`: integration coverage for gemini provider (requires `GEMINI_API_KEY`)
521
- - `npm run test:stdio`: stdio transport integration tests
522
- - `npm run test:http`: streamable HTTP (supergateway) integration tests
523
- - `npm run test:package`: `npm pack` + `npm exec --package` runtime test
524
- - Optional env toggles:
525
- - `RUN_FUSE_PROVIDER_TESTS=true|false`
526
- - `RUN_LOCAL_PROVIDER_TESTS=true|false`
527
- - `RUN_GEMINI_PROVIDER_TESTS=true|false`
528
-
529
- ## Using Search-Based Discovery (Recommended)
530
-
531
- - On session start, let your client call `tools/list` and `resources/list` (pinned only, not exhaustive).
532
- - Read pinned `doc://product-selection` first to choose DBR vs DCV correctly for the scenario.
533
- - For any query, call `search`; it uses semantic RAG retrieval (with fuzzy fallback) and returns `resource_link` entries.
534
- - Read only the links you need via `resources/read` to avoid bloating the context window.
535
- - If unsure what to search, call `get_index` first to see what is available.
536
-
537
- ## RAG Configuration
538
-
539
- 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.
540
-
541
- To keep the legacy fuzzy search (no model download), set `RAG_PROVIDER=fuse`.
542
-
543
- Key env vars:
544
- - `RAG_PROVIDER`: `auto` | `gemini` | `local` | `fuse`
545
- - `RAG_FALLBACK`: `fuse` | `local` | `none`
546
- - `GEMINI_API_KEY`: required for remote embeddings
547
- - `GEMINI_EMBED_MODEL`: e.g. `models/embedding-001` or `models/gemini-embedding-001`
548
- - `GEMINI_RETRY_MAX_ATTEMPTS`: max retry attempts for retryable errors (default `5`)
549
- - `GEMINI_RETRY_BASE_DELAY_MS`: exponential backoff base delay (default `500`)
550
- - `GEMINI_RETRY_MAX_DELAY_MS`: exponential backoff max delay cap (default `10000`)
551
- - `GEMINI_REQUEST_THROTTLE_MS`: fixed delay between Gemini requests (default `0`)
552
- - `RAG_LOCAL_MODEL`: default `Xenova/all-MiniLM-L6-v2`
553
- - `RAG_CACHE_DIR`: default `data/.rag-cache`
554
- - `RAG_PREBUILT_INDEX_AUTO_DOWNLOAD`: default `true`
555
- - `RAG_PREBUILT_INDEX_URL`: global override for release prebuilt index asset URL
556
- - `RAG_PREBUILT_INDEX_URL_LOCAL`: override for local prebuilt index asset URL
557
- - `RAG_PREBUILT_INDEX_URL_GEMINI`: override for gemini prebuilt index asset URL
558
- - `RAG_PREBUILT_INDEX_TIMEOUT_MS`: default `180000`
559
-
560
- Local embeddings download the model on first run and cache under `data/.rag-cache/models`.
561
- Advanced tuning:
562
- - `RAG_CHUNK_SIZE`, `RAG_CHUNK_OVERLAP`, `RAG_MAX_CHUNKS_PER_DOC`, `RAG_MAX_TEXT_CHARS`
563
- - `RAG_MIN_SCORE`, `RAG_INCLUDE_SCORE`, `RAG_REBUILD`, `RAG_PREWARM`, `RAG_PREWARM_BLOCK`, `RAG_LOCAL_QUANTIZED`, `GEMINI_EMBED_BATCH_SIZE`, `RAG_MODEL_CACHE_DIR`
564
-
565
- Gemini hardening behavior:
566
- - Retryable responses (`429`, `503`, transient `5xx`) use exponential backoff with jitter.
567
- - Optional throttling can pace request bursts with `GEMINI_REQUEST_THROTTLE_MS`.
568
- - Batch embedding adaptively downgrades batch size on repeated rate-limit responses.
569
- - Index build progress is checkpointed to disk and resumes from checkpoints after failures.
570
-
571
- For local dev, you can also use a `.env` file (see `.env.example`).
572
-
573
- ## Version Policy
574
-
575
- - This MCP server serves only the latest major version for each product (DCV, DBR, DWT, DDV).
576
- - DBR legacy docs are linked for v9 and v10. Requests below v9 are refused.
577
- - DCV has no legacy archive links in this server.
578
- - DWT archived docs are available for v16.1.1+ (specific versions are hardcoded).
579
- - DDV has no legacy archive links in this server.
580
-
581
- ## Roadmap
582
-
583
- - Deferred release automation plan and implementation notes are tracked in `TODO.md`.
584
- - If you are continuing release pipeline work, start with the checklist in `TODO.md`.
585
-
586
- ## Extending the Server
587
-
588
- ### Add New Samples
589
-
590
- Update the corresponding submodule under `data/samples/`.
591
-
592
- ### Update SDK Info
593
-
594
- Use `npm run data:versions` (or `npm run data:versions:strict`) to refresh SDK versions from docs sources.
595
- 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`
596
248
 
597
249
  ## License
598
250
 
599
251
  MIT
600
-