ext-apps/examples/pdf-server/manifest.json
Olivier Chafik 04fed524a9
fix(pdf-server): npx DOMMatrix crash + broken MCPB bundle (#584)
* fix(pdf-server): stub DOMMatrix/ImageData/Path2D for npx without @napi-rs/canvas

pdfjs-dist/legacy/build/pdf.mjs does `new DOMMatrix()` at module scope.
Its own polyfill loads @napi-rs/canvas (an optionalDependency), but npx
frequently misses the platform-native binary (npm/cli#4828), so the
server crashed on `npx @modelcontextprotocol/server-pdf --stdio`:

    ReferenceError: DOMMatrix is not defined
        at pdfjs-dist/legacy/build/pdf.mjs:17078

The server only uses pdfjs for text/metadata/form-field extraction —
never canvas rendering — so no-op stubs suffice and avoid shipping
~130MB of native binaries.

The polyfill is a separate ESM module kept --external in the bun bundle
so it executes before pdfjs's hoisted static import; inlined body code
would run too late.

Broken since 1.3.0 (#506). Thanks to Bryan Thompson for the analysis
and fix shape from the npm-to-mcpb pipeline.

* fix(pdf-server): MCPB bundle missing runtime deps + display_name with spaces

`mcpb pack` zips whatever is on disk; in this monorepo all runtime deps
are hoisted to root node_modules, so the published .mcpb shipped without
pdfjs-dist/ajv/express/etc. and crashed on import in Claude Desktop.

build-mcpb.mjs stages dist/ + manifest into a clean temp dir, runs a
non-workspace `npm install --omit=dev --omit=optional` (the new
DOMMatrix polyfill makes @napi-rs/canvas's ~130MB of native binaries
unnecessary), syncs manifest.version to package.json, then packs.
Result: 12.3MB / 38.8MB unpacked, full MCP handshake + tools/list pass.

Also rename display_name "PDF (By Anthropic)" → "pdf-viewer" — spaces
in display_name break MCP App UI rendering for MCPBs in Claude Desktop.

CI now smoke-tests the extracted bundle starts (`dist/index.js --stdio`
prints "Ready") so a deps-less bundle can't ship again.

* fix(pdf-server): list interact in MCPB manifest tools (was stale since #491)
2026-04-02 04:16:33 +01:00

48 lines
1.5 KiB
JSON

{
"manifest_version": "0.3",
"name": "@modelcontextprotocol/server-pdf",
"display_name": "pdf-viewer",
"version": "1.0.1",
"description": "Read and interact with PDF files using an interactive viewer with search, navigation, and text extraction",
"author": {
"name": "Anthropic",
"url": "https://www.anthropic.com"
},
"homepage": "https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/pdf-server",
"repository": {
"type": "git",
"url": "https://github.com/modelcontextprotocol/ext-apps"
},
"support": "https://github.com/modelcontextprotocol/ext-apps/issues",
"icon": "icon.png",
"server": {
"type": "node",
"entry_point": "dist/index.js",
"mcp_config": {
"command": "node",
"args": ["${__dirname}/dist/index.js", "--stdio"],
"env": {}
}
},
"tools": [
{
"name": "list_pdfs",
"description": "List available PDF files that can be displayed"
},
{
"name": "display_pdf",
"description": "Display an interactive PDF viewer with search and navigation"
},
{
"name": "interact",
"description": "Interact with a PDF viewer: annotate, navigate, search, extract text/screenshots, fill forms"
}
],
"keywords": ["pdf", "documents", "viewer", "reading"],
"license": "MIT",
"compatibility": {
"platforms": ["darwin", "win32", "linux"],
"runtimes": { "node": ">=18.0.0" }
},
"privacy_policies": ["https://www.anthropic.com/privacy"]
}