@chinchillaenterprises/mcp-dev-logger 1.2.0 → 2.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.
package/README.md CHANGED
@@ -5,11 +5,15 @@ A Model Context Protocol (MCP) server for capturing and streaming development se
5
5
  ## Features
6
6
 
7
7
  - **Universal Dev Server Logging**: Works with any development server command
8
+ - **Multi-Process Support**: Run multiple dev servers simultaneously (frontend + backend)
8
9
  - **Real-time Log Streaming**: Capture build errors, TypeScript errors, hot reload events
9
10
  - **Persistent Logs**: All output saved to file for historical debugging
10
- - **Process Management**: Start, stop, and restart dev servers
11
+ - **Smart Process Management**: Start, stop, and restart individual dev servers by ID
11
12
  - **Log Filtering**: Search through logs with grep patterns
12
13
  - **Framework Agnostic**: One tool for all development servers
14
+ - **Auto-Generated Process IDs**: Intelligent process ID generation based on command and output file
15
+ - **Process State Persistence**: Maintains process state across server restarts (where possible)
16
+ - **Signal Handling**: Proper cleanup with SIGTERM for graceful shutdowns
13
17
 
14
18
  ## Installation
15
19
 
@@ -40,11 +44,12 @@ claude mcp add dev-logger-local -s user -- node $(pwd)/dist/index.js
40
44
  This prefix pattern applies to all MCP servers and helps Claude distinguish between different servers' tools.
41
45
 
42
46
  ### 1. dev_start_log_streaming
43
- Start a development server and stream its output to a log file.
47
+ Start a development server and stream its output to a log file. **Supports multiple concurrent processes.**
44
48
 
45
49
  **Parameters:**
46
50
  - `command` (optional): Dev command to run (default: "npm run dev")
47
51
  - `outputFile` (optional): File to write logs to (default: "dev-server-logs.txt")
52
+ - `processId` (optional): Custom process ID (auto-generated if not provided)
48
53
  - `cwd` (optional): Working directory
49
54
  - `env` (optional): Environment variables to pass
50
55
 
@@ -61,50 +66,92 @@ Start a development server and stream its output to a log file.
61
66
  }
62
67
  ```
63
68
 
64
- ### 2. dev_stop_log_streaming
65
- Stop the running development server and logging.
69
+ ### 2. dev_list_processes
70
+ List all running development processes with their status and details.
66
71
 
67
72
  **No parameters required.**
68
73
 
69
- ### 3. dev_restart_log_streaming
70
- Restart the development server (useful when it crashes or hangs).
74
+ ### 3. dev_stop_log_streaming
75
+ Stop development server(s) and logging.
71
76
 
72
77
  **Parameters:**
78
+ - `processId` (optional): Process ID to stop (if not provided, stops all processes)
79
+
80
+ ### 4. dev_restart_log_streaming
81
+ Restart a specific development server (useful when it crashes or hangs).
82
+
83
+ **Parameters:**
84
+ - `processId` (required): Process ID to restart
73
85
  - `clearLogs` (optional): Whether to clear the log file on restart (default: false)
74
86
 
75
- ### 4. dev_get_status
76
- Check if the development server is running and get its status.
87
+ ### 5. dev_get_status
88
+ Check if development server(s) are running and get their status.
89
+
90
+ **Parameters:**
91
+ - `processId` (optional): Process ID to get status for (if not provided, shows all processes)
77
92
 
78
93
  **Returns:**
79
94
  - Running status
80
- - Process ID (PID)
95
+ - Process ID(s)
96
+ - PID(s)
81
97
  - Uptime
82
- - Current command
83
- - Log file location
98
+ - Current command(s)
99
+ - Log file location(s)
84
100
 
85
- ### 5. dev_tail_logs
101
+ ### 6. dev_tail_logs
86
102
  Get the last N lines from the log file.
87
103
 
88
104
  **Parameters:**
105
+ - `processId` (optional): Process ID to tail logs from (smart fallback for single process)
89
106
  - `lines` (optional): Number of lines to return (default: 50)
90
107
  - `filter` (optional): Grep pattern to filter logs
91
108
 
92
109
  **Example:**
93
110
  ```json
94
111
  {
112
+ "processId": "npm-frontend",
95
113
  "lines": 100,
96
114
  "filter": "ERROR"
97
115
  }
98
116
  ```
99
117
 
100
- ### 6. dev_clear_logs
118
+ ### 7. dev_clear_logs
101
119
  Clear the log file.
102
120
 
103
121
  **Parameters:**
122
+ - `processId` (optional): Process ID to clear logs for (smart fallback for single process)
104
123
  - `backup` (optional): Whether to backup logs before clearing (default: false)
105
124
 
106
125
  ## Usage Examples
107
126
 
127
+ ### Multi-Process Development (v2.0.0)
128
+ ```typescript
129
+ // Start frontend and backend simultaneously
130
+ dev_start_log_streaming({
131
+ "command": "npm run dev",
132
+ "outputFile": "frontend.log",
133
+ "processId": "frontend"
134
+ })
135
+
136
+ dev_start_log_streaming({
137
+ "command": "npx ampx sandbox --stream-function-logs",
138
+ "outputFile": "backend.log",
139
+ "processId": "backend"
140
+ })
141
+
142
+ // List all running processes
143
+ dev_list_processes()
144
+
145
+ // Stop just the frontend
146
+ dev_stop_log_streaming({ "processId": "frontend" })
147
+
148
+ // Restart backend with clean logs
149
+ dev_restart_log_streaming({
150
+ "processId": "backend",
151
+ "clearLogs": true
152
+ })
153
+ ```
154
+
108
155
  ### Start Next.js Development Server
109
156
  ```typescript
