You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+97-33Lines changed: 97 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,10 +33,12 @@ Once configured, you (or your AI agent) can process documents through natural la
33
33
34
34
## Quick Start
35
35
36
-
### 1. Get a Nutrient API Key
36
+
### 1. Create a Nutrient Account
37
37
38
38
Sign up for free at [nutrient.io/api](https://dashboard.nutrient.io/sign_up/).
39
39
40
+
For local desktop use, the recommended path is to omit `NUTRIENT_DWS_API_KEY` and complete the browser sign-in flow on the first DWS-backed tool call. For CI, headless environments, or scripted setups, create an API key in the dashboard and set `NUTRIENT_DWS_API_KEY`.
41
+
40
42
### 2. Configure Your AI Client
41
43
42
44
Choose your platform and add the configuration:
@@ -56,12 +58,13 @@ Open Settings → Developer → Edit Config, then add:
56
58
"command":"npx",
57
59
"args": ["-y", "@nutrient-sdk/dws-mcp-server"],
58
60
"env": {
59
-
"NUTRIENT_DWS_API_KEY":"YOUR_API_KEY_HERE",
60
61
"SANDBOX_PATH":"/your/sandbox/directory",
61
62
// "C:\\your\\sandbox\\directory" for Windows
62
-
},
63
-
},
64
-
},
63
+
// Optional for CI or headless usage:
64
+
// "NUTRIENT_DWS_API_KEY": "YOUR_API_KEY_HERE"
65
+
}
66
+
}
67
+
}
65
68
}
66
69
```
67
70
@@ -79,12 +82,13 @@ Create `.cursor/mcp.json` in your project root:
79
82
"command":"npx",
80
83
"args": ["-y", "@nutrient-sdk/dws-mcp-server"],
81
84
"env": {
82
-
"NUTRIENT_DWS_API_KEY":"YOUR_API_KEY_HERE",
83
85
"SANDBOX_PATH":"/your/project/documents",
84
86
// "C:\\your\\project\\documents" for Windows
85
-
},
86
-
},
87
-
},
87
+
// Optional for CI or headless usage:
88
+
// "NUTRIENT_DWS_API_KEY": "YOUR_API_KEY_HERE"
89
+
}
90
+
}
91
+
}
88
92
}
89
93
```
90
94
@@ -102,12 +106,13 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
102
106
"command":"npx",
103
107
"args": ["-y", "@nutrient-sdk/dws-mcp-server"],
104
108
"env": {
105
-
"NUTRIENT_DWS_API_KEY":"YOUR_API_KEY_HERE",
106
109
"SANDBOX_PATH":"/your/sandbox/directory",
107
110
// "C:\\your\\sandbox\\directory" for Windows
108
-
},
109
-
},
110
-
},
111
+
// Optional for CI or headless usage:
112
+
// "NUTRIENT_DWS_API_KEY": "YOUR_API_KEY_HERE"
113
+
}
114
+
}
115
+
}
111
116
}
112
117
```
113
118
@@ -118,16 +123,17 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
118
123
119
124
Add to `.vscode/settings.json` in your project:
120
125
121
-
```json
126
+
```jsonc
122
127
{
123
128
"mcp": {
124
129
"servers": {
125
130
"nutrient-dws": {
126
131
"command":"npx",
127
132
"args": ["-y", "@nutrient-sdk/dws-mcp-server"],
128
133
"env": {
129
-
"NUTRIENT_DWS_API_KEY": "YOUR_API_KEY_HERE",
130
-
"SANDBOX_PATH": "${workspaceFolder}"
134
+
"SANDBOX_PATH":"${workspaceFolder}",
135
+
// Optional for CI or headless usage:
136
+
// "NUTRIENT_DWS_API_KEY": "YOUR_API_KEY_HERE"
131
137
}
132
138
}
133
139
}
@@ -143,6 +149,9 @@ Add to `.vscode/settings.json` in your project:
143
149
Any MCP-compatible client can connect using stdio transport:
@@ -154,16 +163,18 @@ Restart the application to pick up the new MCP server configuration.
154
163
155
164
### 4. Start Processing Documents
156
165
157
-
Drop documents into your sandbox directory and start giving instructions!
166
+
Place documents in your sandbox directory and use explicit file names or paths in prompts. Explicit paths are safer and more reliable than vague file-browsing requests.
|**document_signer**| Digitally sign PDFs with PAdES-compliant CMS or CAdES signatures, with customizable visible/invisible signature appearances |
165
-
|**sandbox_file_tree**| Browse files in the sandbox directory (when sandbox mode is enabled) |
166
-
|**directory_tree**| Browse directory contents (when sandbox mode is disabled) |
170
+
| Tool | Description |
171
+
| ---- | ----------- |
172
+
|`document_processor`| Nutrient DWS document processing tool for conversions, OCR, extraction, watermarking, rotation, annotation flattening, and redaction workflows |
173
+
|`document_signer`| Nutrient DWS signing tool for CMS / PKCS#7 and CAdES signatures with visible or invisible appearance options |
174
+
|`ai_redactor`| Nutrient DWS AI redaction tool for detecting and permanently removing sensitive content such as names, addresses, SSNs, emails, and custom criteria |
175
+
|`check_credits`| Read-only account lookup for current DWS credits and usage. No document content is uploaded |
176
+
|`sandbox_file_tree`| Read-only view of files inside the configured sandbox directory |
177
+
|`directory_tree`| Read-only view of local files when sandbox mode is disabled. Sandbox mode is strongly recommended |
167
178
168
179
### Document Processor Capabilities
169
180
@@ -179,6 +190,32 @@ Drop documents into your sandbox directory and start giving instructions!
| Digital Signing | PAdES-compliant CMS and CAdES digital signatures (via document_signer tool) |
181
192
193
+
## Example Prompts
194
+
195
+
These examples assume your files live inside the configured sandbox and that you use explicit paths.
196
+
197
+
### HTML -> PDF -> signing
198
+
199
+
```text
200
+
Convert /path/to/sandbox/invoice.html to PDF and save it as /path/to/sandbox/invoice.pdf.
201
+
```
202
+
203
+
```text
204
+
Digitally sign /path/to/sandbox/invoice.pdf with a visible signature and save it as /path/to/sandbox/invoice-signed.pdf.
205
+
```
206
+
207
+
### OCR extraction
208
+
209
+
```text
210
+
Run OCR on /path/to/sandbox/scanned-contract.pdf, return the extracted text, and save the OCR'd file as /path/to/sandbox/scanned-contract-ocr.pdf.
211
+
```
212
+
213
+
### Check credits -> process -> inspect output
214
+
215
+
```text
216
+
Check my Nutrient credits, convert /path/to/sandbox/report.docx to PDF, save it as /path/to/sandbox/report.pdf, and then tell me where the output file was written.
217
+
```
218
+
182
219
## Use with AI Agent Frameworks
183
220
184
221
This MCP server works with any platform that supports the Model Context Protocol:
Supported CLI flags are `--sandbox <dir>` and `-s <dir>`. Unknown CLI flags fail fast instead of silently disabling sandboxing.
256
+
218
257
When sandbox mode is enabled:
219
258
220
259
- Relative paths resolve relative to the sandbox directory
@@ -225,7 +264,7 @@ When sandbox mode is enabled:
225
264
226
265
### Output Location
227
266
228
-
Processed files are saved to a location determined by the AI. To guide output placement, use natural language (e.g., "save the result to `output/result.pdf`") or create an `output` directory in your sandbox.
267
+
Processed files are saved to a location determined by the AI. To guide output placement, use explicit output paths such as `save the result to /path/to/sandbox/output/result.pdf` or create an `output` directory in your sandbox.
229
268
230
269
### Authentication
231
270
@@ -234,27 +273,52 @@ The server authenticates to the Nutrient DWS API (`https://api.nutrient.io`) usi
234
273
| Method | When | Config |
235
274
|--------|------|--------|
236
275
|**API key**|`NUTRIENT_DWS_API_KEY` is set | Static key passed as Bearer token to DWS API |
237
-
|**OAuth browser flow**| No API key set | Opens browser for Nutrient OAuth consent, caches token locally |
276
+
|**OAuth browser flow**| No API key set | Opens browser for Nutrient OAuth consent on the first DWS-backed tool call, caches token locally |
238
277
239
-
When no API key is configured, the server opens a browser-based OAuth flow on the first tool call (similar to `gh auth login`). Tokens are cached at `$XDG_CONFIG_HOME/nutrient/credentials.json` or `~/.config/nutrient/credentials.json` and refreshed automatically.
278
+
When no API key is configured, the server stays connected and opens a browser-based OAuth flow on the first DWS-backed tool call (similar to `gh auth login`). Tokens are cached at `$XDG_CONFIG_HOME/nutrient/credentials.json` or `~/.config/nutrient/credentials.json` and refreshed automatically.
|`NUTRIENT_DWS_API_KEY`| No*| Nutrient DWS API key ([get one free](https://dashboard.nutrient.io/sign_up/)) |
246
-
|`SANDBOX_PATH`| Recommended | Directory to restrict file operations to |
247
-
|`CLIENT_ID`| No | OAuth client ID. Skips DCR and enables token refresh when set |
248
-
|`DWS_API_BASE_URL`| No | DWS API base URL (default: `https://api.nutrient.io`) |
249
-
|`LOG_LEVEL`| No | Winston logger level (`info` default). Logs are written to `MCP_LOG_FILE` in stdio mode |
250
-
|`MCP_LOG_FILE`| No | Override log file path (default: system temp directory) |
284
+
|`NUTRIENT_DWS_API_KEY`| No*| Nutrient DWS API key ([get one free](https://dashboard.nutrient.io/sign_up/)) |
285
+
|`SANDBOX_PATH`| Recommended | Directory to restrict file operations to |
286
+
|`AUTH_SERVER_URL`| No | OAuth server base URL (default: `https://api.nutrient.io`) |
287
+
|`CLIENT_ID`| No | OAuth client ID. Skips DCR and enables refresh token reuse when set |
288
+
|`DWS_API_BASE_URL`| No | DWS API base URL (default: `https://api.nutrient.io`) |
289
+
|`LOG_LEVEL`| No | Winston logger level (`info` default). Logs are written to `MCP_LOG_FILE` in stdio mode |
290
+
|`MCP_LOG_FILE`| No | Override log file path (default: system temp directory) |
251
291
252
292
\* If omitted, the server uses an OAuth browser flow to authenticate with the Nutrient API.
253
293
294
+
## Data Handling
295
+
296
+
### What Stays Local
297
+
298
+
- The MCP server process, sandbox enforcement, and file path resolution run on the local machine.
299
+
-`sandbox_file_tree` and `directory_tree` inspect local files only. They do not upload document contents to Nutrient.
300
+
- API keys and OAuth credentials are stored locally on the machine running the MCP server.
301
+
302
+
### What Gets Sent to Nutrient
303
+
304
+
-`document_processor`, `document_signer`, and `ai_redactor` send the relevant request metadata and referenced document bytes to the Nutrient DWS API so the requested operation can run.
305
+
-`check_credits` sends an authenticated account lookup but does not upload document files.
306
+
- Processed results are written back to the local output path you request.
307
+
254
308
### Security Note: Token Storage
255
309
256
310
When using the OAuth browser flow, access tokens and refresh tokens are cached in plaintext at `$XDG_CONFIG_HOME/nutrient/credentials.json` or `~/.config/nutrient/credentials.json` (permissions `0600`). This file contains credentials equivalent to your API key. Do not commit it to version control or include it in shared backups.
257
311
312
+
## Privacy Policy
313
+
314
+
Nutrient's privacy policy is available at [nutrient.io/legal/privacy](https://www.nutrient.io/legal/privacy/).
315
+
316
+
## Support
317
+
318
+
For product or account support, contact Nutrient at [nutrient.io/company/contact](https://www.nutrient.io/company/contact/).
319
+
320
+
For bugs or feature requests specific to this MCP package, use [GitHub issues](https://github.com/PSPDFKit/nutrient-dws-mcp-server/issues).
321
+
258
322
## Troubleshooting
259
323
260
324
### Reset authentication to a clean state
@@ -303,7 +367,7 @@ The server will automatically register a new client and open the browser for con
303
367
304
368
- Check that `SANDBOX_PATH` points to an existing directory
305
369
- Ensure your documents are inside the sandbox directory
306
-
-Use the `sandbox_file_tree` tool to verify visible files
370
+
-Ask the assistant to inspect the configured sandbox, or inspect the sandbox directory directly
Copy file name to clipboardExpand all lines: src/index.ts
+49-5Lines changed: 49 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ function addToolsToServer(options: {
41
41
42
42
server.tool(
43
43
'document_processor',
44
-
`Processes documents using Nutrient DWS Processor API. Reads from and writes to file system or sandbox (if enabled).
44
+
`Nutrient document processing tool backed by the Nutrient DWS Processor API. Reads input files from the local file system or sandbox (if enabled) and writes results back locally.
`Digitally signs PDF files using Nutrient DWS Sign API. Reads from and writes to file system or sandbox (if enabled).
74
+
`Nutrient PDF signing tool backed by the Nutrient DWS Sign API. Reads input files from the local file system or sandbox (if enabled) and writes signed output back locally.
`AI-powered document redaction using Nutrient DWS AI Redaction API. Reads from and writes to file system or sandbox (if enabled).
115
+
`Nutrient AI redaction tool backed by the Nutrient DWS AI Redaction API. Reads input files from the local file system or sandbox (if enabled) and writes redacted output back locally.
102
116
103
117
Automatically detects and permanently removes sensitive information from documents using AI analysis.
By default (when neither stage nor apply is set), redactions are detected and immediately applied. Set stage to true to detect and stage redactions without applying them. Set apply to true to apply previously staged redactions.`,
@@ -123,8 +144,17 @@ By default (when neither stage nor apply is set), redactions are detected and im
123
144
'check_credits',
124
145
`Check your Nutrient DWS API credit balance and usage for the current billing period.
125
146
147
+
This is a read-only account lookup. It does not upload any document content.
148
+
126
149
Returns: subscription type, total credits, used credits, and remaining credits.`,
127
150
CheckCreditsArgsSchema.shape,
151
+
{
152
+
title: 'Nutrient Credit Balance',
153
+
readOnlyHint: true,
154
+
destructiveHint: false,
155
+
idempotentHint: true,
156
+
openWorldHint: true,
157
+
},
128
158
async()=>{
129
159
try{
130
160
returnawaitperformCheckCreditsCall(apiClient)
@@ -137,15 +167,29 @@ Returns: subscription type, total credits, used credits, and remaining credits.`
137
167
if(sandboxEnabled){
138
168
server.tool(
139
169
'sandbox_file_tree',
140
-
'Returns the file tree of the sandbox directory. It will recurse into subdirectories and return a list of files and directories.',
170
+
'Browse files already available in the configured sandbox directory. This is a read-only local filesystem operation and does not upload documents to Nutrient.',
141
171
{},
172
+
{
173
+
title: 'Nutrient Sandbox Files',
174
+
readOnlyHint: true,
175
+
destructiveHint: false,
176
+
idempotentHint: true,
177
+
openWorldHint: false,
178
+
},
142
179
async()=>performDirectoryTreeCall('.'),
143
180
)
144
181
}else{
145
182
server.tool(
146
183
'directory_tree',
147
-
'Returns the directory tree of a given path. All paths are resolved relative to root directory.',
184
+
'Browse local files when sandbox mode is disabled. This is a read-only local filesystem operation, but it can inspect any path visible to the current user. Sandbox mode is strongly recommended.',
0 commit comments