mcp-perforce-server 3.0.0 → 3.2.0

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
@@ -4,25 +4,36 @@
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
  [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue)](https://www.typescriptlang.org/)
7
+ [![MCPAmpel](https://img.shields.io/endpoint?url=https://mcpampel.com/badge/iPraBhu/mcp-perforce-server.json)](https://mcpampel.com/repo/iPraBhu/mcp-perforce-server)
7
8
 
8
- MCP server for Perforce (P4) with safe defaults, fast execution, and structured JSON responses.
9
+ `mcp-perforce-server` is a Model Context Protocol server for Perforce (`p4`) with safe defaults, structured JSON responses, and both native-style and MCP-optimized workflows.
9
10
 
10
- > Developed with vibe coding for practical Perforce automation workflows.
11
+ It is designed for AI assistants and IDE integrations that need Perforce access without relying on brittle shell scripting.
11
12
 
12
- New to MCP servers? See [What is MCP (Model Context Protocol)?](https://adevguide.com/ai-engineering/llm-agents/what-is-mcp-model-context-protocol/).
13
+ ## What It Provides
13
14
 
14
- ## Workflow Speed
15
+ - 59 MCP tools across repository inspection, file operations, changelists, reviews, jobs, labels, streams, analytics, and compliance.
16
+ - Safe-by-default runtime behavior:
17
+ - `P4_READONLY_MODE=true`
18
+ - `P4_DISABLE_DELETE=true`
19
+ - Batch-capable inputs for the tool surface where native `p4` supports multi-target usage.
20
+ - MCP-specific composite helpers that reduce round trips for common review and search workflows.
21
+ - Structured responses with `ok`, `result`, optional `error`, optional `warnings`, and `configUsed`.
22
+ - Compatibility with both dot and underscore tool naming:
23
+ - `p4.changes`
24
+ - `p4_changes`
15
25
 
16
- This server includes composite tools that combine multiple Perforce calls into one request so review and sync workflows complete faster with fewer MCP round trips.
26
+ ## Highlighted Workflows
17
27
 
18
- - `p4.review.bundle`: pending review changelists with optional details and reviewers in one call
19
- - `p4.change.inspect`: changelist inspection bundle (`describe` + `fixes` + `reviews` + optional diff + optional `filelog`)
20
- - `p4.path.synccheck`: branch/path sync drift analysis (`interchanges` + optional `integrated`)
28
+ The server includes higher-level helpers on top of raw `p4` commands.
21
29
 
22
- To return actual changelist diff content via MCP:
23
-
24
- - `p4.describe` with `includeDiff=true` (optional `diffFormat`: `u`, `c`, `n`, `s`)
25
- - `p4.change.inspect` with `includeDiff=true`
30
+ - `p4.review.bundle`: pending review changelists with optional details and reviewers
31
+ - `p4.change.inspect`: `describe` + `fixes` + `reviews` + optional diff + optional file history
32
+ - `p4.path.synccheck`: drift and sync-state analysis between two depot paths
33
+ - `p4.file.inspect`: per-file metadata, history, optional content, and optional blame
34
+ - `p4.workspace.snapshot`: workspace info, status, optional config, opened files, and recent changes
35
+ - `p4.search.inspect`: grouped search results with optional file metadata and content previews
36
+ - `p4.review.prepare`: explicit or discovered changelists prepared into review-ready bundles
26
37
 
27
38
  ## Install
28
39
 
@@ -30,22 +41,29 @@ To return actual changelist diff content via MCP:
30
41
  npm install -g mcp-perforce-server
31
42
  ```
32
43
 
44
+ Requirements:
45
+
46
+ - Node.js 18+
47
+ - Perforce CLI available as `p4` or `p4.exe`
48
+ - Valid Perforce environment via `.p4config` or MCP `env`
49
+
33
50
  ## Quick Start
34
51
 
35
- 1. Make sure `p4` is installed and available in `PATH`.
36
- 2. Configure Perforce credentials using either `.p4config` in your workspace/project root, or MCP `env` variables.
37
- 3. Add MCP server config in your IDE/client.
52
+ 1. Install the Perforce CLI and ensure `p4` is on `PATH`.
53
+ 2. Configure Perforce credentials in `.p4config` or via MCP `env`.
54
+ 3. Add the server to your MCP client.
55
+ 4. Start in the default safe profile before enabling any write-capable tools.
38
56
 
39
- ### Example `.p4config`
57
+ Example `.p4config`:
40
58
 
41
59
  ```ini
42
- P4PORT=perforce-server:1666
60
+ P4PORT=ssl:perforce.example.com:1666
43
61
  P4USER=your-username
44
62
  P4CLIENT=your-workspace-name
45
- P4PASSWD=your-password
63
+ P4PASSWD=your-password-or-ticket
46
64
  ```
47
65
 
48
- ### Global Install MCP Config (Default Safe Profile)
66
+ Example MCP config using the globally installed server:
49
67
 
50
68
  ```json
51
69
  {
@@ -57,20 +75,7 @@ P4PASSWD=your-password
57
75
  }
58
76
  ```
59
77
 
60
- ### Local Repo MCP Config (Default Safe Profile)
61
-
62
- ```json
63
- {
64
- "mcpServers": {
65
- "perforce": {
66
- "command": "node",
67
- "args": ["/absolute/path/to/mcp-perforce-server/dist/server.js"]
68
- }
69
- }
70
- }
71
- ```
72
-
73
- ### MCP Config (Default Safe Profile + Credentials in `env`)
78
+ Example MCP config with explicit credentials:
74
79
 
75
80
  ```json
76
81
  {
@@ -81,33 +86,16 @@ P4PASSWD=your-password
81
86
  "P4PORT": "ssl:perforce.example.com:1666",
82
87
  "P4USER": "your-username",
83
88
  "P4CLIENT": "your-workspace-name",
84
- "P4PASSWD": "your-password-or-ticket"
85
- }
86
- }
87
- }
88
- }
89
- ```
90
-
91
- Defaults are already safe: `P4_READONLY_MODE=true` and `P4_DISABLE_DELETE=true` unless explicitly set to `false`.
92
-
93
- If you want to pin these explicitly in your client config:
94
-
95
- ```json
96
- {
97
- "mcpServers": {
98
- "perforce": {
99
- "command": "mcp-perforce-server",
100
- "env": {
89
+ "P4PASSWD": "your-password-or-ticket",
101
90
  "P4_READONLY_MODE": "true",
102
- "P4_DISABLE_DELETE": "true",
103
- "LOG_LEVEL": "error"
91
+ "P4_DISABLE_DELETE": "true"
104
92
  }
105
93
  }
106
94
  }
107
95
  }
108
96
  ```
109
97
 
110
- Windows `args` example:
98
+ Windows local-repo example:
111
99
 
112
100
  ```json
113
101
  {
@@ -120,86 +108,71 @@ Windows `args` example:
120
108
  }
121
109
  ```
122
110
 
123
- ## Default Access Model
111
+ ## Safety Model
112
+
113
+ The default runtime profile is conservative.
124
114
 
125
115
  | Setting | Default | Effect |
126
116
  |---|---|---|
127
- | `P4_READONLY_MODE` | `true` | Blocks all write-capable tools. |
117
+ | `P4_READONLY_MODE` | `true` | Blocks write-capable tools. |
128
118
  | `P4_DISABLE_DELETE` | `true` | Blocks `p4.delete` even when write mode is enabled. |
129
119
 
130
- Write-capable tools blocked when `P4_READONLY_MODE=true`:
120
+ Write-capable tools include:
121
+
122
+ - `p4.add`, `p4.edit`, `p4.delete`, `p4.revert`, `p4.sync`
123
+ - `p4.changelist.create`, `p4.changelist.update`, `p4.changelist.submit`, `p4.submit`
124
+ - `p4.resolve`, `p4.shelve`, `p4.unshelve`
125
+ - `p4.copy`, `p4.move`, `p4.integrate`, `p4.merge`
126
+
127
+ ## Tool Surface
128
+
129
+ Major categories:
130
+
131
+ - Repository and workspace inspection
132
+ - File operations and diffing
133
+ - Changelists and submissions
134
+ - Merge, shelving, and resolve flows
135
+ - Search and discovery
136
+ - Review and workflow composites
137
+ - Users, clients, streams, labels, jobs, and fixes
138
+ - Compliance, audit, and operational diagnostics
139
+
140
+ Notable native parity improvements:
131
141
 
132
- | Tool |
133
- |---|
134
- | `p4.add`, `p4.edit`, `p4.delete`, `p4.revert`, `p4.sync` |
135
- | `p4.changelist.create`, `p4.changelist.update`, `p4.changelist.submit`, `p4.submit` |
136
- | `p4.resolve`, `p4.shelve`, `p4.unshelve` |
137
- | `p4.copy`, `p4.move`, `p4.integrate`, `p4.merge` |
142
+ - Batch-style inputs for commands such as `sync`, `opened`, `filelog`, `annotate`, `grep`, `files`, `dirs`, `print`, `fstat`, `sizes`, `have`, `users`, `streams`, `jobs`, and `fixes`
143
+ - Expanded native flag coverage for tools such as `sync`, `interchanges`, `fstat`, `files`, `dirs`, `streams`, `clients`, `labels`, `jobs`, and `sizes`
144
+ - Support for both workspace-facing and depot-to-depot diffing via `p4.diff` and `p4.diff2`
138
145
 
139
- ## Server Configuration Reference
146
+ ## Configuration
140
147
 
141
- ### Runtime, Safety, and Performance
148
+ Most installations only need a small set of variables.
142
149
 
143
- | Variable | Default | Description |
150
+ | Variable | Default | Purpose |
144
151
  |---|---|---|
145
- | `P4_READONLY_MODE` | `true` | Read-only by default. Set to `false` to enable write-capable tools. |
146
- | `P4_DISABLE_DELETE` | `true` | Delete operations are disabled by default. Set to `false` to allow `p4.delete`. |
147
- | `P4_PATH` | `p4` / `p4.exe` | Custom path to Perforce CLI executable. |
148
- | `P4CONFIG` | `.p4config` | `.p4config` file name used for upward discovery. |
149
- | `LOG_LEVEL` | `warn` | Logging level: `error`, `warn`, `info`, `debug`. |
150
- | `P4_PRETTY_JSON` | `false` | Pretty-print JSON responses when `true`. |
152
+ | `P4_READONLY_MODE` | `true` | Keep the server read-only by default. |
153
+ | `P4_DISABLE_DELETE` | `true` | Prevent delete operations unless explicitly enabled. |
154
+ | `P4CONFIG` | `.p4config` | Config file name used during upward discovery. |
155
+ | `P4_PATH` | `p4` / `p4.exe` | Custom path to the Perforce CLI. |
151
156
  | `P4_PERFORMANCE_MODE` | `fast` | Preset: `fast`, `balanced`, `secure`. |
152
- | `P4_TIMEOUT_MS` | `5000` / `10000` / `15000` | Command timeout in ms (`fast` / `balanced` / `secure`). |
153
- | `P4_CONFIG_CACHE_TTL` | `600000` / `300000` / `300000` | `.p4config` cache TTL in ms (`fast` / `balanced` / `secure`). |
154
- | `P4_RESPONSE_CACHE` | `true` | Enable/disable read-result response cache. |
155
- | `P4_RESPONSE_CACHE_TTL_MS` | `5000` / `3000` / `1000` | Response cache TTL in ms (`fast` / `balanced` / `secure`). |
156
- | `P4_RESPONSE_CACHE_TTL_MAP` | unset | Per-tool cache TTL overrides (for example `p4.info=30000,p4.review=2000`). |
157
- | `P4_RESPONSE_CACHE_MAX_ENTRIES` | `400` / `250` / `100` | Max cached read responses (`fast` / `balanced` / `secure`). |
158
- | `P4_NEGATIVE_CACHE` | `true` | Cache predictable read errors for a short TTL to avoid repeated retries. |
159
- | `P4_NEGATIVE_CACHE_TTL_MS` | `5000` | Negative-cache TTL in milliseconds. |
160
- | `P4_WORKFLOW_CONCURRENCY` | `6` | Max concurrent subcalls used by composite workflow tools. |
161
- | `P4_LOG_PERF_METRICS` | `false` | Enable periodic performance snapshots (cache hit rate, p50/p95 latency, subcall totals). |
162
- | `P4_LOG_PERF_METRICS_INTERVAL_MS` | `60000` | Interval for performance snapshot logs in milliseconds. |
163
- | `P4_PERF_METRICS_SAMPLE_SIZE` | `200` | Rolling sample size per tool used to compute p50/p95 latency. |
164
- | `P4_ENABLE_AUDIT_LOGGING` | `false` / `false` / `true` | Override audit logging (`fast` / `balanced` / `secure`). |
165
- | `P4_ENABLE_RATE_LIMITING` | `false` / `false` / `true` | Override rate limiting (`fast` / `balanced` / `secure`). |
166
- | `P4_ENABLE_MEMORY_LIMITS` | `false` / `true` / `true` | Override memory-limit checks (`fast` / `balanced` / `secure`). |
167
- | `P4_ENABLE_INPUT_SANITIZATION` | `true` | Input sanitization is enabled unless set to `false`. |
168
- | `P4_MAX_MEMORY_MB` | `512` | Memory limit for command execution and checks. |
169
- | `P4_AUDIT_RETENTION_DAYS` | `90` | Number of days audit entries are retained. |
170
- | `P4_RATE_LIMIT_REQUESTS` | `100` | Max requests per rate-limit window. |
171
- | `P4_RATE_LIMIT_WINDOW_MS` | `600000` | Rate-limit window in milliseconds. |
172
- | `P4_RATE_LIMIT_BLOCK_MS` | `3600000` | Block duration in milliseconds after exceeding limit. |
173
-
174
- ### Perforce Connection Variables
175
-
176
- | Variable | Required | Description |
177
- |---|---|---|
178
- | `P4PORT` | Yes | Perforce server address (for example `ssl:perforce.example.com:1666`). |
179
- | `P4USER` | Yes | Perforce username. |
180
- | `P4CLIENT` | Yes | Perforce client/workspace name. |
181
- | `P4PASSWD` | No | Password or ticket (masked in server output). |
182
- | `P4CHARSET` | No | Character set (for example `utf8`). |
183
- | `P4COMMANDCHARSET` | No | Command charset override. |
184
- | `P4LANGUAGE` | No | Localized language setting. |
185
- | `P4DIFF` | No | Custom diff tool command. |
186
- | `P4MERGE` | No | Custom merge tool command. |
187
- | `P4EDITOR` | No | Editor for changelist descriptions/spec forms. |
188
-
189
- ## Tool Coverage
190
-
191
- - 55 MCP tools covering repository info, file operations, changelists, merge/resolve, review workflows, workflow composites, search, users/clients, jobs, labels/streams, analytics, and compliance.
192
- - Composite workflow tools are included to reduce request count and speed up common review/sync flows.
193
- - Includes both:
194
- - `p4.diff` for workspace/local vs depot diff.
195
- - `p4.diff2` for depot-to-depot server-side diff.
157
+ | `P4_WORKFLOW_CONCURRENCY` | `6` | Max concurrent subcalls for composite tools. |
158
+ | `P4_RESPONSE_CACHE` | `true` | Enable read-response caching. |
159
+ | `P4_RESPONSE_CACHE_TTL_MAP` | unset | Per-tool cache TTL overrides. |
160
+ | `LOG_LEVEL` | `warn` | Server log level. |
196
161
 
197
- ## Documentation
162
+ Perforce connection variables:
198
163
 
199
- - Detailed tool reference: [docs/TOOLS_REFERENCE.md](docs/TOOLS_REFERENCE.md)
200
- - Docs index: [docs/README.md](docs/README.md)
201
- - IDE/client setup examples: [MCP_CONFIG_EXAMPLES.md](MCP_CONFIG_EXAMPLES.md)
202
- - Perforce setup notes: [PERFORCE_SETUP.md](PERFORCE_SETUP.md)
164
+ - `P4PORT`
165
+ - `P4USER`
166
+ - `P4CLIENT`
167
+ - `P4PASSWD`
168
+ - `P4CHARSET`
169
+ - `P4COMMANDCHARSET`
170
+ - `P4LANGUAGE`
171
+
172
+ For full configuration tables and examples, see:
173
+
174
+ - [PERFORCE_SETUP.md](PERFORCE_SETUP.md)
175
+ - [MCP_CONFIG_EXAMPLES.md](MCP_CONFIG_EXAMPLES.md)
203
176
 
204
177
  ## Development
205
178
 
@@ -210,6 +183,21 @@ npm test
210
183
  npm run test:integration
211
184
  ```
212
185
 
186
+ Current verification baseline:
187
+
188
+ - `npm run build`
189
+ - `npm test`
190
+ - `npm run test:integration`
191
+
192
+ ## Documentation
193
+
194
+ - Tool catalog and descriptions: [AGENTS.md](AGENTS.md)
195
+ - Docs index: [docs/README.md](docs/README.md)
196
+ - Perforce setup: [PERFORCE_SETUP.md](PERFORCE_SETUP.md)
197
+ - MCP client config examples: [MCP_CONFIG_EXAMPLES.md](MCP_CONFIG_EXAMPLES.md)
198
+ - Publishing workflow: [PUBLISHING.md](PUBLISHING.md)
199
+ - Release notes draft: [RELEASE_NOTES.md](RELEASE_NOTES.md)
200
+
213
201
  ## License
214
202
 
215
- MIT
203
+ MIT
package/dist/p4/parse.js CHANGED
@@ -249,7 +249,7 @@ function parseInterchangesOutput(output) {
249
249
  }
250
250
  continue;
251
251
  }
252
- const headerMatch = line.match(/^Change\s+(\d+)\s+on\s+(\S+)\s+by\s+(.+?)@(.+?)(?:\s+'(.*)')?$/);
252
+ const headerMatch = line.match(/^Change\s+(\d+)\s+on\s+(.+?)\s+by\s+(.+?)@(.+?)(?:\s+'(.*)')?$/);
253
253
  if (headerMatch) {
254
254
  finalizeCurrent();
255
255
  const [, change, date, user, client, description] = headerMatch;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AA4OA,cAAM,iBAAiB;IACrB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyC;IACpE,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA6C;IAClF,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAyE;IAC5G,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAGtC;IACF,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAqE;IAC/G,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA6C;IAClF,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAGjC;IACF,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAMzC;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiC;IAC/D,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAuC;IAC5E,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA2C;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