P4 MCP Server
Perforce P4MCP Server is a Model Context Protocol (MCP) server that integrates with the Perforce P4 version control system.
Features
- Comprehensive P4 integration: Read/write tools across files, changelists, shelves, workspaces, jobs, reviews, and server information
- Code review workflows: P4 Code Review support for review discovery, voting, state transitions, commenting, and participant management
- Safety first: Read-only mode by default, ownership checks, explicit confirmation for destructive deletes.
- Flexible toolsets: Configure which tool categories to enable: files, changelists, shelves, workspaces, jobs and reviews.
- Robust logging: Application and session logging to the
logs/directory. - Optional telemetry: Consent-gated usage statistics. Disabled by default.
- Cross platform: Supported on macOS and Windows with pre-built binaries.
Prerequisites
- P4 Server access: Connection to a P4 Server with proper credentials
- Authentication: Valid P4 login (ticket-based or password)
Local P4 MCP Server installation
Download the appropriate binary for your operating system:
- Windows:
binaries/win/p4-mcp-server-2025.2.0.zip - macOS:
binaries/mac/p4-mcp-server-2025.2.0.tgz
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:
- Python 3.11+ (with Tkinter)
Build:
- macOS: chmod +x build.sh && ./build.sh package
- Linux: chmod +x build.sh && ./build.sh package
- Windows: build.bat package
Output:
- macOS: p4-mcp-server-<version>.tgz
- Windows: p4-mcp-server-<version>.zip
MCP client configuration
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"
]
}
}
}
P4 environment variables
P4PORT- P4 Server address. Examples:ssl:perforce.example.com:1666,localhost:1666P4USER- Your P4 usernameP4CLIENT- Your current P4 workspace. Optional, but recommended
Supported arguments
-
--readonly- Control write operations.- If present, uses read-only mode. Safe for exploration and testing.
- If missing, enables write operations. Requires proper permissions on your P4 Server.
-
--allow-usage- Allow usage statistics.- If present, allows anonymous usage statistics collection.
- If missing, disables all usage statistics.
-
--toolsets- Specify which tool categories to enable.- Available:
files,changelists,shelves,workspaces,jobs,reviews - Default: All toolsets enabled.
- Available:
Required configurations
- Use absolute paths for the
commandfield in all configurations. - Ensure environment variables are properly set for each host.
- Different hosts may have different argument parsing. Refer to the host's documentation.
P4 configuration
User configuration
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"
Admin configuration
Manage access through group-level and user-level server properties. These follow a strict order of precedence:
- User-level properties override group properties.
- Group-level properties are evaluated in the order of their sequence number (set with
-s). - If no property applies, MCP remains enabled unless explicitly disabled.
Master switch (global disable)
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.enabledacts as the main switch. -
Avoid global properties (
-awithout-uor-g) unless you absolutely need to disable MCP for everyone.
Available tools
Query tools (read operations)
- Actions:
server_info- Get P4 version, uptime, and configurationcurrent_user- Get current user information and permissions
- Use cases - Server diagnostics, user verification, connection testing
- Actions:
list- List all workspaces (optionally filtered by user)get- Get a detailed workspace specificationtype- Check workspace type and configurationstatus- Check workspace sync status
- Parameters:
workspace_name,user,max_results - Use cases: Workspace discovery, configuration review, status checking
- Actions:
get- Get detailed changelist information (files, description, jobs)list- List changelists with filters (status, user, workspace)
- Parameters:
changelist_id,status(pending/submitted),workspace_name,max_results - Use cases: Code review, history tracking, changelist analysis
- Actions:
content- 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 information
- Parameters:
file_path,file2(for diff),max_results,diff2(boolean) - Use cases: Code analysis, file comparison, history tracking, blame analysis
- Actions:
list- List shelved changes by user or globallydiff- Show differences in shelved filesfiles- List files in a specific shelf
- Parameters:
changelist_id,user,max_results - Use cases: Code review, work-in-progress tracking, collaboration
- Actions:
list_jobs- List jobs associated with a changelistget_job- Get detailed job information and status
- Parameters:
changelist_id,job_id,max_results - Use cases: Defect tracking, requirement traceability, project management
- Actions:
list- 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 review
- Parameters:
review_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)
- Use cases: Code review discovery, review status tracking, comment retrieval, review activity monitoring
Modify tools (write operations)
- Actions -
create,update,delete,switch - Parameters -
name,specs(WorkspaceSpec object with View, Root, Options, etc.) - Requires - Non-read only mode, appropriate permissions
- Use cases - Environment setup, workspace maintenance, branch switching
- Actions -
create,update,submit,delete,move_files - Parameters -
changelist_id,description,file_paths - Safety - Ownership checks, confirmation for destructive operations
- Use cases - Code submission, work organization, file grouping
- Actions -
add,edit,delete,move,revert,reconcile,resolve,sync - Parameters -
file_paths,changelist,force,mode(for resolve operations) - Resolve modes -
auto,safe,force,preview,theirs,yours - Use cases - File editing, conflict resolution, workspace synchronization
- Actions -
shelve,unshelve,update,delete,unshelve_to_changelist - Parameters -
changelist_id,file_paths,target_changelist,force - Use cases - Temporary storage, code sharing, backup before experiments
- Actions -
link_job,unlink_job - Parameters -
changelist_id,job_id - Use cases - Defect tracking integration, requirement linking
- Actions:
create- 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 review
- Parameters:
review_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 actions
- Use cases: Code review workflow, review state management, collaborative commenting, participant management, review cleanup
- Parameters -
operation_id,source_tool,user_confirmed - Safety - Requires explicit user confirmation, logs all operations
- Supported Resources - Changelists, workspaces, shelves
- Use cases - Cleanup operations, resource management
Logging and usage data
Logging system
Log locations:
- Application log:
logs/p4mcp.log- Main server operations and errors - Session logs:
logs/sessions/*.log- Individual session activities are recorded only when the--allow-usageis specified in the server's startup arguments.
Usage data
Privacy-first approach:
- Disabled by default: No data collection without explicit consent
- Consent-gated: First-run prompt for telemetry permission
- Transparent: Clear explanation of data collected
- Revocable: Easy opt-out at any time
Data collected (if consented):
- Tool usage frequency (anonymized)
- Error rates and types (no personal data)
- Performance metrics
- Feature adoption statistics
- P4 server version
Data not collected:
- File contents or names
- P4 Server details except version
- User credentials or personal information
- Specific project information
Control:
- Usage data is only collected if the
--allow-usageargument is provided at startup.
Troubleshooting
Server startup issues
Symptoms: OS cannot find or execute the binary; error includes ENOENT or "No such file or directory".
Solutions:
- Check the path: Make sure the
commandfield uses the correct absolute path for your OS:- macOS/Linux:
/absolute/path/to/p4-mcp-server - Windows:
C:\absolute\path\to\p4-mcp-server.exe
- macOS/Linux:
- Ensure the binary exists and is executable:
- macOS/Linux:
ls -l /absolute/path/to/p4-mcp-server && chmod +x /absolute/path/to/p4-mcp-server - Windows:
dir C:\absolute\path\to\p4-mcp-server.exe
- macOS/Linux:
- On Windows, ensure the binary is not blocked:
- Right-click the
.exefile, select Properties, and if present, click Unblock.
- Right-click the
Connection issues
Symptoms: Cannot connect to P4 Server
Solutions:
- Verify the
P4PORTenvironment variable:echo $P4PORT(macOS) orecho $env:P4PORT(Windows) - Test the direct connection:
p4 info - Check server availability:
ping perforce.example.com - Verify the port and protocol (
ssl:prefix for SSL connections).
Symptoms: SSL trust errors when connecting
Solutions:
- Trust the server:
p4 trust -f -y - Check trust status:
p4 trust -l - For persistent issues, verify the SSL configuration.
Authentication problems
Symptoms: Authentication failures
Solutions:
- Log in to P4:
p4 login -a - Check login status:
p4 login -s - Verify the user exists:
p4 users -m 1 your_username - For persistent issues, check password or use ticket-based authentication.
Symptoms: Login failures
Solutions:
- Reset the password through P4 administrator.
- Use ticket-based authentication:
p4 login -a - Verify the username is correct:
p4 info
Workspace issues
Symptoms: Workspace not found errors
Solutions:
- List the available workspaces:
p4 clients - Verify the
P4CLIENTenvironment variable. - Create a workspace if needed:
p4 client workspace_name - Check the workspace ownership:
p4 client -o workspace_name
Symptoms: Files are outside the workspace mapping
Solutions:
- Check the client view:
p4 client -o workspace_name - Update the workspace mapping to include the required paths.
- Use
p4 where file_pathto check the mapping.
Permission errors
Symptoms: Insufficient permissions for operations
Solutions:
- Check the file ownership:
p4 opened file_path - Verify the user permissions:
p4 protects file_path - Ensure proper group membership.
- For admin operations, verify admin permissions.
Symptoms: Exclusive lock conflicts
Solutions:
- Check who has the file open:
p4 opened file_path - Contact the user to resolve conflicts.
- Admin can force operations if necessary.
Performance issues
Symptoms: Long response times
Solutions:
- Use the
max_resultsparameter to limit the query size. - Use specific file paths instead of wildcards.
- Check network connectivity to P4.
- Monitor server performance.
Symptoms: High memory usage
Solutions:
- Reduce
max_resultsfor large queries. - Process files in batches.
- Restart the MCP server periodically for long-running sessions.
Tool execution
Symptoms: Conflict with built-in or other MCP tools Solutions:
- Disable any built-in or conflicting MCP server tools in your environment or configuration.
- Ensure the P4 MCP server tools are properly registered and enabled.
- Restart the MCP server after applying configuration changes to load the correct tools.
Symptoms: Invalid context or outdated session history Solutions:
- Provide a P4-related context when writing prompts.
- Start a new session if the existing session is old or contains conflicting prompt history.
Common error patterns
- Authentication: Ensure valid login before MCP operations.
- Workspace mapping: Verify client views include target files.
- Permissions: Check user and file permissions for write operations.
- Network: Verify connectivity for remote P4 Servers.
Getting help
- Check the logs: Always check
logs/p4mcp.logfirst. - Test P4: Ensure
p4 infoworks before troubleshooting MCP. - Report issues to the community: Report issues with log excerpts and environment details.
Support
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).
Contributions
We welcome contributions to the P4 MCP Server project.
License
This project is licensed under the MIT License. See LICENSE for details.
Third-Party Notices
This project includes third-party components. Their licenses and attributions are listed in THIRD-PARTY-NOTICES.
Related Servers
Scout Monitoring MCP
sponsorPut performance and error data directly in the hands of your AI assistant.
Alpha Vantage MCP Server
sponsorAccess financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
codegraph-rust
A blazingly fast codebase graphRAG implementation in 100% Rust
oclif MCP Server Plugin
An oclif CLI plugin that automatically discovers and serves commands via the Model Context Protocol (MCP).
Enkrypt AI Secure MCP Gateway
A secure MCP gateway that acts as a proxy, providing authentication, tool discovery, caching, and guardrail enforcement.
MCP Host
A host for running multiple MCP servers, such as a calculator and an IP location query server, configured via a JSON file.
VSCode MCP
Interact with VSCode through the Model Context Protocol, enabling AI agents to perform development tasks.
DICOM API
Exposes DICOM (Digital Imaging and Communications in Medicine) operations as tools for AI agents.
Praison AI
AI Agents framework with 64+ built-in MCP tools for search, memory, workflows, code execution, and file operations. Install via `uvx praisonai-mcp`
Norce Assistant
Provides AI-powered knowledge and code examples for Norce Commerce development directly in your preferred AI environment.
Ghost MCP
An MCP server for the Ghost blogging platform with Server-Sent Events (SSE) transport support.
Mindpilot MCP
Visualize legacy code and inspect complex flows to understand your agent's operations.