mcp-perforce-server 2.0.1 โ†’ 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.
Files changed (45) hide show
  1. package/LICENSE +20 -20
  2. package/MCP_CONFIG_EXAMPLES.md +222 -222
  3. package/README.md +130 -515
  4. package/dist/p4/config.d.ts +2 -0
  5. package/dist/p4/config.d.ts.map +1 -1
  6. package/dist/p4/config.js +60 -31
  7. package/dist/p4/config.js.map +1 -1
  8. package/dist/p4/parse.d.ts +56 -28
  9. package/dist/p4/parse.d.ts.map +1 -1
  10. package/dist/p4/parse.js +462 -29
  11. package/dist/p4/parse.js.map +1 -1
  12. package/dist/p4/runner.d.ts +2 -0
  13. package/dist/p4/runner.d.ts.map +1 -1
  14. package/dist/p4/runner.js +266 -35
  15. package/dist/p4/runner.js.map +1 -1
  16. package/dist/p4/security.d.ts +2 -0
  17. package/dist/p4/security.d.ts.map +1 -1
  18. package/dist/p4/security.js +61 -29
  19. package/dist/p4/security.js.map +1 -1
  20. package/dist/performance.d.ts +47 -0
  21. package/dist/performance.d.ts.map +1 -0
  22. package/dist/performance.js +67 -0
  23. package/dist/performance.js.map +1 -0
  24. package/dist/server.d.ts +15 -0
  25. package/dist/server.d.ts.map +1 -1
  26. package/dist/server.js +418 -135
  27. package/dist/server.js.map +1 -1
  28. package/dist/tools/advanced.js +1 -1
  29. package/dist/tools/advanced.js.map +1 -1
  30. package/dist/tools/basic.d.ts +58 -0
  31. package/dist/tools/basic.d.ts.map +1 -1
  32. package/dist/tools/basic.js +492 -60
  33. package/dist/tools/basic.js.map +1 -1
  34. package/dist/tools/changelist.d.ts +1 -1
  35. package/dist/tools/changelist.d.ts.map +1 -1
  36. package/dist/tools/changelist.js +36 -6
  37. package/dist/tools/changelist.js.map +1 -1
  38. package/dist/tools/index.d.ts +1 -1
  39. package/dist/tools/index.d.ts.map +1 -1
  40. package/dist/tools/index.js +8 -1
  41. package/dist/tools/index.js.map +1 -1
  42. package/dist/tools/utils.d.ts.map +1 -1
  43. package/dist/tools/utils.js +24 -3
  44. package/dist/tools/utils.js.map +1 -1
  45. package/package.json +114 -114
