session-collab-mcp 0.5.0 → 0.5.2

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024
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.
package/README.md ADDED
@@ -0,0 +1,254 @@
1
+ # Session Collab MCP
2
+
3
+ [![npm version](https://img.shields.io/npm/v/session-collab-mcp.svg)](https://www.npmjs.com/package/session-collab-mcp)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ A Model Context Protocol (MCP) server for Claude Code that prevents conflicts when multiple sessions work on the same codebase simultaneously.
7
+
8
+ ## Problem
9
+
10
+ When using parallel Claude Code sessions or the parallel-dev workflow:
11
+
12
+ - Session A is refactoring some code
13
+ - Session B doesn't know and thinks the code "has issues" - deletes or reverts it
14
+ - Session A's work disappears
15
+
16
+ **Root cause**: No synchronization mechanism for "work intent" between sessions.
17
+
18
+ ## Solution
19
+
20
+ Session Collab MCP provides a **Work-in-Progress (WIP) Registry** that allows sessions to:
21
+
22
+ 1. **Declare** - Announce which files you're about to modify
23
+ 2. **Check** - Verify no other session is working on the same files
24
+ 3. **Communicate** - Send messages between sessions
25
+ 4. **Release** - Free files when done
26
+
27
+ ## Installation
28
+
29
+ ### Zero-Config Setup
30
+
31
+ Add to your `~/.claude.json`:
32
+
33
+ ```json
34
+ {
35
+ "mcpServers": {
36
+ "session-collab": {
37
+ "command": "npx",
38
+ "args": ["-y", "session-collab-mcp@latest"]
39
+ }
40
+ }
41
+ }
42
+ ```
43
+
44
+ That's it! The MCP server includes built-in instructions that Claude follows automatically.
45
+
46
+ ### Manual Installation
47
+
48
+ ```bash
49
+ npm install -g session-collab-mcp
50
+ ```
51
+
52
+ ## Features
53
+
54
+ ### Automatic Session Management
55
+
56
+ Once installed, Claude will:
57
+
58
+ 1. Register a session when conversation starts
59
+ 2. Check for conflicts before editing files
60
+ 3. Warn you if another session is working on the same files
61
+ 4. Clean up when the conversation ends
62
+
63
+ ### Symbol-Level Claims
64
+
65
+ Fine-grained conflict detection at the function/class level:
66
+
67
+ ```
68
+ Session A claims: validateToken() in auth.ts
69
+ Session B wants: refreshToken() in auth.ts
70
+ Result: No conflict! Different symbols in same file.
71
+ ```
72
+
73
+ ### LSP Integration
74
+
75
+ Works with Claude Code's LSP tools for:
76
+
77
+ - Accurate symbol validation (no typos in claims)
78
+ - Impact analysis (know which files reference your changes)
79
+ - Smart prioritization (focus on low-impact changes first)
80
+
81
+ ### Conflict Handling Modes
82
+
83
+ Configure behavior with `collab_config`:
84
+
85
+ | Mode | Behavior |
86
+ |------|----------|
87
+ | `strict` | Always ask user, never bypass |
88
+ | `smart` (default) | Auto-proceed with safe content, ask for blocked |
89
+ | `bypass` | Proceed despite conflicts (warn only) |
90
+
91
+ ## MCP Tools Reference
92
+
93
+ ### Session Management
94
+
95
+ | Tool | Purpose |
96
+ |------|---------|
97
+ | `collab_session_start` | Register a new session |
98
+ | `collab_session_end` | End session and release all claims |
99
+ | `collab_session_list` | List active sessions |
100
+ | `collab_session_heartbeat` | Update session heartbeat |
101
+ | `collab_status_update` | Share current work status |
102
+ | `collab_config` | Configure conflict handling mode |
103
+
104
+ ### Claims (File/Symbol Locking)
105
+
106
+ | Tool | Purpose |
107
+ |------|---------|
108
+ | `collab_claim` | Reserve files or symbols before modifying |
109
+ | `collab_check` | Check if files/symbols are claimed by others |
110
+ | `collab_release` | Release claimed files/symbols |
111
+ | `collab_claims_list` | List all WIP claims |
112
+
113
+ ### Inter-Session Communication
114
+
115
+ | Tool | Purpose |
116
+ |------|---------|
117
+ | `collab_message_send` | Send message to other sessions |
118
+ | `collab_message_list` | Read messages |
119
+
120
+ ### Architectural Decisions
121
+
122
+ | Tool | Purpose |
123
+ |------|---------|
124
+ | `collab_decision_add` | Record design decisions |
125
+ | `collab_decision_list` | View recorded decisions |
126
+
127
+ ### LSP Integration (Advanced)
128
+
129
+ | Tool | Purpose |
130
+ |------|---------|
131
+ | `collab_analyze_symbols` | Analyze LSP symbols for conflict detection |
132
+ | `collab_validate_symbols` | Validate symbol names before claiming |
133
+ | `collab_store_references` | Store LSP reference data for impact tracking |
134
+ | `collab_impact_analysis` | Analyze impact of modifying a symbol |
135
+
136
+ ## Usage Examples
137
+
138
+ ### Basic Workflow
139
+
140
+ ```
141
+ # Session A starts working
142
+ collab_session_start(project_root="/my/project", name="feature-auth")
143
+ collab_claim(files=["src/auth.ts"], intent="Adding JWT support")
144
+
145
+ # Session B checks before editing
146
+ collab_check(files=["src/auth.ts"])
147
+ # Result: "src/auth.ts is being worked on by 'feature-auth' - Adding JWT support"
148
+
149
+ # Session A finishes
150
+ collab_release(claim_id="...", status="completed", summary="Added JWT validation")
151
+ ```
152
+
153
+ ### Symbol-Level Claims
154
+
155
+ ```
156
+ # Claim specific functions only
157
+ collab_claim(
158
+ symbols=[{file: "src/auth.ts", symbols: ["validateToken", "refreshToken"]}],
159
+ intent="Refactoring token validation"
160
+ )
161
+
162
+ # Other sessions can still work on other functions in the same file
163
+ ```
164
+
165
+ ### Impact Analysis
166
+
167
+ ```
168
+ # Before modifying a widely-used function
169
+ collab_impact_analysis(file="src/utils.ts", symbol="formatDate")
170
+ # Result: {
171
+ # risk_level: "high",
172
+ # reference_count: 15,
173
+ # affected_files: ["src/api/...", "src/components/..."],
174
+ # message: "HIGH RISK: This symbol is referenced in 15 locations"
175
+ # }
176
+ ```
177
+
178
+ ## Data Storage
179
+
180
+ All data is stored locally in `~/.claude/session-collab/collab.db` (SQLite).
181
+
182
+ - No remote server required
183
+ - No API token needed
184
+ - Works offline
185
+ - Uses WAL mode for multi-process safety
186
+
187
+ ## Development
188
+
189
+ ### Prerequisites
190
+
191
+ - Node.js 18+
192
+ - npm or yarn
193
+
194
+ ### Setup
195
+
196
+ ```bash
197
+ npm install
198
+ npm run build
199
+ ```
200
+
201
+ ### Scripts
202
+
203
+ ```bash
204
+ npm run build # Build with tsup
205
+ npm run start # Start the MCP server
206
+ npm run start:dev # Start in development mode
207
+ npm run typecheck # Run TypeScript type checking
208
+ npm run lint # Run ESLint
209
+ npm run test # Run tests with Vitest
210
+ ```
211
+
212
+ ### Project Structure
213
+
214
+ ```
215
+ session-collab-mcp/
216
+ ├── bin/ # Executable entry point
217
+ ├── migrations/ # SQLite migration files
218
+ │ ├── 0001_init.sql # Core tables
219
+ │ ├── 0002_auth.sql # Auth tables
220
+ │ ├── 0002_session_status.sql # Session status
221
+ │ ├── 0003_config.sql # Session config
222
+ │ ├── 0004_symbols.sql # Symbol-level claims
223
+ │ └── 0005_references.sql # Reference tracking
224
+ ├── src/
225
+ │ ├── cli.ts # CLI entry point
226
+ │ ├── constants.ts # Version and constants
227
+ │ ├── db/ # Database layer
228
+ │ │ ├── queries.ts # SQL queries
229
+ │ │ └── sqlite-adapter.ts
230
+ │ ├── mcp/ # MCP protocol implementation
231
+ │ │ ├── protocol.ts # JSON-RPC handling
232
+ │ │ ├── server.ts # Main MCP server
233
+ │ │ └── tools/ # Tool implementations
234
+ │ │ ├── session.ts # Session management
235
+ │ │ ├── claim.ts # File/symbol claims
236
+ │ │ ├── message.ts # Inter-session messaging
237
+ │ │ ├── decision.ts# Decision logging
238
+ │ │ └── lsp.ts # LSP integration
239
+ │ └── utils/
240
+ └── package.json
241
+ ```
242
+
243
+ ## Changelog
244
+
245
+ ### v0.5.0
246
+
247
+ - Add reference tracking and impact analysis (Phase 3)
248
+ - Add symbol-level claims and LSP integration
249
+ - Fix SQLite WAL sync for multi-process MCP servers
250
+ - Add `collab_config` tool for conflict handling modes
251
+
252
+ ## License
253
+
254
+ MIT
@@ -0,0 +1,14 @@
1
+ -- Add composite indexes for common query patterns
2
+ -- These indexes optimize queries that filter on multiple columns
3
+
4
+ -- Sessions: frequently query active sessions with heartbeat check
5
+ -- Used in cleanupStaleSessions and session list queries
6
+ CREATE INDEX IF NOT EXISTS idx_sessions_status_heartbeat ON sessions(status, last_heartbeat);
7
+
8
+ -- Claims: frequently query active claims for a session
9
+ -- Used in checkConflicts and listClaims
10
+ CREATE INDEX IF NOT EXISTS idx_claims_status_session ON claims(status, session_id);
11
+
12
+ -- Claim files: composite for efficient conflict checking
13
+ -- Used in checkConflicts with JOIN on claims
14
+ CREATE INDEX IF NOT EXISTS idx_claim_files_path_claim ON claim_files(file_path, claim_id);
package/package.json CHANGED
@@ -1,7 +1,16 @@
1
1
  {
2
2
  "name": "session-collab-mcp",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "MCP server for Claude Code session collaboration - prevents conflicts between parallel sessions",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "mcp",
8
+ "claude",
9
+ "claude-code",
10
+ "collaboration",
11
+ "session",
12
+ "conflict-prevention"
13
+ ],
5
14
  "type": "module",
6
15
  "bin": {
7
16
  "session-collab-mcp": "./bin/session-collab-mcp"
package/src/cli.ts CHANGED
@@ -21,6 +21,7 @@ function loadMigrations(): string[] {
21
21
  readFileSync(join(migrationsDir, '0003_config.sql'), 'utf-8'),
22
22
  readFileSync(join(migrationsDir, '0004_symbols.sql'), 'utf-8'),
23
23
  readFileSync(join(migrationsDir, '0005_references.sql'), 'utf-8'),
24
+ readFileSync(join(migrationsDir, '0006_composite_indexes.sql'), 'utf-8'),
24
25
  ];
25
26
  }
26
27