by perforce
Provides a Model Context Protocol server that integrates with Perforce P4, exposing safe, structured read/write tools for changelists, files, shelves, workspaces, jobs, reviews, and server metadata.
A Model Context Protocol server that bridges AI‑enabled tools with the Perforce P4 version‑control system, allowing programs to query and manipulate P4 entities such as files, changelists, shelves, workspaces, jobs, and code reviews.
build.sh / build.bat scripts.P4PORT, P4USER, P4CLIENT) or reference a P4CONFIG file../p4-mcp-server --readonly --allow-usage
--readonly flag to enable writes safely.--toolsets to enable only needed categories.logs/ and optional, consent‑gated telemetry (--allow-usage).p4 commands.Q: Do I need Python installed? A: Only when building from source. Pre‑built binaries run without any Python runtime.
Q: Can I run the server on Linux? A: Direct binaries are provided for macOS and Windows. Linux users can build from source or use the Docker image.
Q: Is data sent to Perforce? A: No file contents or personal data are transmitted. Telemetry (when enabled) only includes anonymous usage counts and server version.
Q: How do I enable write operations?
A: Omit the --readonly flag when starting the server and ensure the P4 user has appropriate permissions.
Q: What if my workspace has a host restriction?
A: When using Docker, set the container hostname to match the workspace’s Host: field and mount the workspace root at the exact path inside the container.
logs/ directory.| Component | Supported Versions |
|---|---|
| Operating Systems | Windows 10+macOS 12+Ubuntu 20.04+ |
| Perforce P4 Server | 2025.2 (earlier versions untested) |
| Python | 3.11+ (required only for building from source) |
Download the appropriate binary for your operating system:
Extract and use the executable directly. No Python installation is required.
# Windows
unzip p4-mcp-server-2025.2.0.zip
cd p4-mcp-server-2025.2.0
./p4-mcp-server.exe --help
# macOS
tar -xzf p4-mcp-server-2025.2.0.tgz
cd p4-mcp-server-2025.2.0
./p4-mcp-server --help
Requirements:
Build:
Output:
Run the P4 MCP Server from a Docker container with STDIO transport, allowing MCP clients to manage the container lifecycle.
Note: Docker-based execution is currently supported on macOS and Linux only.
Prerequisites
Build the Docker Image
cd /path/to/p4mcp-server
docker build -t p4-mcp-server .
Configure MCP Client
Add the following to your mcp.json:
{
"servers": {
"perforce-p4mcp-docker": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"--hostname", "your-hostname",
"-e", "P4PORT=ssl:perforce.example.com:1666",
"-e", "P4USER=your_username",
"-e", "P4CLIENT=your_workspace",
"-v", "/Users/your_username/.p4tickets:/root/.p4tickets:ro",
"p4-mcp-server"
]
}
}
}
Configuration Options
| Flag | Description |
|---|---|
-i |
Interactive mode (required for STDIO) |
--rm |
Remove container when stopped |
--hostname |
Match workspace host restriction |
-e P4PORT |
P4 server address |
-e P4USER |
P4 username |
-e P4CLIENT |
Workspace name |
-v |
Mount P4 tickets file |
Authentication
Using P4 tickets:
# macOS/Linux
-v /Users/your_username/.p4tickets:/root/.p4tickets:ro
Note: Use the full path to your tickets file (not
~). After runningp4 login, restart the MCP server to pick up the new ticket.
Using a password:
-e P4PASSWD="your_password"
Workspace Host Restrictions
⚠️ Important: Docker containers have their own hostname, which differs from your local machine. If your P4 workspace is restricted to a specific host, operations like
syncwill fail.
To resolve this, set the container hostname to match your workspace's host restriction:
--hostname your-hostname
To find your workspace host name:
# macOS/Linux
p4 client -o your_workspace | grep "^Host:"
Mounting Client Root for Write Operations
⚠️ Important: By default, the Docker container cannot access your local workspace files. For write operations like
sync,submit, orreconcile, you must mount your client root directory into the container at the same path.
Add a volume mount for your client root:
-v /path/to/your/client/root:/path/to/your/client/root
Example configuration with client root mounted:
{
"servers": {
"perforce-p4mcp-docker": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"--hostname", "your-hostname",
"-e", "P4PORT=ssl:perforce.example.com:1666",
"-e", "P4USER=your_username",
"-e", "P4CLIENT=your_workspace",
"-v", "/Users/your_username/.p4tickets:/root/.p4tickets",
"-v", "/path/to/client/root:/path/to/client/root",
"p4-mcp-server"
]
}
}
}
To find your client root:
p4 client -o your_workspace | grep "^Root:"
Note: The mount path inside the container must match the client root path exactly, as P4 tracks files by their absolute paths.
Note: In all configuration examples below, if
P4CONFIGis set, you do not need to set any environment variables in theenvblock. The server will use the configuration from the specified P4CONFIG file instead.{ "mcpServers": { "perforce-p4-mcp": { "command": "/absolute/path/to/p4-mcp-server", "env": { }, "args": [ "--readonly", "--allow-usage" ] } } }
See the JetBrains AI Assistant VCS Integration documentation for detailed configuration steps.
See the Claude Code MCP docs for more information.
{
"mcpServers": {
"perforce-p4-mcp": {
"command": "/absolute/path/to/p4-mcp-server",
"env": {
"P4PORT": "ssl:perforce.example.com:1666",
"P4USER": "your_username",
"P4CLIENT": "your_workspace"
},
"args": [
"--readonly", "--allow-usage"
]
}
}
}
See the Cursor MCP documentation for more information.
{
"mcpServers": {
"perforce-p4-mcp": {
"command": "/absolute/path/to/p4-mcp-server",
"env": {
"P4PORT": "ssl:perforce.example.com:1666",
"P4USER": "your_username",
"P4CLIENT": "your_workspace"
},
"args": [
"--readonly", "--allow-usage"
]
}
}
}
See the Eclipse MCP documentation for more information.
{
"servers": {
"perforce-p4-mcp": {
"command": "/absolute/path/to/p4-mcp-server",
"env": {
"P4PORT": "ssl:perforce.example.com:1666",
"P4USER": "your_username",
"P4CLIENT": "your_workspace"
},
"args": [
"--readonly", "--allow-usage"
]
}
}
}
See the Kiro MCP documentation for more information.
{
"mcpServers": {
"perforce-p4-mcp": {
"command": "/absolute/path/to/p4-mcp-server",
"env": {
"P4PORT": "ssl:perforce.example.com:1666",
"P4USER": "your_username",
"P4CLIENT": "your_workspace"
},
"args": [
"--readonly", "--allow-usage"
]
}
}
}
See the VS Code documentation for more information. Add the following to your VS Code MCP settings:
{
"servers": {
"perforce-p4-mcp": {
"command": "/absolute/path/to/p4-mcp-server",
"env": {
"P4PORT": "ssl:perforce.example.com:1666",
"P4USER": "your_username",
"P4CLIENT": "your_workspace"
},
"args": [
"--readonly", "--allow-usage"
]
}
}
}
See the Windsurf MCP documentation for more information.
{
"mcpServers": {
"perforce-p4-mcp": {
"command": "/absolute/path/to/p4-mcp-server",
"env": {
"P4PORT": "ssl:perforce.example.com:1666",
"P4USER": "your_username",
"P4CLIENT": "your_workspace"
},
"args": [
"--readonly", "--allow-usage"
]
}
}
}
P4PORT - P4 Server address. Examples: ssl:perforce.example.com:1666, localhost:1666P4USER - Your P4 usernameP4CLIENT - Your current P4 workspace. Optional, but recommended--readonly - Control write operations.
--allow-usage - Allow usage statistics.
--toolsets - Specify which tool categories to enable.
files, changelists, shelves, workspaces, jobs, reviewscommand field in all configurations.Example setup
# Windows (PowerShell)
$env:P4PORT = "ssl:perforce.example.com:1666"
$env:P4USER = "your_username"
$env:P4CLIENT = "your_workspace"
# macOS (Bash)
export P4PORT="ssl:perforce.example.com:1666"
export P4USER="your_username"
export P4CLIENT="your_workspace"
Manage access through group-level and user-level server properties. These follow a strict order of precedence:
-s).To disable MCP for all users:
p4 property -a -n mcp.enabled -v false
To re-enable group/user-based control, delete the global property first:
p4 property -d -n mcp.enabled
To prevent access for all members of a specific group:
p4 property -a -n mcp.enabled -v false -g noaccessgroup
You can set multiple group restrictions the same way.
When a user belongs to multiple groups with conflicting settings, sequence order (-s) determines which settings apply.
Lower sequence numbers are evaluated first.
Example:
p4 property -a -n mcp.enabled -v false -s1 -g noaccessgroup
p4 property -a -n mcp.enabled -v true -s2 -g accessgroup
In this example, accessgroup overrides noaccessgroup because it is evaluated later.
To block a specific user regardless of group membership:
p4 property -a -n mcp.enabled -v false -u noaccessuser
User-level properties always override group-level settings.
Example: Even if noaccessuser is in accessgroup (where MCP is enabled), the user property takes precedence and MCP is disabled.
Important notes
mcp.enabled acts as the main switch.
Avoid global properties (-a without -u or -g) unless you absolutely need to disable MCP for everyone.
server_info - Get P4 version, uptime, and configurationcurrent_user - Get current user information and permissionslist - List all workspaces (optionally filtered by user)get - Get a detailed workspace specificationtype - Check workspace type and configurationstatus - Check workspace sync statusworkspace_name, user, max_resultsget - Get detailed changelist information (files, description, jobs)list - List changelists with filters (status, user, workspace)changelist_id, status (pending/submitted), workspace_name, max_resultscontent - Get file content at a specific revisionhistory - Get file revision history and integration recordsinfo - Get file basic details (type, size, permissions)metadata - Get file metadata (attributes, filesize, etc.)diff - Compare file versions (depot-to-depot or mixed)annotations - Get file annotations with blame informationfile_path, file2 (for diff), max_results, diff2 (boolean)list - List shelved changes by user or globallydiff - Show differences in shelved filesfiles - List files in a specific shelfchangelist_id, user, max_resultslist_jobs - List jobs associated with a changelistget_job - Get detailed job information and statuschangelist_id, job_id, max_resultslist - List all reviews with optional filteringdashboard - Get current user's review dashboard (my reviews, needs attention)get - Get detailed review informationtransitions - Get available state transitions for a reviewfiles_readby - Get files read status by usersfiles - Get files in a review (with optional version range)activity - Get review activity historycomments - Get comments on a reviewreview_id - Review ID (required for get, transitions, files_readby, files, comments, activity)review_fields - Comma-separated fields to return (e.g., "id,description,author,state")comments_fields - Fields for comments (default: "id,body,user,time")up_voters - List of up voters for transitionsfrom_version, to_version - Version range for files actionmax_results - Maximum results (default: 10)create, update, delete, switchname, specs (WorkspaceSpec object with View, Root, Options, etc.)create, update, submit, delete, move_fileschangelist_id, description, file_pathsadd, edit, delete, move, revert, reconcile, resolve, syncfile_paths, changelist, force, mode (for resolve operations)auto, safe, force, preview, theirs, yoursshelve, unshelve, update, delete, unshelve_to_changelistchangelist_id, file_paths, target_changelist, forcelink_job, unlink_jobchangelist_id, job_idcreate - Create a new review from a changelistrefresh_projects - Refresh project associationsvote - Vote on a review (up, down, clear)transition - Change review state (needsRevision, needsReview, approved, committed, rejected, archived)append_participants - Add reviewers/groups to a reviewreplace_participants - Replace all participantsdelete_participants - Remove participants from a reviewadd_comment - Add a comment to a reviewreply_comment - Reply to an existing commentappend_change - Add a changelist to an existing reviewreplace_with_change - Replace review content with a changelistjoin - Join a review as a participantleave - Leave a reviewarchive_inactive - Archive inactive reviewsmark_comment_read / mark_comment_unread - Mark individual comment read statusmark_all_comments_read / mark_all_comments_unread - Mark all comments read statusupdate_author - Change the review authorupdate_description - Update review descriptionobliterate - Permanently delete a reviewreview_id - Review ID (required for most actions)change_id - Changelist ID (required for create, append_change, replace_with_change)description - Review descriptionreviewers, required_reviewers - Lists of reviewer usernamesreviewer_groups - Reviewer groups with requirementsvote_value - Vote value: up, down, clearversion - Review version for votingtransition - Target state: needsRevision, needsReview, approved, committed, approved:commit, rejected, archivedjobs, fix_status, cleanup - Job linking and cleanup options for transitionsusers, groups - Structured participant data for append/replace/deletebody - Comment body texttask_state - Comment task state: open, commentnotify - Notification mode: immediate, delayedcomment_id - Comment ID for replies or marking read/unreadcontext - Comment context (file, line numbers, content, version)not_updated_since, max_reviews - Filters for archive_inactivenew_author, new_description - Values for update actionsoperation_id, source_tool, user_confirmedLog locations:
logs/p4mcp.log - Main server operations and errorslogs/sessions/*.log - Individual session activities are recorded only when the --allow-usage is specified in the server's startup arguments.Privacy-first approach:
Data collected (if consented):
Data not collected:
Control:
--allow-usage argument is provided at startup.Symptoms: OS cannot find or execute the binary; error includes ENOENT or "No such file or directory".
Solutions:
command field uses the correct absolute path for your OS:
/absolute/path/to/p4-mcp-serverC:\absolute\path\to\p4-mcp-server.exels -l /absolute/path/to/p4-mcp-server && chmod +x /absolute/path/to/p4-mcp-server
dir C:\absolute\path\to\p4-mcp-server.exe
.exe file, select Properties, and if present, click Unblock.Symptoms: Cannot connect to P4 Server
Solutions:
P4PORT environment variable: echo $P4PORT (macOS) or echo $env:P4PORT (Windows)p4 infoping perforce.example.comssl: prefix for SSL connections).Symptoms: SSL trust errors when connecting
Solutions:
p4 trust -f -yp4 trust -lSymptoms: Authentication failures
Solutions:
p4 login -ap4 login -sp4 users -m 1 your_usernameSymptoms: Login failures
Solutions:
p4 login -ap4 infoSymptoms: Workspace not found errors
Solutions:
p4 clientsP4CLIENT environment variable.p4 client workspace_namep4 client -o workspace_nameSymptoms: Files are outside the workspace mapping
Solutions:
p4 client -o workspace_namep4 where file_path to check the mapping.Symptoms: Insufficient permissions for operations
Solutions:
p4 opened file_pathp4 protects file_pathSymptoms: Exclusive lock conflicts
Solutions:
p4 opened file_pathSymptoms: Long response times
Solutions:
max_results parameter to limit the query size.Symptoms: High memory usage
Solutions:
max_results for large queries.Symptoms: Conflict with built-in or other MCP tools Solutions:
Symptoms: Invalid context or outdated session history Solutions:
logs/p4mcp.log first.p4 info works before troubleshooting MCP.Perforce P4 MCP Server is a community supported project and is not officially supported by Perforce. Pull requests and issues are the responsibility of the project's moderator(s); this may be a vetted individual or team with members outside of the Perforce organization. Perforce does not officially support these projects, therefore all issues should be reported and managed via GitHub (not via Perforce's standard support process).
We welcome contributions to the P4 MCP Server project.
This project is licensed under the MIT License. See LICENSE for details.
This project includes third-party components. Their licenses and attributions are listed in THIRD-PARTY-NOTICES.
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation.
by zed-industries
A high‑performance, multiplayer code editor designed for speed and collaboration.
by modelcontextprotocol
Model Context Protocol Servers
by modelcontextprotocol
A Model Context Protocol server that provides time and timezone conversion capabilities.
by cline
An autonomous coding assistant that can create and edit files, execute terminal commands, and interact with a browser directly from your IDE, operating step‑by‑step with explicit user permission.
by upstash
Provides up-to-date, version‑specific library documentation and code examples directly inside LLM prompts, eliminating outdated information and hallucinated APIs.
by daytonaio
Provides a secure, elastic infrastructure that creates isolated sandboxes for running AI‑generated code with sub‑90 ms startup, unlimited persistence, and OCI/Docker compatibility.
by continuedev
Enables faster shipping of code by integrating continuous AI agents across IDEs, terminals, and CI pipelines, offering chat, edit, autocomplete, and customizable agent workflows.
by github
Connects AI tools directly to GitHub, enabling natural‑language interactions for repository browsing, issue and pull‑request management, CI/CD monitoring, code‑security analysis, and team collaboration.