mcp-perforce-server 2.1.0 โ 2.1.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/LICENSE +20 -20
- package/MCP_CONFIG_EXAMPLES.md +222 -222
- package/README.md +130 -568
- package/dist/p4/config.d.ts.map +1 -1
- package/dist/p4/config.js +32 -21
- package/dist/p4/config.js.map +1 -1
- package/dist/p4/parse.d.ts +28 -0
- package/dist/p4/parse.d.ts.map +1 -1
- package/dist/p4/parse.js +341 -29
- package/dist/p4/parse.js.map +1 -1
- package/dist/p4/runner.d.ts.map +1 -1
- package/dist/p4/runner.js +223 -14
- package/dist/p4/runner.js.map +1 -1
- package/dist/p4/security.d.ts.map +1 -1
- package/dist/p4/security.js +15 -5
- package/dist/p4/security.js.map +1 -1
- package/dist/server.d.ts +15 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +418 -135
- package/dist/server.js.map +1 -1
- package/dist/tools/basic.d.ts +58 -0
- package/dist/tools/basic.d.ts.map +1 -1
- package/dist/tools/basic.js +450 -52
- package/dist/tools/basic.js.map +1 -1
- package/dist/tools/changelist.d.ts +1 -1
- package/dist/tools/changelist.d.ts.map +1 -1
- package/dist/tools/changelist.js +31 -22
- package/dist/tools/changelist.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +8 -1
- package/dist/tools/index.js.map +1 -1
- package/package.json +114 -114
package/README.md
CHANGED
|
@@ -1,568 +1,130 @@
|
|
|
1
|
-
# MCP Perforce Server
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/mcp-perforce-server)
|
|
4
|
-
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
[](https://nodejs.org/)
|
|
6
|
-
[](https://www.typescriptlang.org/)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
>
|
|
11
|
-
|
|
12
|
-
##
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
-
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
2. **Configuration:** Choose one method:
|
|
132
|
-
|
|
133
|
-
**Method A: .p4config file** (Recommended)
|
|
134
|
-
```
|
|
135
|
-
P4PORT=your-perforce-server:1666
|
|
136
|
-
P4USER=your-username
|
|
137
|
-
P4CLIENT=your-workspace-name
|
|
138
|
-
P4PASSWD=your-password
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
**Method B: MCP Environment Variables**
|
|
142
|
-
```json
|
|
143
|
-
{
|
|
144
|
-
"mcpServers": {
|
|
145
|
-
"perforce": {
|
|
146
|
-
"command": "mcp-perforce-server",
|
|
147
|
-
"env": {
|
|
148
|
-
"P4PORT": "your-perforce-server:1666",
|
|
149
|
-
"P4USER": "your-username",
|
|
150
|
-
"P4CLIENT": "your-workspace-name",
|
|
151
|
-
"P4PASSWD": "your-password"
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
3. **Performance (Optional):** For faster responses in development:
|
|
159
|
-
```bash
|
|
160
|
-
export P4_PERFORMANCE_MODE=fast
|
|
161
|
-
export P4_TIMEOUT_MS=5000
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
4. **Verification:**
|
|
165
|
-
```bash
|
|
166
|
-
mcp-perforce-server --help
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
## Authentication Configuration
|
|
170
|
-
|
|
171
|
-
The server supports multiple methods for providing Perforce credentials, prioritized in this order:
|
|
172
|
-
|
|
173
|
-
### 1. **Environment Variables** (Highest Priority)
|
|
174
|
-
Set `P4PASSWD` along with other Perforce environment variables:
|
|
175
|
-
|
|
176
|
-
```bash
|
|
177
|
-
export P4PORT=perforce-server:1666
|
|
178
|
-
export P4USER=your-username
|
|
179
|
-
export P4CLIENT=your-workspace-name
|
|
180
|
-
export P4PASSWD=your-password
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### 2. **`.p4config` File** (Recommended)
|
|
184
|
-
Create a `.p4config` file in your project root:
|
|
185
|
-
|
|
186
|
-
```ini
|
|
187
|
-
P4PORT=perforce-server:1666
|
|
188
|
-
P4USER=your-username
|
|
189
|
-
P4CLIENT=your-workspace-name
|
|
190
|
-
P4PASSWD=your-password
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
The server automatically searches upward from the current directory to find this file.
|
|
194
|
-
|
|
195
|
-
### 3. **MCP Configuration**
|
|
196
|
-
Include credentials in your MCP server configuration (see examples above).
|
|
197
|
-
|
|
198
|
-
**Security Notes:**
|
|
199
|
-
- Passwords are **masked** (`***masked***`) in all logs
|
|
200
|
-
- The system operates **non-interactively** - no password prompts
|
|
201
|
-
- Authentication failures return `P4_AUTH_FAILED` error code
|
|
202
|
-
- For production, prefer `.p4config` files or secure environment variables
|
|
203
|
-
|
|
204
|
-
## Security Configuration
|
|
205
|
-
|
|
206
|
-
**Default Security Posture:**
|
|
207
|
-
- `P4_READONLY_MODE=true` - Read-only operations only
|
|
208
|
-
- `P4_DISABLE_DELETE=true` - Delete operations disabled
|
|
209
|
-
|
|
210
|
-
**Production Environments:**
|
|
211
|
-
```bash
|
|
212
|
-
# Read-only mode (safest)
|
|
213
|
-
P4_READONLY_MODE=true P4_DISABLE_DELETE=true
|
|
214
|
-
|
|
215
|
-
# Write-enabled, delete-protected (recommended)
|
|
216
|
-
P4_READONLY_MODE=false P4_DISABLE_DELETE=true
|
|
217
|
-
|
|
218
|
-
# Full access (use with caution)
|
|
219
|
-
P4_READONLY_MODE=false P4_DISABLE_DELETE=false
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
## Performance Configuration
|
|
223
|
-
|
|
224
|
-
**Performance Optimization:**
|
|
225
|
-
The MCP server includes multiple performance modes to balance speed with security features:
|
|
226
|
-
|
|
227
|
-
**Development (Fastest Response):**
|
|
228
|
-
```bash
|
|
229
|
-
# Fast Mode - Optimized for development speed
|
|
230
|
-
export P4_PERFORMANCE_MODE=fast
|
|
231
|
-
export P4_TIMEOUT_MS=5000 # 5 second timeout
|
|
232
|
-
export P4_ENABLE_RATE_LIMITING=false # Disable rate limiting overhead
|
|
233
|
-
export P4_ENABLE_MEMORY_LIMITS=false # Disable memory monitoring overhead
|
|
234
|
-
export P4_ENABLE_AUDIT_LOGGING=false # Disable audit logging overhead
|
|
235
|
-
export P4_CONFIG_CACHE_TTL=600000 # Cache config for 10 minutes
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
**Balanced (Recommended):**
|
|
239
|
-
```bash
|
|
240
|
-
# Balanced Mode - Good performance with essential monitoring
|
|
241
|
-
export P4_PERFORMANCE_MODE=balanced
|
|
242
|
-
export P4_TIMEOUT_MS=10000 # 10 second timeout
|
|
243
|
-
export P4_ENABLE_RATE_LIMITING=false # Rate limiting disabled
|
|
244
|
-
export P4_ENABLE_MEMORY_LIMITS=true # Memory monitoring enabled
|
|
245
|
-
export P4_ENABLE_AUDIT_LOGGING=false # Audit logging disabled
|
|
246
|
-
export P4_CONFIG_CACHE_TTL=300000 # Cache config for 5 minutes
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
**Production (Secure):**
|
|
250
|
-
```bash
|
|
251
|
-
# Secure Mode - Full security features enabled
|
|
252
|
-
export P4_PERFORMANCE_MODE=secure
|
|
253
|
-
export P4_TIMEOUT_MS=15000 # 15 second timeout
|
|
254
|
-
export P4_ENABLE_RATE_LIMITING=true # Rate limiting enabled
|
|
255
|
-
export P4_ENABLE_MEMORY_LIMITS=true # Memory monitoring enabled
|
|
256
|
-
export P4_ENABLE_AUDIT_LOGGING=true # Audit logging enabled
|
|
257
|
-
export P4_CONFIG_CACHE_TTL=300000 # Cache config for 5 minutes
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
**Performance Features:**
|
|
261
|
-
- โก **Fast Command Timeouts** - Configurable 5-60+ second timeouts vs default 60s
|
|
262
|
-
- ๐๏ธ **Configuration Caching** - Cache .p4config lookups for 5-10 minutes
|
|
263
|
-
- ๐ง **Optimized Memory Checks** - Periodic vs per-operation memory monitoring
|
|
264
|
-
- ๐ฆ **Smart Rate Limiting** - Disabled in development, optimized algorithms in production
|
|
265
|
-
- ๐ **Selective Audit Logging** - Minimal overhead with configurable detail levels
|
|
266
|
-
- ๐ฏ **Automatic Mode Detection** - Development vs production environment detection
|
|
267
|
-
|
|
268
|
-
**Custom Tuning:**
|
|
269
|
-
```bash
|
|
270
|
-
# Fine-tune individual components
|
|
271
|
-
P4_TIMEOUT_MS=8000 # Custom timeout in milliseconds
|
|
272
|
-
P4_CONFIG_CACHE_TTL=420000 # Custom cache TTL (7 minutes)
|
|
273
|
-
P4_MAX_MEMORY_MB=1024 # Memory limit in MB
|
|
274
|
-
NODE_ENV=development # Triggers automatic performance optimizations
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
## Compliance & Security Features
|
|
278
|
-
|
|
279
|
-
**Enterprise-Grade Security Suite:**
|
|
280
|
-
- ๐ **Audit Logging** - Complete operation tracking with retention policies
|
|
281
|
-
- ๐ฆ **Rate Limiting** - Configurable request throttling with block periods
|
|
282
|
-
- ๐งน **Input Sanitization** - Regex validation and path traversal protection
|
|
283
|
-
- ๐พ **Memory Limits** - Process memory monitoring and automatic GC
|
|
284
|
-
- ๐ **Compliance Reporting** - SOC 2, GDPR, HIPAA-ready architecture
|
|
285
|
-
|
|
286
|
-
**New Compliance Tools:**
|
|
287
|
-
- `p4.audit` - Query audit logs with filtering and CSV export
|
|
288
|
-
- `p4.compliance` - View compliance configuration and system status
|
|
289
|
-
|
|
290
|
-
**Compliance Configuration:**
|
|
291
|
-
```bash
|
|
292
|
-
# Enable enterprise features
|
|
293
|
-
P4_ENABLE_AUDIT_LOGGING=true
|
|
294
|
-
P4_ENABLE_RATE_LIMITING=true
|
|
295
|
-
P4_ENABLE_MEMORY_LIMITS=true
|
|
296
|
-
P4_ENABLE_INPUT_SANITIZATION=true
|
|
297
|
-
|
|
298
|
-
# Compliance tuning
|
|
299
|
-
P4_MAX_MEMORY_MB=1024
|
|
300
|
-
P4_AUDIT_RETENTION_DAYS=365
|
|
301
|
-
P4_RATE_LIMIT_REQUESTS=100
|
|
302
|
-
P4_RATE_LIMIT_WINDOW_MS=600000
|
|
303
|
-
P4_RATE_LIMIT_BLOCK_MS=3600000
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
**Security Architecture:**
|
|
307
|
-
- โ
**Defense-in-depth** - Multiple security layers
|
|
308
|
-
- โ
**Zero-trust defaults** - Everything disabled by default
|
|
309
|
-
- โ
**Structured logging** - JSON audit trails
|
|
310
|
-
- โ
**Input validation** - Regex and path sanitization
|
|
311
|
-
- โ
**Resource limits** - Memory and rate controls
|
|
312
|
-
- โ
**GDPR/HIPAA Ready** - No personal data storage
|
|
313
|
-
|
|
314
|
-
## Supported Operations
|
|
315
|
-
|
|
316
|
-
### Repository Operations
|
|
317
|
-
- `p4.info` - Server and client information
|
|
318
|
-
- `p4.status` - Workspace status
|
|
319
|
-
- `p4.sync` - Sync from depot
|
|
320
|
-
- `p4.opened` - List opened files
|
|
321
|
-
- `p4.have` - List synced files
|
|
322
|
-
- `p4.where` - Show file mappings
|
|
323
|
-
|
|
324
|
-
### File Operations
|
|
325
|
-
- `p4.add` - Add files to Perforce
|
|
326
|
-
- `p4.edit` - Open files for edit
|
|
327
|
-
- `p4.delete` - Mark files for deletion
|
|
328
|
-
- `p4.revert` - Revert changes
|
|
329
|
-
- `p4.diff` - Show file differences
|
|
330
|
-
- `p4.copy` - Copy files between locations
|
|
331
|
-
- `p4.move` - Move/rename files
|
|
332
|
-
- `p4.blame` - Show file annotations (like git blame)
|
|
333
|
-
|
|
334
|
-
### Merge & Conflict Resolution
|
|
335
|
-
- `p4.resolve` - Resolve merge conflicts
|
|
336
|
-
- `p4.shelve` - Shelve files for code review
|
|
337
|
-
- `p4.unshelve` - Unshelve files from review
|
|
338
|
-
|
|
339
|
-
### Changelist Operations
|
|
340
|
-
- `p4.changelist.create` - Create new changelist
|
|
341
|
-
- `p4.changelist.update` - Update changelist
|
|
342
|
-
- `p4.changelist.submit` - Submit changelist
|
|
343
|
-
- `p4.submit` - Submit default changelist
|
|
344
|
-
- `p4.describe` - Describe changelist details
|
|
345
|
-
- `p4.changes` - List changelists with filtering
|
|
346
|
-
|
|
347
|
-
### Search & Discovery
|
|
348
|
-
- `p4.grep` - Search text patterns across files
|
|
349
|
-
- `p4.files` - List files in depot with metadata
|
|
350
|
-
- `p4.dirs` - List directories in depot
|
|
351
|
-
- `p4.filelog` - File history
|
|
352
|
-
|
|
353
|
-
### User & Client Management
|
|
354
|
-
- `p4.users` - List Perforce users
|
|
355
|
-
- `p4.user` - Get user information
|
|
356
|
-
- `p4.clients` - List workspaces
|
|
357
|
-
- `p4.client` - Get workspace details
|
|
358
|
-
|
|
359
|
-
### Job & Issue Tracking
|
|
360
|
-
- `p4.jobs` - List jobs (if enabled)
|
|
361
|
-
- `p4.job` - Get job details
|
|
362
|
-
- `p4.fixes` - Show changelist-job relationships
|
|
363
|
-
|
|
364
|
-
### Labels & Organization
|
|
365
|
-
- `p4.labels` - List labels
|
|
366
|
-
- `p4.label` - Get label details
|
|
367
|
-
|
|
368
|
-
### Analytics & Monitoring
|
|
369
|
-
- `p4.sizes` - File size and disk usage statistics
|
|
370
|
-
- `p4.audit` - Audit log queries and compliance reporting
|
|
371
|
-
- `p4.compliance` - Compliance configuration and status
|
|
372
|
-
|
|
373
|
-
### Utilities
|
|
374
|
-
- `p4.config.detect` - Configuration diagnostics
|
|
375
|
-
|
|
376
|
-
## Integration
|
|
377
|
-
|
|
378
|
-
### VS Code / Cursor
|
|
379
|
-
For silent operation without approval prompts, add these settings:
|
|
380
|
-
```json
|
|
381
|
-
{
|
|
382
|
-
"mcpServers": {
|
|
383
|
-
"perforce": {
|
|
384
|
-
"command": "mcp-perforce-server",
|
|
385
|
-
"env": {
|
|
386
|
-
"P4_READONLY_MODE": "false",
|
|
387
|
-
"LOG_LEVEL": "error"
|
|
388
|
-
},
|
|
389
|
-
"alwaysAllow": ["p4.*"],
|
|
390
|
-
"disabled": false
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
See [MCP_CONFIG_EXAMPLES.md](MCP_CONFIG_EXAMPLES.md) for IDE-specific configuration.
|
|
397
|
-
|
|
398
|
-
### Claude Desktop
|
|
399
|
-
Add to `claude_desktop_config.json`:
|
|
400
|
-
```json
|
|
401
|
-
{
|
|
402
|
-
"mcpServers": {
|
|
403
|
-
"perforce": {
|
|
404
|
-
"command": "mcp-perforce-server",
|
|
405
|
-
"env": {
|
|
406
|
-
"P4_READONLY_MODE": "false"
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
## Environment Variables
|
|
414
|
-
|
|
415
|
-
| Variable | Description | Default |
|
|
416
|
-
|----------|-------------|---------|
|
|
417
|
-
| `P4_READONLY_MODE` | Enable read-only mode | `true` |
|
|
418
|
-
| `P4_DISABLE_DELETE` | Disable delete operations | `true` |
|
|
419
|
-
| `P4_PATH` | Path to p4 executable | `p4` |
|
|
420
|
-
| `P4CONFIG` | Config file name | `.p4config` |
|
|
421
|
-
| `LOG_LEVEL` | Logging level | `warn` |
|
|
422
|
-
| `P4_ENABLE_AUDIT_LOGGING` | Enable audit logging | `false` |
|
|
423
|
-
| `P4_ENABLE_RATE_LIMITING` | Enable rate limiting | `true` |
|
|
424
|
-
| `P4_ENABLE_MEMORY_LIMITS` | Enable memory limits | `true` |
|
|
425
|
-
| `P4_ENABLE_INPUT_SANITIZATION` | Enable input sanitization | `true` |
|
|
426
|
-
| `P4_MAX_MEMORY_MB` | Memory limit in MB | `512` |
|
|
427
|
-
| `P4_AUDIT_RETENTION_DAYS` | Audit log retention days | `90` |
|
|
428
|
-
| `P4_RATE_LIMIT_REQUESTS` | Max requests per window | `100` |
|
|
429
|
-
| `P4_RATE_LIMIT_WINDOW_MS` | Rate limit window ms | `600000` |
|
|
430
|
-
| `P4_RATE_LIMIT_BLOCK_MS` | Rate limit block duration ms | `3600000` |
|
|
431
|
-
|
|
432
|
-
## Error Handling
|
|
433
|
-
|
|
434
|
-
Standardized error codes for reliable error handling:
|
|
435
|
-
- `P4_NOT_FOUND` - Perforce executable not found
|
|
436
|
-
- `P4_AUTH_FAILED` - Authentication failure
|
|
437
|
-
- `P4_CLIENT_UNKNOWN` - Unknown workspace
|
|
438
|
-
- `P4_CONNECTION_FAILED` - Server connection failed
|
|
439
|
-
- `P4_READONLY_MODE` - Operation blocked by read-only mode
|
|
440
|
-
- `P4_DELETE_DISABLED` - Delete operation blocked
|
|
441
|
-
- `P4_INVALID_ARGS` - Invalid arguments or input sanitization failure
|
|
442
|
-
- `P4_MEMORY_LIMIT` - Memory limit exceeded
|
|
443
|
-
- `P4_AUDIT_DISABLED` - Audit logging not enabled
|
|
444
|
-
- `RATE_LIMIT_EXCEEDED` - Rate limit exceeded
|
|
445
|
-
- `RATE_LIMIT_EXCEEDED` - Rate limit exceeded
|
|
446
|
-
|
|
447
|
-
## Architecture
|
|
448
|
-
|
|
449
|
-
### ๐๏ธ **System Overview**
|
|
450
|
-
```
|
|
451
|
-
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
|
|
452
|
-
โ AI Assistant โโโโโโ MCP Protocol โโโโโโ MCP Perforce โ
|
|
453
|
-
โ (Claude/GPT) โ โ (JSON-RPC 2.0) โ โ Server โ
|
|
454
|
-
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
|
|
455
|
-
โ โ โ
|
|
456
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
457
|
-
โ
|
|
458
|
-
โโโโโโโโโโโโโโโโโโโโโโ
|
|
459
|
-
โ Perforce CLI โ
|
|
460
|
-
โ (p4) โ
|
|
461
|
-
โโโโโโโโโโโโโโโโโโโโโโ
|
|
462
|
-
```
|
|
463
|
-
|
|
464
|
-
### ๐ง **Core Components**
|
|
465
|
-
|
|
466
|
-
#### **Security Module (`src/p4/security.ts`)**
|
|
467
|
-
- **Rate Limiting**: Token bucket algorithm with configurable limits
|
|
468
|
-
- **Audit Logging**: Structured logging with retention policies
|
|
469
|
-
- **Input Sanitization**: Regex-based validation and escaping
|
|
470
|
-
- **Memory Management**: Automatic monitoring and garbage collection
|
|
471
|
-
- **Compliance Reporting**: SOC 2, GDPR, HIPAA compliance tools
|
|
472
|
-
|
|
473
|
-
#### **Server Core (`src/server.ts`)**
|
|
474
|
-
- **MCP Protocol Handler**: JSON-RPC 2.0 implementation
|
|
475
|
-
- **Tool Registry**: 37+ Perforce operations with security validation
|
|
476
|
-
- **Request Processing**: Async handling with error recovery
|
|
477
|
-
- **Configuration Management**: Environment variable processing
|
|
478
|
-
|
|
479
|
-
#### **Tool Modules (`src/tools/`)**
|
|
480
|
-
- **Basic Operations**: Core Perforce commands (add, edit, submit)
|
|
481
|
-
- **Advanced Operations**: Complex workflows (merge, integrate, resolve)
|
|
482
|
-
- **Changelist Management**: CL creation, modification, and tracking
|
|
483
|
-
- **Search & Discovery**: File finding, history, and metadata queries
|
|
484
|
-
- **User Management**: Client specs, user info, and permissions
|
|
485
|
-
- **Analytics**: Repository statistics and monitoring
|
|
486
|
-
|
|
487
|
-
#### **Perforce Integration (`src/p4/`)**
|
|
488
|
-
- **Command Execution**: Secure child_process spawning
|
|
489
|
-
- **Output Parsing**: Structured data extraction from p4 output
|
|
490
|
-
- **Environment Detection**: Automatic .p4config and credential discovery
|
|
491
|
-
- **Error Handling**: Comprehensive error classification and reporting
|
|
492
|
-
|
|
493
|
-
### ๐ก๏ธ **Security Architecture**
|
|
494
|
-
|
|
495
|
-
#### **Defense in Depth**
|
|
496
|
-
1. **Input Validation**: All inputs sanitized before processing
|
|
497
|
-
2. **Rate Limiting**: Prevents abuse and resource exhaustion
|
|
498
|
-
3. **Audit Logging**: Complete operation traceability
|
|
499
|
-
4. **Memory Protection**: Automatic monitoring and limits
|
|
500
|
-
5. **Read-Only Mode**: Safe defaults for sensitive environments
|
|
501
|
-
|
|
502
|
-
#### **Compliance Framework**
|
|
503
|
-
- **SOC 2 Type II**: Automated controls and reporting
|
|
504
|
-
- **GDPR**: Data protection and privacy controls
|
|
505
|
-
- **HIPAA**: Healthcare data handling compliance
|
|
506
|
-
- **Custom Policies**: Configurable retention and access controls
|
|
507
|
-
|
|
508
|
-
### ๐ **Data Flow**
|
|
509
|
-
```
|
|
510
|
-
User Request โ MCP Protocol โ Security Validation โ Tool Execution โ Perforce CLI โ Response
|
|
511
|
-
โ โ โ โ โ โ
|
|
512
|
-
Sanitize Authenticate Rate Check Command Execute Format
|
|
513
|
-
```
|
|
514
|
-
|
|
515
|
-
### ๐ **Integration Patterns**
|
|
516
|
-
- **VS Code Extension**: Direct MCP integration via configuration
|
|
517
|
-
- **Claude Desktop**: App-specific MCP server configuration
|
|
518
|
-
- **Custom Clients**: Standard JSON-RPC 2.0 protocol support
|
|
519
|
-
- **Enterprise Deployments**: Docker/containerized execution
|
|
520
|
-
|
|
521
|
-
## Development
|
|
522
|
-
|
|
523
|
-
```bash
|
|
524
|
-
# Local development
|
|
525
|
-
git clone https://github.com/iPraBhu/mcp-perforce-server.git
|
|
526
|
-
cd mcp-perforce-server
|
|
527
|
-
npm install
|
|
528
|
-
npm run build
|
|
529
|
-
|
|
530
|
-
# Run tests
|
|
531
|
-
npm test
|
|
532
|
-
|
|
533
|
-
# Development mode
|
|
534
|
-
npm run watch
|
|
535
|
-
```
|
|
536
|
-
|
|
537
|
-
## Contributing
|
|
538
|
-
|
|
539
|
-
This project was created with โค๏ธ by [Pratik Bhuite](https://github.com/iPraBhu) to solve real Perforce automation challenges.
|
|
540
|
-
|
|
541
|
-
**Ways to contribute:**
|
|
542
|
-
- ๐ **Report bugs** - Open an issue if something's not working
|
|
543
|
-
- ๐ก **Suggest features** - Have an idea? Let's discuss it!
|
|
544
|
-
- ๐ง **Submit PRs** - Code contributions are welcome
|
|
545
|
-
- ๐ **Improve docs** - Help make the documentation better
|
|
546
|
-
- โญ **Star the repo** - Show your support!
|
|
547
|
-
|
|
548
|
-
**Found this useful?** Consider giving it a star โญ and sharing with others who might benefit!
|
|
549
|
-
|
|
550
|
-
## Support This Project
|
|
551
|
-
|
|
552
|
-
โ **Enjoying this tool?** [Buy me a coffee on Ko-fi](https://ko-fi.com/adevguide) to support continued development and new features!
|
|
553
|
-
|
|
554
|
-
[](https://ko-fi.com/adevguide)
|
|
555
|
-
|
|
556
|
-
## Security
|
|
557
|
-
|
|
558
|
-
This project follows security best practices:
|
|
559
|
-
- ๐ **Dependencies**: Regularly updated to latest secure versions
|
|
560
|
-
- ๐ก๏ธ **Default Safety**: Read-only mode and delete protection by default
|
|
561
|
-
- ๐ **Audit**: Run `npm run audit-fix` to check for vulnerabilities
|
|
562
|
-
- ๐ข **Report Issues**: Security issues? Please report privately via GitHub
|
|
563
|
-
|
|
564
|
-
## License
|
|
565
|
-
|
|
566
|
-
MIT License - Feel free to use, modify, and distribute as needed. See [LICENSE](LICENSE) for details.
|
|
567
|
-
|
|
568
|
-
**TL;DR:** Use it however you want, just keep the license notice. Built for the community! ๐
|
|
1
|
+
๏ปฟ# MCP Perforce Server
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/mcp-perforce-server)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
|
|
8
|
+
MCP server for Perforce (P4) with safe defaults, fast execution, and structured JSON responses.
|
|
9
|
+
|
|
10
|
+
> Developed with vibe coding for practical Perforce automation workflows.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g mcp-perforce-server
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
1. Make sure `p4` is installed and available in `PATH`.
|
|
21
|
+
2. Configure Perforce credentials using either:
|
|
22
|
+
- `.p4config` in your workspace/project root, or
|
|
23
|
+
- MCP `env` variables.
|
|
24
|
+
3. Add MCP server config in your IDE/client.
|
|
25
|
+
|
|
26
|
+
### Example `.p4config`
|
|
27
|
+
|
|
28
|
+
```ini
|
|
29
|
+
P4PORT=perforce-server:1666
|
|
30
|
+
P4USER=your-username
|
|
31
|
+
P4CLIENT=your-workspace-name
|
|
32
|
+
P4PASSWD=your-password
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Global Install MCP Config
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"mcpServers": {
|
|
40
|
+
"perforce": {
|
|
41
|
+
"command": "mcp-perforce-server",
|
|
42
|
+
"env": {
|
|
43
|
+
"P4_READONLY_MODE": "false",
|
|
44
|
+
"P4_DISABLE_DELETE": "true",
|
|
45
|
+
"LOG_LEVEL": "error"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Local Repo MCP Config
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"mcpServers": {
|
|
57
|
+
"perforce": {
|
|
58
|
+
"command": "node",
|
|
59
|
+
"args": ["/absolute/path/to/mcp-perforce-server/dist/server.js"],
|
|
60
|
+
"env": {
|
|
61
|
+
"P4_READONLY_MODE": "false",
|
|
62
|
+
"P4_DISABLE_DELETE": "true",
|
|
63
|
+
"LOG_LEVEL": "error"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Windows `args` example:
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"mcpServers": {
|
|
75
|
+
"perforce": {
|
|
76
|
+
"command": "node",
|
|
77
|
+
"args": ["C:\\Tools\\git-projects\\mcp-perforce-server\\dist\\server.js"]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Safe Defaults
|
|
84
|
+
|
|
85
|
+
- `P4_READONLY_MODE=true`
|
|
86
|
+
- `P4_DISABLE_DELETE=true`
|
|
87
|
+
- `P4_PERFORMANCE_MODE=fast`
|
|
88
|
+
|
|
89
|
+
## Key Environment Variables
|
|
90
|
+
|
|
91
|
+
| Variable | Purpose | Default |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| `P4_READONLY_MODE` | Block write operations | `true` |
|
|
94
|
+
| `P4_DISABLE_DELETE` | Block delete operations | `true` |
|
|
95
|
+
| `P4_PERFORMANCE_MODE` | `fast`, `balanced`, `secure` | `fast` |
|
|
96
|
+
| `P4_TIMEOUT_MS` | Command timeout (ms) | mode-based |
|
|
97
|
+
| `P4_RESPONSE_CACHE` | Read-result cache | `true` |
|
|
98
|
+
| `P4_PRETTY_JSON` | Pretty JSON responses | `false` |
|
|
99
|
+
| `P4CONFIG` | Config file name | `.p4config` |
|
|
100
|
+
| `LOG_LEVEL` | `error`, `warn`, `info`, `debug` | `warn` |
|
|
101
|
+
|
|
102
|
+
## Tool Coverage
|
|
103
|
+
|
|
104
|
+
- 47 MCP tools covering repository info, file operations, changelists, merge/resolve, search, users/clients, jobs, labels/streams, analytics, and compliance.
|
|
105
|
+
- Includes both:
|
|
106
|
+
- `p4.diff` for workspace/local vs depot diff.
|
|
107
|
+
- `p4.diff2` for depot-to-depot server-side diff.
|
|
108
|
+
|
|
109
|
+
## Documentation
|
|
110
|
+
|
|
111
|
+
- Detailed tool reference: [docs/TOOLS_REFERENCE.md](docs/TOOLS_REFERENCE.md)
|
|
112
|
+
- Docs index: [docs/README.md](docs/README.md)
|
|
113
|
+
- IDE/client setup examples: [MCP_CONFIG_EXAMPLES.md](MCP_CONFIG_EXAMPLES.md)
|
|
114
|
+
- Perforce setup notes: [PERFORCE_SETUP.md](PERFORCE_SETUP.md)
|
|
115
|
+
|
|
116
|
+
## Development
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm install
|
|
120
|
+
npm run build
|
|
121
|
+
npm test
|
|
122
|
+
npm run test:integration
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
MIT
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|