scrivener-mcp 0.1.4 → 0.2.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/README.md CHANGED
@@ -2,6 +2,43 @@
2
2
 
3
3
  A Model Context Protocol (MCP) server for Scrivener integration that allows Claude to manipulate Scrivener projects, including file and folder operations, metadata management, and content analysis.
4
4
 
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g scrivener-mcp
9
+ ```
10
+
11
+ The installation will **automatically configure Claude Desktop** for you! Just restart Claude Desktop after installation.
12
+
13
+ ### Manual Configuration (if needed)
14
+
15
+ If automatic setup didn't work, you can manually configure:
16
+
17
+ ```bash
18
+ # Run the setup script
19
+ npx scrivener-mcp setup
20
+
21
+ # Or manually add to claude_desktop_config.json:
22
+ ```
23
+
24
+ ```json
25
+ {
26
+ "mcpServers": {
27
+ "scrivener": {
28
+ "command": "npx",
29
+ "args": ["scrivener-mcp"]
30
+ }
31
+ }
32
+ }
33
+ ```
34
+
35
+ ### Uninstalling
36
+
37
+ ```bash
38
+ # Remove the package and configuration
39
+ npm uninstall -g scrivener-mcp
40
+ ```
41
+
5
42
  ## Features
6
43
 
7
44
  ### Core Scrivener Operations
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "scrivener-mcp",
3
- "version": "0.1.4",
4
- "description": "Model Context Protocol server for Scrivener project manipulation and analysis",
3
+ "version": "0.2.0",
4
+ "description": "MCP server for Scrivener - Read, analyze, and manipulate Scrivener writing projects. Features RTF parsing, document structure analysis, word counting, and AI-powered writing assistance for authors using Claude or other LLMs.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",
@@ -10,6 +10,7 @@
10
10
  },
11
11
  "files": [
12
12
  "dist",
13
+ "scripts",
13
14
  "README.md",
14
15
  "LICENSE"
15
16
  ],
@@ -33,7 +34,10 @@
33
34
  "format:check": "prettier --check 'src/**/*.ts'",
34
35
  "typecheck": "tsc --noEmit",
35
36
  "prepublishOnly": "npm run clean && npm run build && npm run test",
36
- "prepare": "npm run build"
37
+ "prepare": "npm run build",
38
+ "postinstall": "node scripts/setup.js || true",
39
+ "setup": "node scripts/setup.js",
40
+ "uninstall": "node scripts/uninstall.js"
37
41
  },
38
42
  "dependencies": {
39
43
  "@modelcontextprotocol/sdk": "^1.0.0",
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
4
+ import { homedir } from 'os';
5
+ import { join } from 'path';
6
+
7
+ console.log('\nšŸš€ Setting up Scrivener MCP for Claude Desktop...\n');
8
+
9
+ // Possible config locations
10
+ const configPaths = [
11
+ join(homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json'),
12
+ join(homedir(), '.config', 'claude', 'claude_desktop_config.json'),
13
+ join(homedir(), 'AppData', 'Roaming', 'Claude', 'claude_desktop_config.json')
14
+ ];
15
+
16
+ // Find existing config
17
+ let configPath = configPaths.find(p => existsSync(p));
18
+
19
+ if (!configPath) {
20
+ // Try to create config in the most likely location based on platform
21
+ const platform = process.platform;
22
+ if (platform === 'darwin') {
23
+ configPath = configPaths[0];
24
+ } else if (platform === 'win32') {
25
+ configPath = configPaths[2];
26
+ } else {
27
+ configPath = configPaths[1];
28
+ }
29
+
30
+ // Create directory if it doesn't exist
31
+ const dir = join(configPath, '..');
32
+ if (!existsSync(dir)) {
33
+ console.log(`šŸ“ Creating config directory: ${dir}`);
34
+ mkdirSync(dir, { recursive: true });
35
+ }
36
+ }
37
+
38
+ // Read or create config
39
+ let config = {};
40
+ if (existsSync(configPath)) {
41
+ console.log(`šŸ“„ Found existing config at: ${configPath}`);
42
+ try {
43
+ config = JSON.parse(readFileSync(configPath, 'utf8'));
44
+ } catch (err) {
45
+ console.error('āš ļø Error reading config file:', err.message);
46
+ console.log('Creating new config...');
47
+ }
48
+ } else {
49
+ console.log(`šŸ“ Creating new config at: ${configPath}`);
50
+ }
51
+
52
+ // Ensure mcpServers exists
53
+ if (!config.mcpServers) {
54
+ config.mcpServers = {};
55
+ }
56
+
57
+ // Check if scrivener is already configured
58
+ if (config.mcpServers.scrivener) {
59
+ console.log('āœ… Scrivener MCP is already configured!');
60
+ console.log('\nCurrent configuration:');
61
+ console.log(JSON.stringify(config.mcpServers.scrivener, null, 2));
62
+
63
+ const readline = await import('readline');
64
+ const rl = readline.createInterface({
65
+ input: process.stdin,
66
+ output: process.stdout
67
+ });
68
+
69
+ const answer = await new Promise((resolve) => {
70
+ rl.question('\nDo you want to update the configuration? (y/N): ', resolve);
71
+ });
72
+ rl.close();
73
+
74
+ if (answer.toLowerCase() !== 'y') {
75
+ console.log('\n✨ Setup complete! Restart Claude Desktop to use Scrivener MCP.\n');
76
+ process.exit(0);
77
+ }
78
+ }
79
+
80
+ // Add scrivener configuration
81
+ config.mcpServers.scrivener = {
82
+ command: 'npx',
83
+ args: ['scrivener-mcp']
84
+ };
85
+
86
+ // Write config
87
+ try {
88
+ writeFileSync(configPath, JSON.stringify(config, null, 2));
89
+ console.log('\nāœ… Successfully configured Scrivener MCP!');
90
+ console.log(`šŸ“ Configuration saved to: ${configPath}`);
91
+ console.log('\n✨ Setup complete! Please restart Claude Desktop to use Scrivener MCP.\n');
92
+ console.log('šŸ“š You can now ask Claude to:');
93
+ console.log(' - Open your Scrivener projects');
94
+ console.log(' - Read and analyze your manuscripts');
95
+ console.log(' - Help with writing and editing');
96
+ console.log(' - Manage document structure\n');
97
+ } catch (err) {
98
+ console.error('āŒ Error writing config:', err.message);
99
+ console.log('\nšŸ“‹ Please manually add this to your claude_desktop_config.json:');
100
+ console.log(JSON.stringify({ mcpServers: { scrivener: config.mcpServers.scrivener } }, null, 2));
101
+ process.exit(1);
102
+ }
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { existsSync, readFileSync, writeFileSync } from 'fs';
4
+ import { homedir } from 'os';
5
+ import { join } from 'path';
6
+
7
+ console.log('\nšŸ—‘ļø Removing Scrivener MCP from Claude Desktop...\n');
8
+
9
+ // Possible config locations
10
+ const configPaths = [
11
+ join(homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json'),
12
+ join(homedir(), '.config', 'claude', 'claude_desktop_config.json'),
13
+ join(homedir(), 'AppData', 'Roaming', 'Claude', 'claude_desktop_config.json')
14
+ ];
15
+
16
+ // Find existing config
17
+ const configPath = configPaths.find(p => existsSync(p));
18
+
19
+ if (!configPath) {
20
+ console.log('āš ļø No Claude Desktop configuration found.');
21
+ console.log('Scrivener MCP may not have been configured.');
22
+ process.exit(0);
23
+ }
24
+
25
+ try {
26
+ const config = JSON.parse(readFileSync(configPath, 'utf8'));
27
+
28
+ if (!config.mcpServers || !config.mcpServers.scrivener) {
29
+ console.log('ā„¹ļø Scrivener MCP was not configured in Claude Desktop.');
30
+ process.exit(0);
31
+ }
32
+
33
+ // Remove scrivener from mcpServers
34
+ delete config.mcpServers.scrivener;
35
+
36
+ // If mcpServers is now empty, remove it
37
+ if (Object.keys(config.mcpServers).length === 0) {
38
+ delete config.mcpServers;
39
+ }
40
+
41
+ // Write updated config
42
+ writeFileSync(configPath, JSON.stringify(config, null, 2));
43
+
44
+ console.log('āœ… Successfully removed Scrivener MCP from Claude Desktop configuration.');
45
+ console.log('šŸ“ Configuration updated at:', configPath);
46
+ console.log('\n✨ Please restart Claude Desktop to apply changes.\n');
47
+ } catch (err) {
48
+ console.error('āŒ Error updating config:', err.message);
49
+ process.exit(1);
50
+ }