Skip to content

Commit 183eca5

Browse files
committed
feat: Prepare for npm publishing
- Add bin/mcp-memory-keeper CLI wrapper for npx execution - Update package.json with bin entry and npm metadata - Add .npmignore to control published files - Update README with simple npx installation instructions - Add prepublishOnly script to ensure build before publish Now users can simply run: claude mcp add memory-keeper npx mcp-memory-keeper This provides the best user experience, matching other MCP servers.
1 parent f35e396 commit 183eca5

File tree

5 files changed

+143
-21
lines changed

5 files changed

+143
-21
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ coverage/
88
.DS_Store
99
.env
1010
*.log
11-
memory-keeper-export-*.json
11+
memory-keeper-export-*.json
12+
.build-marker-*

.npmignore

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Source files
2+
src/
3+
*.ts
4+
!dist/**/*.d.ts
5+
6+
# Development files
7+
.devcontainer/
8+
.github/
9+
.husky/
10+
.vscode/
11+
scripts/
12+
examples/
13+
14+
# Test files
15+
__tests__/
16+
test/
17+
tests/
18+
*.test.js
19+
*.test.ts
20+
jest.config.js
21+
coverage/
22+
23+
# Build files
24+
tsconfig.json
25+
eslint.config.js
26+
.prettierrc.json
27+
.prettierignore
28+
.lintstagedrc.json
29+
30+
# Git files
31+
.git/
32+
.gitignore
33+
34+
# Docs (except main ones)
35+
*.md
36+
!README.md
37+
!LICENSE
38+
!CHANGELOG.md
39+
40+
# Misc
41+
.DS_Store
42+
*.log
43+
.env
44+
.env.*
45+
node_modules/
46+
*.db
47+
*.db-*
48+
.build-marker-*
49+
50+
# Installation scripts (not needed with npm)
51+
install.sh
52+
launcher.sh

README.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,35 +39,31 @@ Claude Code users often face context loss when the conversation window fills up.
3939

4040
## Installation
4141

42-
### Method 1: Self-Contained Launcher (Easiest)
42+
### Method 1: NPX (Recommended)
4343

44-
The launcher script handles everything automatically - installation, updates, and native module rebuilds:
44+
The simplest way to use memory-keeper with Claude:
4545

4646
```bash
47-
# Quick install and add to Claude
48-
curl -fsSL https://raw.githubusercontent.com/mkreyman/mcp-memory-keeper/master/install.sh | bash
49-
50-
# Then add to Claude (using the path shown by installer)
51-
claude mcp add memory-keeper "$HOME/.local/mcp-servers/memory-keeper/launcher.sh"
47+
claude mcp add memory-keeper npx mcp-memory-keeper
5248
```
5349

54-
### Method 2: Direct from Repository
50+
That's it! This will:
5551

56-
If you've already cloned the repository:
52+
- Always use the latest version
53+
- Handle all dependencies automatically
54+
- Create the data directory at `~/mcp-data/memory-keeper/`
55+
- Work across different platforms
5756

58-
```bash
59-
# Add using the launcher script
60-
claude mcp add memory-keeper /path/to/mcp-memory-keeper/launcher.sh
61-
```
57+
### Method 2: Global Installation
6258

63-
The launcher automatically:
59+
If you prefer a global installation:
6460

65-
- Installs memory-keeper if needed
66-
- Rebuilds native modules for your platform
67-
- Creates the data directory at `~/mcp-data/memory-keeper/`
68-
- Handles updates (if enabled with `MEMORY_KEEPER_AUTO_UPDATE=1`)
61+
```bash
62+
npm install -g mcp-memory-keeper
63+
claude mcp add memory-keeper mcp-memory-keeper
64+
```
6965

70-
### Method 3: Manual Installation
66+
### Method 3: From Source
7167

7268
```bash
7369
# 1. Clone the repository

bin/mcp-memory-keeper

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* MCP Memory Keeper CLI
5+
* This wrapper ensures the server runs correctly when invoked via npx
6+
*/
7+
8+
const { spawn } = require('child_process');
9+
const path = require('path');
10+
const fs = require('fs');
11+
const os = require('os');
12+
13+
// Determine the data directory
14+
const DATA_DIR = process.env.DATA_DIR || path.join(os.homedir(), 'mcp-data', 'memory-keeper');
15+
16+
// Ensure data directory exists
17+
if (!fs.existsSync(DATA_DIR)) {
18+
fs.mkdirSync(DATA_DIR, { recursive: true });
19+
}
20+
21+
// Set environment variable for the server
22+
process.env.DATA_DIR = DATA_DIR;
23+
24+
// Get the path to the actual server
25+
const serverPath = path.join(__dirname, '..', 'dist', 'index.js');
26+
27+
// Check if the server is built
28+
if (!fs.existsSync(serverPath)) {
29+
console.error('Error: Server not built. This should not happen with the npm package.');
30+
console.error('Please report this issue at: https://github.com/mkreyman/mcp-memory-keeper/issues');
31+
process.exit(1);
32+
}
33+
34+
// Change to data directory (where context.db will be created)
35+
process.chdir(DATA_DIR);
36+
37+
// Spawn the server
38+
const child = spawn(process.execPath, [serverPath, ...process.argv.slice(2)], {
39+
stdio: 'inherit',
40+
env: process.env
41+
});
42+
43+
// Handle exit
44+
child.on('exit', (code) => {
45+
process.exit(code);
46+
});
47+
48+
// Handle errors
49+
child.on('error', (err) => {
50+
console.error('Failed to start memory-keeper server:', err);
51+
process.exit(1);
52+
});

package.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"version": "0.10.0",
44
"description": "MCP server for persistent context management in AI coding assistants",
55
"main": "dist/index.js",
6+
"bin": {
7+
"mcp-memory-keeper": "./bin/mcp-memory-keeper"
8+
},
69
"scripts": {
710
"build": "tsc",
811
"dev": "tsx src/index.ts",
@@ -19,7 +22,8 @@
1922
"check-all": "npm run build && npm run type-check && npm run lint && npm run format:check && npm test",
2023
"pre-commit": "npm run build && npm run type-check && npm run lint && npm run format:check && npm test",
2124
"check-migrations": "tsx scripts/check-migrations.ts",
22-
"prepare": "husky"
25+
"prepare": "husky",
26+
"prepublishOnly": "npm run build && npm run test"
2327
},
2428
"keywords": [
2529
"mcp",
@@ -34,6 +38,23 @@
3438
"type": "git",
3539
"url": "https://github.com/mkreyman/mcp-memory-keeper"
3640
},
41+
"homepage": "https://github.com/mkreyman/mcp-memory-keeper#readme",
42+
"bugs": {
43+
"url": "https://github.com/mkreyman/mcp-memory-keeper/issues"
44+
},
45+
"files": [
46+
"dist/**/*",
47+
"bin/**/*",
48+
"README.md",
49+
"LICENSE",
50+
"CHANGELOG.md"
51+
],
52+
"engines": {
53+
"node": ">=18.0.0"
54+
},
55+
"publishConfig": {
56+
"access": "public"
57+
},
3758
"dependencies": {
3859
"@modelcontextprotocol/sdk": "^1.12.3",
3960
"better-sqlite3": "^11.10.0",

0 commit comments

Comments
 (0)