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/README.md CHANGED
@@ -1,568 +1,130 @@
1
- # MCP Perforce Server
2
-
3
- [![npm version](https://badge.fury.io/js/mcp-perforce-server.svg)](https://www.npmjs.com/package/mcp-perforce-server)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
- [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/)
6
- [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue)](https://www.typescriptlang.org/)
7
-
8
- Enterprise-grade MCP (Model Context Protocol) server providing secure, non-interactive Perforce operations for AI-assisted development workflows with Claude, ChatGPT, VS Code, and Cursor IDE.
9
-
10
- > **Created using vibe coding to solve real-world Perforce automation challenges. Open source, community-driven, and ready for customization!
11
-
12
- ## Overview
13
-
14
- Production-ready server that exposes **37+ Perforce VCS operations** through the Model Context Protocol, enabling AI assistants and code editors to interact with Perforce repositories safely and efficiently. Perfect for DevOps automation, enterprise development workflows, and AI-powered version control management.
15
-
16
- **Key Features:**
17
- - ๐Ÿ”’ **Enterprise Security** - Read-only defaults with configurable access controls
18
- - ๐Ÿ” **Compliance Ready** - SOC 2, GDPR, HIPAA compliant with audit logging
19
- - ๐Ÿšฆ **Rate Limiting** - Configurable request throttling with automatic blocking
20
- - ๐Ÿงน **Input Sanitization** - Regex validation and path traversal protection
21
- - ๐Ÿ’พ **Memory Management** - Process monitoring with automatic GC and limits
22
- - ๐Ÿ“Š **Audit Logging** - Complete operation tracking with retention policies
23
- - โšก **Performance Optimized** - Fast/Balanced/Secure modes with configurable timeouts and caching
24
- - ๐ŸŒ **Cross-platform Support** - Windows, macOS, Linux compatibility
25
- - ๐Ÿค– **AI Integration** - Works with Claude, ChatGPT, VS Code, Cursor, and other AI assistants
26
- - ๐Ÿš€ **Non-interactive Operations** - Automated Perforce commands with comprehensive error handling
27
- - ๐Ÿ“ **Multi-project Support** - Automatic `.p4config` detection with upward directory search
28
- - ๐Ÿ›ก๏ธ **Production Ready** - Structured JSON responses with standardized error codes
29
- - ๐Ÿ”ง **Developer Friendly** - TypeScript support with comprehensive documentation
30
- - ๐ŸŽฏ **Zero Configuration** - Works out-of-the-box with sensible defaults
31
-
32
- ## Core Capabilities
33
-
34
- ### ๐Ÿ”’ Security & Compliance
35
- - **Defense-in-depth architecture** with multiple security layers
36
- - **Zero-trust defaults** - all advanced features disabled by default
37
- - **Comprehensive audit logging** with configurable retention (90+ days)
38
- - **Rate limiting** with configurable thresholds and block periods
39
- - **Input sanitization** preventing injection attacks and path traversal
40
- - **Memory management** with automatic garbage collection and limits
41
- - **SOC 2, GDPR, HIPAA ready** with structured compliance reporting
42
-
43
- ### ๐Ÿค– AI Assistant Integration
44
- - **37+ Perforce operations** exposed through MCP protocol
45
- - **Structured JSON responses** for reliable AI parsing
46
- - **Non-interactive execution** - no user prompts or confirmations
47
- - **Error handling** with standardized error codes
48
- - **Context-aware operations** with automatic configuration detection
49
- - **Real-time monitoring** and compliance status reporting
50
-
51
- ### ๐Ÿข Enterprise Features
52
- - **Multi-tenant support** with per-operation rate limiting
53
- - **Centralized configuration** via environment variables
54
- - **Production monitoring** with memory and performance tracking
55
- - **Compliance reporting** with CSV/JSON export capabilities
56
- - **Automated resource management** preventing system overload
57
- - **Enterprise authentication** support through Perforce credentials
58
-
59
- ### ๐Ÿ”ง Developer Experience
60
- - **TypeScript first** with full type safety
61
- - **Comprehensive documentation** with examples and guides
62
- - **Cross-platform compatibility** - Windows, macOS, Linux
63
- - **Zero configuration setup** with sensible defaults
64
- - **Extensive testing** with automated component validation
65
- - **Open source** with community contributions welcome
66
-
67
- **Alternative to:**
68
- - Manual Perforce CLI operations in AI workflows
69
- - Custom Git-to-Perforce bridges for AI assistants
70
- - Unsafe direct P4 command execution in development environments
71
- - Complex Perforce API integrations for code assistants
72
-
73
- **Perfect for:**
74
- - Enterprise teams using Perforce with AI development tools
75
- - DevOps automation with Anthropic Claude or OpenAI ChatGPT
76
- - VS Code and Cursor IDE users working with Perforce repositories
77
- - Secure version control operations in AI-assisted coding workflows
78
- - Organizations requiring SOC 2, GDPR, or HIPAA compliance
79
- - Teams needing comprehensive audit trails and security monitoring
80
- - Enterprises with strict security policies and compliance requirements
81
-
82
- ## Why Choose MCP Perforce Server?
83
-
84
- ### ๐Ÿ›ก๏ธ **Enterprise-Grade Security**
85
- - **Defense-in-depth architecture** with multiple security layers
86
- - **Rate limiting** prevents abuse and ensures fair resource usage
87
- - **Comprehensive audit logging** with configurable retention policies
88
- - **Input sanitization** protects against injection attacks and malicious input
89
- - **Memory management** with automatic monitoring and garbage collection
90
- - **Read-only mode** for secure environments and compliance requirements
91
-
92
- ### ๐Ÿ“Š **Compliance Ready**
93
- - **SOC 2 Type II** compliance framework with automated reporting
94
- - **GDPR** compliance with data protection and privacy controls
95
- - **HIPAA** compliance for healthcare and sensitive data environments
96
- - **Compliance reporting tools** for audit preparation and regulatory requirements
97
- - **Data retention policies** configurable for different compliance needs
98
-
99
- ### ๐Ÿค– **AI-First Design**
100
- - **37+ Perforce operations** through standardized MCP protocol
101
- - **Non-interactive execution** perfect for AI assistants and automation
102
- - **Structured error handling** with detailed error codes and recovery suggestions
103
- - **Context-aware operations** that understand Perforce workflows
104
- - **Seamless integration** with Claude, ChatGPT, VS Code, and Cursor
105
-
106
- ### โšก **Production Ready**
107
- - **Zero-configuration setup** with automatic Perforce environment detection
108
- - **Cross-platform support** (Windows, macOS, Linux) for enterprise deployments
109
- - **Comprehensive error handling** with actionable error messages
110
- - **Performance optimized** with connection pooling and caching
111
- - **Enterprise authentication** support through Perforce credentials
112
-
113
- ### ๐Ÿ”ง **Developer Experience**
114
- - **TypeScript implementation** with full type safety and IntelliSense
115
- - **Comprehensive documentation** with examples and troubleshooting
116
- - **Modular architecture** for easy customization and extension
117
- - **Open source** with community contributions and transparent development
118
- - **Active maintenance** with regular updates and security patches
119
-
120
-
121
- ## Installation
122
-
123
- ```bash
124
- npm install -g mcp-perforce-server
125
- ```
126
-
127
- ## Quick Start
128
-
129
- 1. **Prerequisites:** Perforce CLI (`p4`) installed and in PATH
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
- [![Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](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
+ [![npm version](https://badge.fury.io/js/mcp-perforce-server.svg)](https://www.npmjs.com/package/mcp-perforce-server)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue)](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
+