@fenfill/mcp 0.0.1 → 0.1.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/LICENSE +26 -0
- package/README.md +265 -4
- package/THIRD_PARTY_NOTICES +1172 -0
- package/dist/fonts/DejaVuSans.ttf +0 -0
- package/dist/fonts/Inter-Regular.ttf +0 -0
- package/dist/index.js +141123 -0
- package/dist/pdfium.wasm +0 -0
- package/licenses/DejaVu-LICENSE.txt +187 -0
- package/licenses/Inter-OFL.txt +92 -0
- package/licenses/PDFium-LICENSE.txt +196 -0
- package/licenses/PDFium-third-party.txt +591 -0
- package/package.json +52 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Stanisław Ursatjew
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
The bundled third-party software keeps its own licenses: see
|
|
26
|
+
THIRD_PARTY_NOTICES and the licenses/ folder.
|
package/README.md
CHANGED
|
@@ -1,9 +1,270 @@
|
|
|
1
|
-
# @fenfill/mcp
|
|
1
|
+
# @fenfill/mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An [MCP](https://modelcontextprotocol.io) server that lets an AI agent turn a blank PDF form into a
|
|
4
|
+
filled one with [fenfill](https://fenfill.com).
|
|
4
5
|
|
|
6
|
+
**Fills happen on your machine; only blank forms and templates go to fenfill.** The agent's answers
|
|
7
|
+
are stamped into the PDF locally and are never sent to fenfill or anywhere else.
|
|
8
|
+
|
|
9
|
+
## How it works
|
|
10
|
+
|
|
11
|
+
1. **`analyze_form`** uploads the **blank** PDF to fenfill once. fenfill finds the fillable
|
|
12
|
+
fields (text boxes, checkboxes, dates, character boxes, tables, signatures) and returns them
|
|
13
|
+
with ids, types and labels. The result is cached on your machine, so asking again is free.
|
|
14
|
+
2. **`fill_form`** takes the agent's answers (`field id → value`), checks them against the
|
|
15
|
+
fields, and stamps them into a new, flattened PDF. This step runs entirely on your machine,
|
|
16
|
+
with no network at all.
|
|
17
|
+
3. Saved fenfill templates work the same way: `list_templates` → `get_template` → `fill_template`.
|
|
18
|
+
4. **`preview_page`** shows a page as an image with every field box outlined and tagged, rendered
|
|
19
|
+
on your machine. If a box is misplaced, missing or mislabeled, **`edit_template`** fixes it in a
|
|
20
|
+
local working copy that filling uses at once, and **`save_template`** keeps the fix in a saved
|
|
21
|
+
template.
|
|
22
|
+
|
|
23
|
+
### What is sent where
|
|
24
|
+
|
|
25
|
+
| Data | Sent to fenfill? |
|
|
26
|
+
| -------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
27
|
+
| The blank PDF you analyze | Yes, once (then cached locally) |
|
|
28
|
+
| Your API key | Yes, as `Authorization: Bearer` |
|
|
29
|
+
| The agent's answers, signatures and the filled PDF | **No, never** |
|
|
30
|
+
| Saved templates (blank PDF, fields, your logo) | Downloaded from fenfill to fill locally |
|
|
31
|
+
| Page previews (`preview_page`) | **No**: rendered on your machine |
|
|
32
|
+
| Layout corrections (`edit_template`) | Only on `save_template`, and then only the layout and the form's own wording |
|
|
33
|
+
|
|
34
|
+
`analyze_form` refuses PDFs whose form fields already hold answers, and PDFs this server wrote
|
|
35
|
+
itself, so a filled-in form isn't uploaded by mistake.
|
|
36
|
+
|
|
37
|
+
On fenfill's side, uploads are encrypted on arrival. Unless you save the form as a template, the
|
|
38
|
+
blank PDF is deleted when the analysis finishes. The analysis result is kept for at most 24 hours
|
|
39
|
+
after it completes, or 1 hour after it is first fetched, whichever comes first.
|
|
40
|
+
|
|
41
|
+
## Requirements
|
|
42
|
+
|
|
43
|
+
- Node.js 22 or newer (`npx` comes with it).
|
|
44
|
+
- A fenfill API key (`ff_live_…`): fenfill → Settings → API keys. The API is available on paid
|
|
45
|
+
plans (Pro and up).
|
|
46
|
+
- Analyzing a form uses one page scan per analyzed page from your plan. Forms that already have
|
|
47
|
+
native PDF form fields are read directly, with no AI, and use none. Repeat analyses of the same
|
|
48
|
+
file come from the local cache. Filling never uses scans. `get_account` shows what's left.
|
|
49
|
+
|
|
50
|
+
## Setup
|
|
51
|
+
|
|
52
|
+
### Claude Code
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
claude mcp add fenfill --scope user -e FENFILL_API_KEY=ff_live_… -- npx -y @fenfill/mcp
|
|
5
56
|
```
|
|
6
|
-
|
|
57
|
+
|
|
58
|
+
### Claude Desktop
|
|
59
|
+
|
|
60
|
+
Edit `claude_desktop_config.json` (macOS:
|
|
61
|
+
`~/Library/Application Support/Claude/claude_desktop_config.json`, Windows:
|
|
62
|
+
`%APPDATA%\Claude\claude_desktop_config.json`), then restart Claude Desktop:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"mcpServers": {
|
|
67
|
+
"fenfill": {
|
|
68
|
+
"command": "npx",
|
|
69
|
+
"args": ["-y", "@fenfill/mcp"],
|
|
70
|
+
"env": { "FENFILL_API_KEY": "ff_live_…" }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
7
74
|
```
|
|
8
75
|
|
|
9
|
-
|
|
76
|
+
### Cursor
|
|
77
|
+
|
|
78
|
+
Add the same `mcpServers` block to `~/.cursor/mcp.json` (all projects) or `.cursor/mcp.json` (one
|
|
79
|
+
project).
|
|
80
|
+
|
|
81
|
+
### Other MCP clients
|
|
82
|
+
|
|
83
|
+
Any client that can launch a stdio server works: run `npx -y @fenfill/mcp` with
|
|
84
|
+
`FENFILL_API_KEY` in its environment. The installed command is `fenfill-mcp`.
|
|
85
|
+
|
|
86
|
+
On native Windows, if the client can't find `npx`, use `"command": "cmd"` with
|
|
87
|
+
`"args": ["/c", "npx", "-y", "@fenfill/mcp"]`.
|
|
88
|
+
|
|
89
|
+
## Tools
|
|
90
|
+
|
|
91
|
+
| Tool | What it does |
|
|
92
|
+
| ----------------------- | ------------------------------------------------------------------------------- |
|
|
93
|
+
| `analyze_form` | Uploads a **blank** PDF once and returns its fields. Cached locally afterwards. |
|
|
94
|
+
| `fill_form` | Fills an analyzed PDF locally, offline, and writes a new flattened PDF. |
|
|
95
|
+
| `fill_template` | Fills a saved fenfill template locally. |
|
|
96
|
+
| `list_templates` | Lists the workspace's saved templates, newest first. |
|
|
97
|
+
| `get_template` | Shows a template's fields (use `pages` to narrow a large form). |
|
|
98
|
+
| `create_recipient_link` | Creates a personal fill link for one recipient of a restricted template. |
|
|
99
|
+
| `get_recipient_status` | Shows those links' status: `pending`, `opened` or `completed`. |
|
|
100
|
+
| `get_account` | Shows the plan, page scans left and limits. |
|
|
101
|
+
| `preview_page` | Renders one page (PNG) with every field box outlined and tagged, locally. |
|
|
102
|
+
| `edit_template` | Moves, resizes, relabels, retypes, adds, deletes or regroups fields, locally. |
|
|
103
|
+
| `save_template` | Saves `edit_template`'s working copy to a saved template. |
|
|
104
|
+
|
|
105
|
+
`analyze_form` options: `pages` (e.g. `"1-3,5"`; long PDFs can be analyzed in chunks, and
|
|
106
|
+
`fill_form` merges them), `save_as_template` (also keep it as a fenfill template), `access`
|
|
107
|
+
(with `save_as_template`: `"public"`, the default, or `"restricted"`, which recipient links
|
|
108
|
+
need), `estimate` (price the request first: counts the pages and spots native form fields on
|
|
109
|
+
your machine, uploads nothing, and returns `page_count`, `likely_mode`, `estimated_scans` and
|
|
110
|
+
`scans_remaining`), `detect_extra_blanks` (for PDFs with native form fields: also find blanks
|
|
111
|
+
that have no native field, such as a signature or date line, at 1 page scan per analyzed page;
|
|
112
|
+
a free analysis answers `extra_blanks_available: true` when that is likely worth it), and `force`
|
|
113
|
+
(analyze again even if cached; uses scans again). If it answers `"running"`, call it again with
|
|
114
|
+
the same arguments. To correct the layout and keep the corrections, analyze with
|
|
115
|
+
`save_as_template: true` (edits on an unsaved analysis can be used for filling and previews but
|
|
116
|
+
can't be saved); a result without a template says so in `save_note`.
|
|
117
|
+
|
|
118
|
+
When fenfill refuses an upload for capacity (`rate_limited`, `too_many_active_jobs`,
|
|
119
|
+
`queue_full`), `analyze_form` waits the server's `retry_after` (plus a little jitter) and
|
|
120
|
+
uploads again by itself, up to about 60 s of waiting per call, then reports the error with
|
|
121
|
+
`waited_s`. These refusals happen before fenfill creates a job, so the retry never pays twice;
|
|
122
|
+
cancelling the call ends the wait. `too_many_active_jobs` counts every running analysis of the
|
|
123
|
+
workspace, free native-field (AcroForm) ones included.
|
|
124
|
+
|
|
125
|
+
`fill_form` and `fill_template` take `values`, `output_path` (a new `.pdf`) and optional
|
|
126
|
+
`overwrite`. They never overwrite the input PDF.
|
|
127
|
+
|
|
128
|
+
### Previews and corrections
|
|
129
|
+
|
|
130
|
+
`preview_page` takes `path` (an analyzed PDF) or `template_id`, a 1-based `page`, optional
|
|
131
|
+
`values` (to see them stamped; the same shapes as `fill_form`, e.g. `table_rows` =
|
|
132
|
+
`[{columnId: value}, …]`, `multiselect` = an array of option ids or labels) and `dpi` (default
|
|
133
|
+
110, max 200). It returns a PNG image plus a legend: each box's tag, id, type, label and `box`.
|
|
134
|
+
It renders the local working copy (`edit_template`) when there is one, otherwise the saved
|
|
135
|
+
template or analyzed version; `edited: true` / `false` in the result says which. The page is rendered on your machine by
|
|
136
|
+
PDFium (WebAssembly, shipped in the package; nothing native is installed), nothing is written to
|
|
137
|
+
disk, and the image goes only to the calling client.
|
|
138
|
+
|
|
139
|
+
`edit_template` takes `path` or `template_id` and up to 200 `ops`: `set_box` (absolute
|
|
140
|
+
`{id, x, y, w, h}` in one step), `move`, `resize`, `relabel`,
|
|
141
|
+
`retype`, `add`, `delete`, `set_format`, `group`, `ungroup`, `set_options`, `set_required`,
|
|
142
|
+
`set_description`, `set_placeholder` (table rows and columns can't be added or removed yet).
|
|
143
|
+
Coordinates are fractions of the page (0–1) with a top-left origin, the same as the legend's
|
|
144
|
+
`box`. Each op is checked against the rules fenfill applies when saving and is rejected with a
|
|
145
|
+
reason if it breaks them; ops apply in order, all-or-nothing each, except that a box only has to
|
|
146
|
+
lie on the page after the whole batch (so `move` then `resize` works even if the moved box
|
|
147
|
+
overhangs the page in between). `discard: true` drops the working copy. Labels, descriptions,
|
|
148
|
+
placeholders, options, date formats and checkbox symbols are the form's wording, never answers:
|
|
149
|
+
an op whose new wording matches an answer given to `fill_form`, `fill_template` or
|
|
150
|
+
`preview_page` in the same session is rejected before the working copy is written (wording that
|
|
151
|
+
contains an answer of 6+ characters, or equals one of 4–5; equal to a shorter one only warns).
|
|
152
|
+
Once a PDF is saved as a template, `fill_form` and `preview_page` on it use only that template's
|
|
153
|
+
working copy; an older copy of its unsaved analysis is dropped.
|
|
154
|
+
|
|
155
|
+
`save_template` sends the working copy of a saved template, together with the version it started
|
|
156
|
+
from: if the template changed in fenfill meanwhile, it answers `template_conflict` and keeps your
|
|
157
|
+
local edits. Before anything is sent, it refuses wording that matches an answer given to
|
|
158
|
+
`fill_form`, `fill_template` or `preview_page` in the same session (that list lives only in
|
|
159
|
+
memory). A working copy edited in an earlier session can't be checked against that session's
|
|
160
|
+
answers: `save_template` then answers `confirm_wording_needed` with the changed ids and
|
|
161
|
+
properties (never their text); review them and call again with `confirm_wording: true`. An
|
|
162
|
+
unsaved analysis can be edited for filling but not saved: to keep corrections,
|
|
163
|
+
analyze with `save_as_template: true` and edit that template.
|
|
164
|
+
|
|
165
|
+
### Value shapes
|
|
166
|
+
|
|
167
|
+
| Field type | Value |
|
|
168
|
+
| ------------------- | --------------------------------------------------------------------------- |
|
|
169
|
+
| `text`, `multiline` | string, stamped exactly as given |
|
|
170
|
+
| `comb` | string, one character per cell |
|
|
171
|
+
| `date` | `"YYYY-MM-DD"`, printed as `YYYY-MM-DD` |
|
|
172
|
+
| `checkbox` | `true` / `false` |
|
|
173
|
+
| `radio` | option id, option label, or the bare option text (`"No"` for `"Smoke? No"`) |
|
|
174
|
+
| `multiselect` | array of those |
|
|
175
|
+
| `table` | `{ "<cellId>": value, … }` |
|
|
176
|
+
| `table_rows` | `[{ "<columnId>": value, … }, …]` |
|
|
177
|
+
| `signature` | `{ "image_path": "/abs/path/signature.png" }` (PNG or JPG) |
|
|
178
|
+
|
|
179
|
+
A date the form asks for in a plain `text` field is not reformatted: write it the way the field's
|
|
180
|
+
label or placeholder asks (for example `10042026` for "mmddyyyy"). A `signature` whose
|
|
181
|
+
`signing_requirement` is `"external"` is signed outside fenfill (on paper, or with an e-signature
|
|
182
|
+
service), so it is left blank.
|
|
183
|
+
|
|
184
|
+
Unknown field ids (with did-you-mean suggestions), invalid options, comb values that don't fit
|
|
185
|
+
and malformed dates are reported back, so the agent can correct itself. Required fields left empty are listed as
|
|
186
|
+
warnings.
|
|
187
|
+
|
|
188
|
+
### Branding
|
|
189
|
+
|
|
190
|
+
`fill_form` output is never branded. `fill_template` applies the same branding as a fill in the
|
|
191
|
+
fenfill web app for that workspace (for example, your logo if you have set one up).
|
|
192
|
+
|
|
193
|
+
## Configuration
|
|
194
|
+
|
|
195
|
+
| Variable | Default | Notes |
|
|
196
|
+
| ------------------------------ | ------------------------- | ------------------------------------------------------ |
|
|
197
|
+
| `FENFILL_API_KEY` | (none) | `ff_live_…` from fenfill → Settings → API keys. |
|
|
198
|
+
| `FENFILL_API_URL` | `https://api.fenfill.com` | https only (http allowed for localhost). |
|
|
199
|
+
| `FENFILL_CACHE_DIR` | the OS cache folder | Holds schemas and blank forms only, never answers. |
|
|
200
|
+
| `FENFILL_ANALYZE_WAIT_SECONDS` | `50` | How long `analyze_form` waits before saying "running". |
|
|
201
|
+
|
|
202
|
+
`fill_form` works without an API key once a form has been analyzed.
|
|
203
|
+
|
|
204
|
+
## Files and privacy
|
|
205
|
+
|
|
206
|
+
- **The cache** (`FENFILL_CACHE_DIR`, by default `~/Library/Caches/fenfill-mcp` on macOS,
|
|
207
|
+
`~/.cache/fenfill-mcp` on Linux, `%LOCALAPPDATA%\fenfill-mcp\Cache` on Windows; private to
|
|
208
|
+
your user) holds form schemas, blank template PDFs, the workspace logo, sha256 hashes of the
|
|
209
|
+
PDFs it produced and `edit_template`'s working copies, **never the answers you fill in**. A
|
|
210
|
+
working copy holds the layout plus the wording the agent wrote with `edit_template`; the echo
|
|
211
|
+
guard refuses wording that repeats an answer seen in the same session before it is written.
|
|
212
|
+
- **Cache cleanup:** at startup and at most once a day it deletes blank PDFs and the logo after
|
|
213
|
+
1 hour, analyses and working copies unused for 90 days, stale job records after 48 hours, and
|
|
214
|
+
output hashes after a year.
|
|
215
|
+
- **Filled PDFs** are written only where you ask, readable by your user only (mode 0600).
|
|
216
|
+
- **`overwrite: true`** replaces the target file with a new one: the old file's permissions and
|
|
217
|
+
ACL are not kept, and other hard links to it keep the old content.
|
|
218
|
+
- **Recipient links** from `create_recipient_link` are working access links to the form: treat
|
|
219
|
+
them as secrets and share them only with that recipient.
|
|
220
|
+
- **Logs** go to stderr and contain tool names, timings and error codes, never field values.
|
|
221
|
+
|
|
222
|
+
## Troubleshooting
|
|
223
|
+
|
|
224
|
+
| Error | What to do |
|
|
225
|
+
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
226
|
+
| `missing_api_key` / `invalid_api_key` | Set `FENFILL_API_KEY` in the client's config and restart the client. |
|
|
227
|
+
| `plan_required` | The workspace needs a paid plan (Pro and up). |
|
|
228
|
+
| `insufficient_scans` | Not enough page scans left; analyze fewer `pages` or check `get_account`. |
|
|
229
|
+
| `prefilled_form` / `filled_output` | Only blank forms can be analyzed; use the original, empty PDF. If it is the blank form (some ship with default text in their fields), use the fenfill web app. |
|
|
230
|
+
| `pdf_password_required` | Remove the open password first; owner-password PDFs work as they are. |
|
|
231
|
+
| `pdf_fill_forbidden` | The PDF's author forbids form filling; fenfill won't fill it. Use a copy that allows filling. |
|
|
232
|
+
| `not_analyzed` | Run `analyze_form` on the same file (and pages) before `fill_form`. |
|
|
233
|
+
| `output_exists` | Pick a new `output_path` or pass `overwrite: true`. |
|
|
234
|
+
| `rate_limited` / `queue_full` | `analyze_form` already waited about a minute (`waited_s`); try again later. |
|
|
235
|
+
| `too_many_active_jobs` | Other analyses in the workspace (free native-field ones too) are still running; try again in a minute, or analyze fewer at once. |
|
|
236
|
+
| `template_conflict` | The template changed in fenfill since your edits began. Your local edits are kept: `edit_template` with `discard: true`, re-apply the ops, save again. |
|
|
237
|
+
| `invalid_schema` | fenfill (or the local check before it) refused the edited layout; `details` lists each item and reason. Fix them with `edit_template`. |
|
|
238
|
+
| `request_too_large` | The edited template is too large to save in one request. |
|
|
239
|
+
| `answer_in_template` | Edited wording matches an answer from this session, so nothing was sent. Put the form's own wording back with `edit_template`. |
|
|
240
|
+
| `confirm_wording_needed` | The working copy has wording edited in an earlier session. Review the ids and properties in `changed`, then `save_template` with `confirm_wording: true`. |
|
|
241
|
+
| `no_local_edits` | `save_template` has nothing to save for that template (edits to an unsaved analysis can't be saved; see above). |
|
|
242
|
+
| `upload_outcome_unknown` | An earlier upload was interrupted. To avoid charging twice, the same file isn't re-uploaded for about 10 minutes; check `get_account` meanwhile. |
|
|
243
|
+
|
|
244
|
+
## API
|
|
245
|
+
|
|
246
|
+
The server wraps fenfill's REST API: reference at
|
|
247
|
+
[api.fenfill.com/v1/docs](https://api.fenfill.com/v1/docs), OpenAPI spec at
|
|
248
|
+
[api.fenfill.com/v1/openapi.json](https://api.fenfill.com/v1/openapi.json). Fill values are never
|
|
249
|
+
sent to any endpoint; the API has no field for them.
|
|
250
|
+
|
|
251
|
+
## Verify this package
|
|
252
|
+
|
|
253
|
+
- Releases are built and published by GitHub Actions from
|
|
254
|
+
[github.com/fenfill/mcp](https://github.com/fenfill/mcp) with
|
|
255
|
+
[npm provenance](https://docs.npmjs.com/generating-provenance-statements): the npm page links
|
|
256
|
+
each version to the exact commit and workflow run that built it.
|
|
257
|
+
- `npm audit signatures` in a project that installs `@fenfill/mcp` checks the registry signature
|
|
258
|
+
and the provenance attestation.
|
|
259
|
+
- The bundle (`dist/index.js`) is not minified, so what runs on your machine can be read.
|
|
260
|
+
`dist/pdfium.wasm` is the unmodified PDFium build from `@embedpdf/pdfium` (see
|
|
261
|
+
`THIRD_PARTY_NOTICES`), loaded only by `preview_page`.
|
|
262
|
+
|
|
263
|
+
## Security
|
|
264
|
+
|
|
265
|
+
Report vulnerabilities to [security@fenfill.com](mailto:security@fenfill.com) (or through GitHub
|
|
266
|
+
private vulnerability reporting on the repository), not in public issues.
|
|
267
|
+
|
|
268
|
+
## License
|
|
269
|
+
|
|
270
|
+
MIT: see `LICENSE`. Bundled third-party software: see `THIRD_PARTY_NOTICES` and `licenses/`.
|