110
157
  // Start Next.js dev server
@@ -146,17 +193,27 @@ Clear the log file.
146
193
 
147
194
  ## Log Format
148
195
 
149
- Logs are written with timestamps and error markers:
196
+ Logs are written with timestamps, process IDs, and error markers:
150
197
 
151
198
  ```
152
- [2024-01-15T10:30:45.123Z] Starting: npm run dev
153
- [2024-01-15T10:30:46.456Z] > my-app@1.0.0 dev
154
- [2024-01-15T10:30:46.457Z] > next dev
155
- [2024-01-15T10:30:47.123Z] ▲ Next.js 14.0.0
156
- [2024-01-15T10:30:47.124Z] - Local: http://localhost:3000
157
- [2024-01-15T10:30:48.789Z] [ERROR] Error: Cannot find module './components/Header'
199
+ [2024-01-15T10:30:45.123Z] Starting: npm run dev (Process ID: npm-frontend)
200
+ [2024-01-15T10:30:46.456Z] [npm-frontend] > my-app@1.0.0 dev
201
+ [2024-01-15T10:30:46.457Z] [npm-frontend] > next dev
202
+ [2024-01-15T10:30:47.123Z] [npm-frontend] ▲ Next.js 14.0.0
203
+ [2024-01-15T10:30:47.124Z] [npm-frontend] - Local: http://localhost:3000
204
+ [2024-01-15T10:30:48.789Z] [npm-frontend] [ERROR] Error: Cannot find module './components/Header'
205
+
206
+ [2024-01-15T10:30:50.123Z] Starting: npx ampx sandbox --stream-function-logs (Process ID: npx-backend)
207
+ [2024-01-15T10:30:51.456Z] [npx-backend] [INFO] Amplify sandbox starting...
208
+ [2024-01-15T10:30:52.123Z] [npx-backend] Process exited with code 0 and signal null
158
209
  ```
159
210
 
211
+ ### Process ID Generation
212
+ The server automatically generates intelligent process IDs based on the command and output file:
213
+ - Command: `npm run dev` + Output: `frontend.log` → Process ID: `npm-frontend`
214
+ - Command: `npx ampx sandbox --stream-function-logs` + Output: `backend.log` → Process ID: `npx-backend`
215
+ - Duplicate IDs are automatically suffixed with `-1`, `-2`, etc.
216
+
160
217
  ## Common Use Cases
161
218
 
162
219
  ### 1. Debugging Build Failures
@@ -192,6 +249,19 @@ dev_start_log_streaming {
192
249
  dev_restart_log_streaming { "clearLogs": true }
193
250
  ```
194
251
 
252
+ ### 5. Amplify Development Workflow
253
+ ```bash
254
+ # Start Amplify backend logging
255
+ dev_start_log_streaming {
256
+ "command": "npx ampx sandbox --stream-function-logs",
257
+ "outputFile": "backend-logs.txt",
258
+ "processId": "amplify-backend"
259
+ }
260
+
261
+ # Monitor Lambda function logs
262
+ dev_tail_logs { "processId": "amplify-backend", "filter": "ERROR|WARN", "lines": 100 }
263
+ ```
264
+
195
265
  ## Troubleshooting
196
266
 
197
267
  ### Dev Server Not Starting
@@ -210,12 +280,31 @@ dev_restart_log_streaming { "clearLogs": true }
210
280
  2. If that fails, the process may have crashed - check system process manager
211
281
  3. Restart Claude Code to clean up orphaned processes
212
282
 
283
+ ## Implementation Details
284
+
285
+ ### Process Management
286
+ - Uses Node.js `spawn` with `detached: true` for proper process isolation
287
+ - Implements graceful shutdown with SIGTERM signals
288
+ - Automatically removes event listeners on process termination to prevent memory leaks
289
+ - Attempts to kill process groups (`-pid`) to handle child processes
290
+
291
+ ### State Persistence
292
+ - Saves process state to `${tmpdir}/mcp-dev-logger.json`
293
+ - Restores process information on server restart (where possible)
294
+ - Handles process cleanup on server shutdown
295
+
296
+ ### Log Streaming
297
+ - Real-time streaming of both stdout and stderr
298
+ - Timestamped log entries with process ID tagging
299
+ - Error entries are clearly marked with `[ERROR]` prefix
300
+ - Supports concurrent logging from multiple processes to different files
301
+
213
302
  ## Limitations
214
303
 
215
- - Only one dev server can be managed at a time (default instance)
216
304
  - Process management is best-effort - some processes may not respond to signals
217
305
  - Very large log files may impact performance of `dev_tail_logs`
218
- - Only captures server-side console output (not browser console logs) - for browser logs, use the Playwright MCP server
306
+ - Only captures server-side console output (not browser console logs)
307
+ - Process state restoration is limited after server restarts (PIDs become invalid)
219
308
 
220
309
  ## Development
221
310