package/README.md CHANGED
@@ -1,515 +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 by [Pratik Bhuite](https://github.com/iPraBhu)** 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
- - ๐ŸŒ **Cross-platform Support** - Windows, macOS, Linux compatibility
24
- - ๐Ÿค– **AI Integration** - Works with Claude, ChatGPT, VS Code, Cursor, and other AI assistants
25
- - โšก **Non-interactive Operations** - Automated Perforce commands with comprehensive error handling
26
- - ๐Ÿ“ **Multi-project Support** - Automatic `.p4config` detection with upward directory search
27
- - ๐Ÿ›ก๏ธ **Production Ready** - Structured JSON responses with standardized error codes
28
- - ๐Ÿ”ง **Developer Friendly** - TypeScript support with comprehensive documentation
29
- - ๐Ÿš€ **Zero Configuration** - Works out-of-the-box with sensible defaults
30
-
31
- ## Core Capabilities
32
-
33
- ### ๐Ÿ”’ Security & Compliance
34
- - **Defense-in-depth architecture** with multiple security layers
35
- - **Zero-trust defaults** - all advanced features disabled by default
36
- - **Comprehensive audit logging** with configurable retention (90+ days)
37
- - **Rate limiting** with configurable thresholds and block periods
38
- - **Input sanitization** preventing injection attacks and path traversal
39
- - **Memory management** with automatic garbage collection and limits
40
- - **SOC 2, GDPR, HIPAA ready** with structured compliance reporting
41
-
42
- ### ๐Ÿค– AI Assistant Integration
43
- - **37+ Perforce operations** exposed through MCP protocol
44
- - **Structured JSON responses** for reliable AI parsing
45
- - **Non-interactive execution** - no user prompts or confirmations
46
- - **Error handling** with standardized error codes
47
- - **Context-aware operations** with automatic configuration detection
48
- - **Real-time monitoring** and compliance status reporting
49
-
50
- ### ๐Ÿข Enterprise Features
51
- - **Multi-tenant support** with per-operation rate limiting
52
- - **Centralized configuration** via environment variables
53
- - **Production monitoring** with memory and performance tracking
54
- - **Compliance reporting** with CSV/JSON export capabilities
55
- - **Automated resource management** preventing system overload
56
- - **Enterprise authentication** support through Perforce credentials
57
-
58
- ### ๐Ÿ”ง Developer Experience
59
- - **TypeScript first** with full type safety
60
- - **Comprehensive documentation** with examples and guides
61
- - **Cross-platform compatibility** - Windows, macOS, Linux
62
- - **Zero configuration setup** with sensible defaults
63
- - **Extensive testing** with automated component validation
64
- - **Open source** with community contributions welcome
65
-
66
- **Alternative to:**
67
- - Manual Perforce CLI operations in AI workflows
68
- - Custom Git-to-Perforce bridges for AI assistants
69
- - Unsafe direct P4 command execution in development environments
70
- - Complex Perforce API integrations for code assistants
71
-
72
- **Perfect for:**
73
- - Enterprise teams using Perforce with AI development tools
74
- - DevOps automation with Anthropic Claude or OpenAI ChatGPT
75
- - VS Code and Cursor IDE users working with Perforce repositories
76
- - Secure version control operations in AI-assisted coding workflows
77
- - Organizations requiring SOC 2, GDPR, or HIPAA compliance
78
- - Teams needing comprehensive audit trails and security monitoring
79
- - Enterprises with strict security policies and compliance requirements
80
-
81
- ## Why Choose MCP Perforce Server?
82
-
83
- ### ๐Ÿ›ก๏ธ **Enterprise-Grade Security**
84
- - **Defense-in-depth architecture** with multiple security layers
85
- - **Rate limiting** prevents abuse and ensures fair resource usage
86
- - **Comprehensive audit logging** with configurable retention policies
87
- - **Input sanitization** protects against injection attacks and malicious input
88
- - **Memory management** with automatic monitoring and garbage collection
89
- - **Read-only mode** for secure environments and compliance requirements
90
-
91
- ### ๐Ÿ“Š **Compliance Ready**
92
- - **SOC 2 Type II** compliance framework with automated reporting
93
- - **GDPR** compliance with data protection and privacy controls
94
- - **HIPAA** compliance for healthcare and sensitive data environments
95
- - **Compliance reporting tools** for audit preparation and regulatory requirements
96
- - **Data retention policies** configurable for different compliance needs
97
-
98
- ### ๐Ÿค– **AI-First Design**
99
- - **37+ Perforce operations** through standardized MCP protocol
100
- - **Non-interactive execution** perfect for AI assistants and automation
101
- - **Structured error handling** with detailed error codes and recovery suggestions
102
- - **Context-aware operations** that understand Perforce workflows
103
- - **Seamless integration** with Claude, ChatGPT, VS Code, and Cursor
104
-
105
- ### โšก **Production Ready**
106
- - **Zero-configuration setup** with automatic Perforce environment detection
107
- - **Cross-platform support** (Windows, macOS, Linux) for enterprise deployments
108
- - **Comprehensive error handling** with actionable error messages
109
- - **Performance optimized** with connection pooling and caching
110
- - **Enterprise authentication** support through Perforce credentials
111
-
112
- ### ๐Ÿ”ง **Developer Experience**
113
- - **TypeScript implementation** with full type safety and IntelliSense
114
- - **Comprehensive documentation** with examples and troubleshooting
115
- - **Modular architecture** for easy customization and extension
116
- - **Open source** with community contributions and transparent development
117
- - **Active maintenance** with regular updates and security patches
118
-
119
- ## Origin Story
120
-
121
- This project was born from a real need! I was facing challenges integrating Perforce with AI development tools and decided to solve it using **vibe coding** - building something that just works, feels right, and solves real problems.
122
-
123
- **๐Ÿค Community Welcome**
124
- - โœ… **Use freely** - This is open source, use it however you need
125
- - ๐Ÿ› **Report issues** - Found a bug? Please let me know!
126
- - ๐Ÿ”ง **Customize** - Fork it, modify it, make it yours
127
- - ๐Ÿ’ก **Contribute** - Ideas, PRs, and feedback are always welcome
128
-
129
- ## Installation
130
-
131
- ```bash
132
- npm install -g mcp-perforce-server
133
- ```
134
-
135
- ## Quick Start
136
-
137
- 1. **Prerequisites:** Perforce CLI (`p4`) installed and in PATH
138
-
139
- 2. **Configuration:** Choose one method:
140
-
141
- **Method A: .p4config file** (Recommended)
142
- ```
143
- P4PORT=your-perforce-server:1666
144
- P4USER=your-username
145
- P4CLIENT=your-workspace-name
146
- P4PASSWD=your-password
147
- ```
148
-
149
- **Method B: MCP Environment Variables**
150
- ```json
151
- {
152
- "mcpServers": {
153
- "perforce": {
154
- "command": "mcp-perforce-server",
155
- "env": {
156
- "P4PORT": "your-perforce-server:1666",
157
- "P4USER": "your-username",
158
- "P4CLIENT": "your-workspace-name",
159
- "P4PASSWD": "your-password"
160
- }
161
- }
162
- }
163
- }
164
- ```
165
-
166
- 3. **Verification:**
167
- ```bash
168
- mcp-perforce-server --help
169
- ```
170
-
171
- ## Authentication Configuration
172
-
173
- The server supports multiple methods for providing Perforce credentials, prioritized in this order:
174
-
175
- ### 1. **Environment Variables** (Highest Priority)
176
- Set `P4PASSWD` along with other Perforce environment variables:
177
-
178
- ```bash
179
- export P4PORT=perforce-server:1666
180
- export P4USER=your-username
181
- export P4CLIENT=your-workspace-name
182
- export P4PASSWD=your-password
183
- ```
184
-
185
- ### 2. **`.p4config` File** (Recommended)
186
- Create a `.p4config` file in your project root:
187
-
188
- ```ini
189
- P4PORT=perforce-server:1666
190
- P4USER=your-username
191
- P4CLIENT=your-workspace-name
192
- P4PASSWD=your-password
193
- ```
194
-
195
- The server automatically searches upward from the current directory to find this file.
196
-
197
- ### 3. **MCP Configuration**
198
- Include credentials in your MCP server configuration (see examples above).
199
-
200
- **Security Notes:**
201
- - Passwords are **masked** (`***masked***`) in all logs
202
- - The system operates **non-interactively** - no password prompts
203
- - Authentication failures return `P4_AUTH_FAILED` error code
204
- - For production, prefer `.p4config` files or secure environment variables
205
-
206
- ## Security Configuration
207
-
208
- **Default Security Posture:**
209
- - `P4_READONLY_MODE=true` - Read-only operations only
210
- - `P4_DISABLE_DELETE=true` - Delete operations disabled
211
-
212
- **Production Environments:**
213
- ```bash
214
- # Read-only mode (safest)
215
- P4_READONLY_MODE=true P4_DISABLE_DELETE=true
216
-
217
- # Write-enabled, delete-protected (recommended)
218
- P4_READONLY_MODE=false P4_DISABLE_DELETE=true
219
-
220
- # Full access (use with caution)
221
- P4_READONLY_MODE=false P4_DISABLE_DELETE=false
222
- ```
223
-
224
- ## Compliance & Security Features
225
-
226
- **Enterprise-Grade Security Suite:**
227
- - ๐Ÿ” **Audit Logging** - Complete operation tracking with retention policies
228
- - ๐Ÿšฆ **Rate Limiting** - Configurable request throttling with block periods
229
- - ๐Ÿงน **Input Sanitization** - Regex validation and path traversal protection
230
- - ๐Ÿ’พ **Memory Limits** - Process memory monitoring and automatic GC
231
- - ๐Ÿ“Š **Compliance Reporting** - SOC 2, GDPR, HIPAA-ready architecture
232
-
233
- **New Compliance Tools:**
234
- - `p4.audit` - Query audit logs with filtering and CSV export
235
- - `p4.compliance` - View compliance configuration and system status
236
-
237
- **Compliance Configuration:**
238
- ```bash
239
- # Enable enterprise features
240
- P4_ENABLE_AUDIT_LOGGING=true
241
- P4_ENABLE_RATE_LIMITING=true
242
- P4_ENABLE_MEMORY_LIMITS=true
243
- P4_ENABLE_INPUT_SANITIZATION=true
244
-
245
- # Compliance tuning
246
- P4_MAX_MEMORY_MB=1024
247
- P4_AUDIT_RETENTION_DAYS=365
248
- P4_RATE_LIMIT_REQUESTS=100
249
- P4_RATE_LIMIT_WINDOW_MS=600000
250
- P4_RATE_LIMIT_BLOCK_MS=3600000
251
- ```
252
-
253
- **Security Architecture:**
254
- - โœ… **Defense-in-depth** - Multiple security layers
255
- - โœ… **Zero-trust defaults** - Everything disabled by default
256
- - โœ… **Structured logging** - JSON audit trails
257
- - โœ… **Input validation** - Regex and path sanitization
258
- - โœ… **Resource limits** - Memory and rate controls
259
- - โœ… **GDPR/HIPAA Ready** - No personal data storage
260
-
261
- ## Supported Operations
262
-
263
- ### Repository Operations
264
- - `p4.info` - Server and client information
265
- - `p4.status` - Workspace status
266
- - `p4.sync` - Sync from depot
267
- - `p4.opened` - List opened files
268
- - `p4.have` - List synced files
269
- - `p4.where` - Show file mappings
270
-
271
- ### File Operations
272
- - `p4.add` - Add files to Perforce
273
- - `p4.edit` - Open files for edit
274
- - `p4.delete` - Mark files for deletion
275
- - `p4.revert` - Revert changes
276
- - `p4.diff` - Show file differences
277
- - `p4.copy` - Copy files between locations
278
- - `p4.move` - Move/rename files
279
- - `p4.blame` - Show file annotations (like git blame)
280
-
281
- ### Merge & Conflict Resolution
282
- - `p4.resolve` - Resolve merge conflicts
283
- - `p4.shelve` - Shelve files for code review
284
- - `p4.unshelve` - Unshelve files from review
285
-
286
- ### Changelist Operations
287
- - `p4.changelist.create` - Create new changelist
288
- - `p4.changelist.update` - Update changelist
289
- - `p4.changelist.submit` - Submit changelist
290
- - `p4.submit` - Submit default changelist
291
- - `p4.describe` - Describe changelist details
292
- - `p4.changes` - List changelists with filtering
293
-
294
- ### Search & Discovery
295
- - `p4.grep` - Search text patterns across files
296
- - `p4.files` - List files in depot with metadata
297
- - `p4.dirs` - List directories in depot
298
- - `p4.filelog` - File history
299
-
300
- ### User & Client Management
301
- - `p4.users` - List Perforce users
302
- - `p4.user` - Get user information
303
- - `p4.clients` - List workspaces
304
- - `p4.client` - Get workspace details
305
-
306
- ### Job & Issue Tracking
307
- - `p4.jobs` - List jobs (if enabled)
308
- - `p4.job` - Get job details
309
- - `p4.fixes` - Show changelist-job relationships
310
-
311
- ### Labels & Organization
312
- - `p4.labels` - List labels
313
- - `p4.label` - Get label details
314
-
315
- ### Analytics & Monitoring
316
- - `p4.sizes` - File size and disk usage statistics
317
- - `p4.audit` - Audit log queries and compliance reporting
318
- - `p4.compliance` - Compliance configuration and status
319
-
320
- ### Utilities
321
- - `p4.config.detect` - Configuration diagnostics
322
-
323
- ## Integration
324
-
325
- ### VS Code / Cursor
326
- For silent operation without approval prompts, add these settings:
327
- ```json
328
- {
329
- "mcpServers": {
330
- "perforce": {
331
- "command": "mcp-perforce-server",
332
- "env": {
333
- "P4_READONLY_MODE": "false",
334
- "LOG_LEVEL": "error"
335
- },
336
- "alwaysAllow": ["p4.*"],
337
- "disabled": false
338
- }
339
- }
340
- }
341
- ```
342
-
343
- See [MCP_CONFIG_EXAMPLES.md](MCP_CONFIG_EXAMPLES.md) for IDE-specific configuration.
344
-
345
- ### Claude Desktop
346
- Add to `claude_desktop_config.json`:
347
- ```json
348
- {
349
- "mcpServers": {
350
- "perforce": {
351
- "command": "mcp-perforce-server",
352
- "env": {
353
- "P4_READONLY_MODE": "false"
354
- }
355
- }
356
- }
357
- }
358
- ```
359
-
360
- ## Environment Variables
361
-
362
- | Variable | Description | Default |
363
- |----------|-------------|---------|
364
- | `P4_READONLY_MODE` | Enable read-only mode | `true` |
365
- | `P4_DISABLE_DELETE` | Disable delete operations | `true` |
366
- | `P4_PATH` | Path to p4 executable | `p4` |
367
- | `P4CONFIG` | Config file name | `.p4config` |
368
- | `LOG_LEVEL` | Logging level | `warn` |
369
- | `P4_ENABLE_AUDIT_LOGGING` | Enable audit logging | `false` |
370
- | `P4_ENABLE_RATE_LIMITING` | Enable rate limiting | `true` |
371
- | `P4_ENABLE_MEMORY_LIMITS` | Enable memory limits | `true` |
372
- | `P4_ENABLE_INPUT_SANITIZATION` | Enable input sanitization | `true` |
373
- | `P4_MAX_MEMORY_MB` | Memory limit in MB | `512` |
374
- | `P4_AUDIT_RETENTION_DAYS` | Audit log retention days | `90` |
375
- | `P4_RATE_LIMIT_REQUESTS` | Max requests per window | `100` |
376
- | `P4_RATE_LIMIT_WINDOW_MS` | Rate limit window ms | `600000` |
377
- | `P4_RATE_LIMIT_BLOCK_MS` | Rate limit block duration ms | `3600000` |
378
-
379
- ## Error Handling
380
-
381
- Standardized error codes for reliable error handling:
382
- - `P4_NOT_FOUND` - Perforce executable not found
383
- - `P4_AUTH_FAILED` - Authentication failure
384
- - `P4_CLIENT_UNKNOWN` - Unknown workspace
385
- - `P4_CONNECTION_FAILED` - Server connection failed
386
- - `P4_READONLY_MODE` - Operation blocked by read-only mode
387
- - `P4_DELETE_DISABLED` - Delete operation blocked
388
- - `P4_INVALID_ARGS` - Invalid arguments or input sanitization failure
389
- - `P4_MEMORY_LIMIT` - Memory limit exceeded
390
- - `P4_AUDIT_DISABLED` - Audit logging not enabled
391
- - `RATE_LIMIT_EXCEEDED` - Rate limit exceeded
392
- - `RATE_LIMIT_EXCEEDED` - Rate limit exceeded
393
-
394
- ## Architecture
395
-
396
- ### ๐Ÿ—๏ธ **System Overview**
397
- ```
398
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
399
- โ”‚ AI Assistant โ”‚โ”€โ”€โ”€โ”€โ”‚ MCP Protocol โ”‚โ”€โ”€โ”€โ”€โ”‚ MCP Perforce โ”‚
400
- โ”‚ (Claude/GPT) โ”‚ โ”‚ (JSON-RPC 2.0) โ”‚ โ”‚ Server โ”‚
401
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
402
- โ”‚ โ”‚ โ”‚
403
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
404
- โ”‚
405
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
406
- โ”‚ Perforce CLI โ”‚
407
- โ”‚ (p4) โ”‚
408
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
409
- ```
410
-
411
- ### ๐Ÿ”ง **Core Components**
412
-
413
- #### **Security Module (`src/p4/security.ts`)**
414
- - **Rate Limiting**: Token bucket algorithm with configurable limits
415
- - **Audit Logging**: Structured logging with retention policies
416
- - **Input Sanitization**: Regex-based validation and escaping
417
- - **Memory Management**: Automatic monitoring and garbage collection
418
- - **Compliance Reporting**: SOC 2, GDPR, HIPAA compliance tools
419
-
420
- #### **Server Core (`src/server.ts`)**
421
- - **MCP Protocol Handler**: JSON-RPC 2.0 implementation
422
- - **Tool Registry**: 37+ Perforce operations with security validation
423
- - **Request Processing**: Async handling with error recovery
424
- - **Configuration Management**: Environment variable processing
425
-
426
- #### **Tool Modules (`src/tools/`)**
427
- - **Basic Operations**: Core Perforce commands (add, edit, submit)
428
- - **Advanced Operations**: Complex workflows (merge, integrate, resolve)
429
- - **Changelist Management**: CL creation, modification, and tracking
430
- - **Search & Discovery**: File finding, history, and metadata queries
431
- - **User Management**: Client specs, user info, and permissions
432
- - **Analytics**: Repository statistics and monitoring
433
-
434
- #### **Perforce Integration (`src/p4/`)**
435
- - **Command Execution**: Secure child_process spawning
436
- - **Output Parsing**: Structured data extraction from p4 output
437
- - **Environment Detection**: Automatic .p4config and credential discovery
438
- - **Error Handling**: Comprehensive error classification and reporting
439
-
440
- ### ๐Ÿ›ก๏ธ **Security Architecture**
441
-
442
- #### **Defense in Depth**
443
- 1. **Input Validation**: All inputs sanitized before processing
444
- 2. **Rate Limiting**: Prevents abuse and resource exhaustion
445
- 3. **Audit Logging**: Complete operation traceability
446
- 4. **Memory Protection**: Automatic monitoring and limits
447
- 5. **Read-Only Mode**: Safe defaults for sensitive environments
448
-
449
- #### **Compliance Framework**
450
- - **SOC 2 Type II**: Automated controls and reporting
451
- - **GDPR**: Data protection and privacy controls
452
- - **HIPAA**: Healthcare data handling compliance
453
- - **Custom Policies**: Configurable retention and access controls
454
-
455
- ### ๐Ÿ“Š **Data Flow**
456
- ```
457
- User Request โ†’ MCP Protocol โ†’ Security Validation โ†’ Tool Execution โ†’ Perforce CLI โ†’ Response
458
- โ†“ โ†“ โ†“ โ†“ โ†“ โ†“
459
- Sanitize Authenticate Rate Check Command Execute Format
460
- ```
461
-
462
- ### ๐Ÿ”„ **Integration Patterns**
463
- - **VS Code Extension**: Direct MCP integration via configuration
464
- - **Claude Desktop**: App-specific MCP server configuration
465
- - **Custom Clients**: Standard JSON-RPC 2.0 protocol support
466
- - **Enterprise Deployments**: Docker/containerized execution
467
-
468
- ## Development
469
-
470
- ```bash
471
- # Local development
472
- git clone https://github.com/iPraBhu/mcp-perforce-server.git
473
- cd mcp-perforce-server
474
- npm install
475
- npm run build
476
-
477
- # Run tests
478
- npm test
479
-
480
- # Development mode
481
- npm run watch
482
- ```
483
-
484
- ## Contributing
485
-
486
- This project was created with โค๏ธ by [Pratik Bhuite](https://github.com/iPraBhu) to solve real Perforce automation challenges.
487
-
488
- **Ways to contribute:**
489
- - ๐Ÿ› **Report bugs** - Open an issue if something's not working
490
- - ๐Ÿ’ก **Suggest features** - Have an idea? Let's discuss it!
491
- - ๐Ÿ”ง **Submit PRs** - Code contributions are welcome
492
- - ๐Ÿ“– **Improve docs** - Help make the documentation better
493
- - โญ **Star the repo** - Show your support!
494
-
495
- **Found this useful?** Consider giving it a star โญ and sharing with others who might benefit!
496
-
497
- ## Support This Project
498
-
499
- โ˜• **Enjoying this tool?** [Buy me a coffee on Ko-fi](https://ko-fi.com/adevguide) to support continued development and new features!
500
-
501
- [![Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/adevguide)
502
-
503
- ## Security
504
-
505
- This project follows security best practices:
506
- - ๐Ÿ”’ **Dependencies**: Regularly updated to latest secure versions
507
- - ๐Ÿ›ก๏ธ **Default Safety**: Read-only mode and delete protection by default
508
- - ๐Ÿ” **Audit**: Run `npm run audit-fix` to check for vulnerabilities
509
- - ๐Ÿ“ข **Report Issues**: Security issues? Please report privately via GitHub
510
-
511
- ## License
512
-
513
- MIT License - Feel free to use, modify, and distribute as needed. See [LICENSE](LICENSE) for details.
514
-
515
- **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
+
@@ -11,6 +11,8 @@ export interface P4ServerConfig {
11
11
  }
12
12
  export declare class P4Config {
13
13
  private static readonly DEFAULT_CONFIG_NAME;
14
+ private configCache;
15
+ private readonly CACHE_TTL;
14
16
  /**
15
17
  * Find .p4config file by searching upward from the given directory
16
18
  */
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/p4/config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC,MA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