@paradyno/pdf-mcp-server 0.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.
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const os = require('os');
6
+
7
+ function getBinaryName() {
8
+ const platform = os.platform();
9
+ const arch = os.arch();
10
+
11
+ const platformMap = {
12
+ darwin: 'darwin',
13
+ linux: 'linux',
14
+ win32: 'windows',
15
+ };
16
+
17
+ const archMap = {
18
+ x64: 'x64',
19
+ arm64: 'arm64',
20
+ };
21
+
22
+ const platformName = platformMap[platform];
23
+ const archName = archMap[arch];
24
+
25
+ if (!platformName || !archName) {
26
+ console.warn(`⚠️ Unsupported platform: ${platform} ${arch}`);
27
+ console.warn(' You may need to build from source or download manually.');
28
+ return null;
29
+ }
30
+
31
+ const ext = platform === 'win32' ? '.exe' : '';
32
+ return `pdf-mcp-server-${platformName}-${archName}${ext}`;
33
+ }
34
+
35
+ function extractBinary() {
36
+ const binaryName = getBinaryName();
37
+ if (!binaryName) return;
38
+
39
+ const binariesDir = path.join(__dirname, '..', 'binaries');
40
+ const archiveDir = path.join(binariesDir, binaryName.replace(/\.exe$/, ''));
41
+
42
+ // Check for tar.gz or zip archive
43
+ const tarPath = path.join(archiveDir, `${binaryName}.tar.gz`);
44
+ const zipPath = path.join(archiveDir, `${binaryName}.zip`);
45
+
46
+ if (fs.existsSync(tarPath)) {
47
+ const { execSync } = require('child_process');
48
+ execSync(`tar -xzf "${tarPath}" -C "${binariesDir}"`, { stdio: 'inherit' });
49
+ console.log(`✅ Extracted ${binaryName}`);
50
+ } else if (fs.existsSync(zipPath)) {
51
+ const { execSync } = require('child_process');
52
+ execSync(`unzip -o "${zipPath}" -d "${binariesDir}"`, { stdio: 'inherit' });
53
+ console.log(`✅ Extracted ${binaryName}`);
54
+ } else {
55
+ // Binary might already be extracted or doesn't need extraction
56
+ const binaryPath = path.join(binariesDir, binaryName);
57
+ if (fs.existsSync(binaryPath)) {
58
+ console.log(`✅ Binary found: ${binaryName}`);
59
+ // Ensure executable on Unix
60
+ if (os.platform() !== 'win32') {
61
+ fs.chmodSync(binaryPath, 0o755);
62
+ }
63
+ } else {
64
+ console.warn(`⚠️ Binary not found: ${binaryName}`);
65
+ console.warn(' Please download from: https://github.com/paradyno/pdf-mcp-server/releases');
66
+ }
67
+ }
68
+ }
69
+
70
+ // Run extraction
71
+ extractBinary();
72
+
73
+ console.log('');
74
+ console.log('PDF MCP Server installed successfully!');
75
+ console.log('');
76
+ console.log('To use with Claude Desktop, add to your config:');
77
+ console.log('');
78
+ console.log(' {');
79
+ console.log(' "mcpServers": {');
80
+ console.log(' "pdf": {');
81
+ console.log(' "command": "npx",');
82
+ console.log(' "args": ["@paradyno/pdf-mcp-server"]');
83
+ console.log(' }');
84
+ console.log(' }');
85
+ console.log(' }');
86
+ console.log('');
package/bin/run.js ADDED
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const os = require('os');
6
+ const fs = require('fs');
7
+
8
+ function getBinaryName() {
9
+ const platform = os.platform();
10
+ const arch = os.arch();
11
+
12
+ const platformMap = {
13
+ darwin: 'darwin',
14
+ linux: 'linux',
15
+ win32: 'windows',
16
+ };
17
+
18
+ const archMap = {
19
+ x64: 'x64',
20
+ arm64: 'arm64',
21
+ };
22
+
23
+ const platformName = platformMap[platform];
24
+ const archName = archMap[arch];
25
+
26
+ if (!platformName || !archName) {
27
+ console.error(`Unsupported platform: ${platform} ${arch}`);
28
+ process.exit(1);
29
+ }
30
+
31
+ const ext = platform === 'win32' ? '.exe' : '';
32
+ return `pdf-mcp-server-${platformName}-${archName}${ext}`;
33
+ }
34
+
35
+ function findBinary() {
36
+ const binaryName = getBinaryName();
37
+
38
+ // Check in binaries directory (installed via npm)
39
+ const binariesDir = path.join(__dirname, '..', 'binaries');
40
+ const binaryPath = path.join(binariesDir, binaryName);
41
+
42
+ if (fs.existsSync(binaryPath)) {
43
+ return binaryPath;
44
+ }
45
+
46
+ // Check if binary is in PATH
47
+ const pathDirs = (process.env.PATH || '').split(path.delimiter);
48
+ for (const dir of pathDirs) {
49
+ const fullPath = path.join(dir, binaryName);
50
+ if (fs.existsSync(fullPath)) {
51
+ return fullPath;
52
+ }
53
+ }
54
+
55
+ console.error(`Binary not found: ${binaryName}`);
56
+ console.error('Please ensure the binary is installed correctly.');
57
+ process.exit(1);
58
+ }
59
+
60
+ const binaryPath = findBinary();
61
+
62
+ // Make sure it's executable on Unix
63
+ if (os.platform() !== 'win32') {
64
+ try {
65
+ fs.chmodSync(binaryPath, 0o755);
66
+ } catch (e) {
67
+ // Ignore chmod errors
68
+ }
69
+ }
70
+
71
+ // Spawn the binary with all arguments
72
+ const child = spawn(binaryPath, process.argv.slice(2), {
73
+ stdio: 'inherit',
74
+ env: process.env,
75
+ });
76
+
77
+ child.on('error', (err) => {
78
+ console.error(`Failed to start binary: ${err.message}`);
79
+ process.exit(1);
80
+ });
81
+
82
+ child.on('exit', (code, signal) => {
83
+ if (signal) {
84
+ process.kill(process.pid, signal);
85
+ } else {
86
+ process.exit(code || 0);
87
+ }
88
+ });
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@paradyno/pdf-mcp-server",
3
+ "version": "0.0.1",
4
+ "description": "MCP server for PDF processing - text extraction, search, and outline extraction",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/paradyno/pdf-mcp-server"
9
+ },
10
+ "homepage": "https://github.com/paradyno/pdf-mcp-server",
11
+ "bugs": {
12
+ "url": "https://github.com/paradyno/pdf-mcp-server/issues"
13
+ },
14
+ "keywords": [
15
+ "mcp",
16
+ "pdf",
17
+ "claude",
18
+ "ai",
19
+ "llm",
20
+ "text-extraction",
21
+ "pdf-search"
22
+ ],
23
+ "bin": {
24
+ "pdf-mcp-server": "./bin/run.js"
25
+ },
26
+ "files": [
27
+ "bin",
28
+ "binaries"
29
+ ],
30
+ "scripts": {
31
+ "postinstall": "node bin/postinstall.js"
32
+ },
33
+ "engines": {
34
+ "node": ">=18"
35
+ },
36
+ "os": [
37
+ "darwin",
38
+ "linux",
39
+ "win32"
40
+ ],
41
+ "cpu": [
42
+ "x64",
43
+ "arm64"
44
+ ]
45
+ }