MCP Perforce Server
Integrates with Perforce version control system to perform operations such as adding, editing, deleting, submitting, reverting, syncing files, managing changelists, streams, and client workspaces through the P4 command-line interface.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Perforce Server Show me my pending P4 changes"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Perforce Server
A Model Context Protocol (MCP) server that provides a clean interface for Perforce (P4) operations in Claude Desktop. This server wraps P4 commands to make them more reliable and easier for Claude to use, eliminating issues with interactive prompts and complex state management.
Features
Non-interactive operations: All commands are wrapped to avoid interactive prompts
Structured responses: Clean, parseable output instead of raw P4 output
Multi-project support: Automatically uses
.p4configfiles for per-project settingsCommon operations: Add, edit, delete, submit, revert, sync, and more
Changelist management: Create and submit changelists with explicit parameters
Error handling: Graceful error handling with clear error messages
Related MCP server: Workbench MCP Server
Installation
Prerequisites
Node.js 18+ installed
Perforce command-line client (p4) installed and in your PATH
.p4configfiles in your project directories (recommended)
Quick Install with Claude Code
# Install the package globally
npm install -g @cocoon-ai/mcp-perforce
# Add to Claude Code
claude mcp add perforce @cocoon-ai/mcp-perforceThat's it! Claude Code will automatically configure the server for you.
Manual Installation
Via NPM (when published)
npm install -g @cocoon-ai/mcp-perforceInstall from Source
git clone https://github.com/Cocoon-AI/mcp-perforce.git
cd mcp-perforce
npm install
npm run build
npm link # Makes 'mcp-perforce' available globallyConfiguration
Basic Setup
Add the server to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/claude/claude_desktop_config.json
{
"mcpServers": {
"perforce": {
"command": "npx",
"args": ["-y", "@cocoon-ai/mcp-perforce"],
"env": {
"P4CONFIG": ".p4config"
}
}
}
}Setting Up .p4config Files
The server uses Perforce's built-in P4CONFIG mechanism to automatically switch between different Perforce servers based on your current directory. Create a .p4config file in each project root:
# ~/projects/gamedev/.p4config
P4PORT=perforce-game.company.com:1666
P4CLIENT=gamedev-workspace
P4USER=your-username
# ~/projects/web/.p4config
P4PORT=perforce-web.company.com:1666
P4CLIENT=web-workspace
P4USER=your-usernameNow the MCP server will automatically use the correct Perforce settings based on which project directory you're working in!
Available Commands
Once configured, you can ask Claude to use these P4 operations. All commands will automatically use the .p4config settings from your current project directory.
Basic File Operations
p4_status: Check workspace status and pending changes"Show me my pending P4 changes" "Check P4 status in the gamedev directory"p4_add: Add files to Perforce"Add all .js files in the src directory to Perforce"p4_edit: Open files for edit"Open config.json for editing in Perforce"p4_delete: Mark files for deletion"Delete the old_module.py file from Perforce"p4_sync: Sync files from depot"Sync all files in the project" "Force sync the src directory"p4_revert: Revert files or entire changelists"Revert all files in changelist 12345" "Revert changes to config.json"p4_diff: Show differences for files"Show me the diff for all my open files"
Changelist Operations
p4_changelist_create: Create a new changelist"Create a new changelist with description 'Fix login bug'"p4_changelist_submit: Submit a changelist"Submit changelist 12345"p4_move_to_changelist: Move files between changelists"Move all my open files to changelist 12345"
Stream Operations
p4_stream_list: List streams in a depot"List all streams in //depot" "Show me development streams matching 'feature'"p4_stream_info: Get detailed stream information"Show me details about //depot/main stream"p4_stream_switch: Switch workspace to a different stream"Switch to the //depot/dev stream" "Force switch to //depot/release-2.0"p4_stream_create: Create a new stream"Create a development stream //depot/feature-xyz from //depot/main"p4_stream_edit: Edit stream specification"Edit the //depot/feature-xyz stream spec"p4_stream_graph: Show stream hierarchy"Show the stream hierarchy for //depot"
Client/Workspace Operations
p4_client_list: List all clients/workspaces"List all my Perforce workspaces" "Show clients for user jsmith"p4_client_info: Get client/workspace details"Show me details about my current workspace" "Show info for client gamedev-workspace"p4_client_create: Create a new client/workspace"Create a new workspace called dev-feature in /home/user/p4/feature" "Create a stream client for //depot/main-stream"p4_client_edit: Edit client specification"Edit the view mappings for client dev-workspace"p4_client_delete: Delete a client/workspace"Delete the old-feature workspace" "Force delete the broken-client workspace"p4_client_switch: Switch to a different client"Switch to the production-client workspace"
Information Operations
p4_info: Show current Perforce configuration"Show me which P4 server and workspace I'm using"mcp_perforce_version: Show MCP Perforce server version"What version of mcp-perforce is running?"
Example Usage in Claude
Here are some example conversations with Claude:
Example 1: Creating and submitting a change
You: "I've modified server.js and config.json. Create a changelist for these fixes"
Claude: I'll help you create a changelist for your changes. Let me first check the status...
[Uses p4_status, p4_changelist_create, p4_submit]Example 2: Syncing and reviewing changes
You: "Sync the latest changes and show me what files I have open"
Claude: I'll sync your workspace and check your open files...
[Uses p4_sync, p4_status]Troubleshooting
Server not appearing in Claude
Restart Claude Desktop after modifying the configuration
Check that the configuration file is valid JSON
Verify the MCP server is installed:
npm list -g @cocoon-ai/mcp-perforce
Perforce authentication errors
Check your
.p4configfile exists and has the correct settingsTest your connection outside Claude:
p4 infoMake sure you're logged in:
p4 loginVerify P4CONFIG is being recognized:
p4 set P4CONFIG
Wrong Perforce server being used
Check which directory you're in - the server uses
.p4configfrom the current or parent directoriesRun
p4 infoto see which config is being usedUse the
p4_infocommand in Claude to debug: "Show me my P4 configuration"
Command not working as expected
Check Claude's response for error messages
Verify the P4 command works in your terminal from the same directory
Enable debug logging (see below)
Debug Logging
To enable debug output, add to your configuration:
{
"mcpServers": {
"perforce": {
"command": "npx",
"args": ["-y", "@cocoon-ai/mcp-perforce"],
"env": {
"P4CONFIG": ".p4config",
"DEBUG": "mcp:*"
}
}
}
}Development
Building from source
git clone https://github.com/Cocoon-AI/mcp-perforce.git
cd mcp-perforce
npm install
npm run buildRunning tests
npm testAdding new commands
Add the tool definition in the appropriate file under
src/tools/Add the handler function in the corresponding file under
src/handlers/Update the switch statement in
src/handlers/index.tsFollow the existing pattern for parameter validation and error handling
Contributing
Contributions are welcome! Please:
Fork the repository
Create a feature branch (
git checkout -b feature/new-command)Commit your changes (
git commit -am 'Add new P4 command')Push to the branch (
git push origin feature/new-command)Create a Pull Request
License
MIT License - see LICENSE file for details
Acknowledgments
Built on the Model Context Protocol SDK
Inspired by the need for better Perforce integration in AI assistants
Support
Issues: GitHub Issues
Discussions: GitHub Discussions
Made with ❤️ for AIs struggling with P4 command-line operations
Available Tools
25 toolsmcp_perforce_versionA
Show MCP Perforce server version
Inputs: no named parameters.
p4_addC
Add files to Perforce
Inputs: files (required), path.
p4_changelist_createB
Create a new changelist with a description
Inputs: description (required), path.
p4_changelist_submitC
Submit a changelist
Inputs: changelist (required), path, description.
p4_client_createB
Create a new client/workspace
Inputs: root (required), client (required), path, view, +3 more.
p4_client_deleteB
Delete a client/workspace
Inputs: client (required), path, force.
p4_client_editB
Edit an existing client/workspace specification
Inputs: client (required), path, spec.
p4_client_infoA
Get detailed information about a specific client/workspace
Inputs: path, client.
p4_client_listB
List all clients/workspaces for the current user
Inputs: path, user.
p4_client_switchC
Switch to a different client/workspace
Inputs: client (required), path.
p4_deleteB
Mark files for deletion in Perforce
Inputs: files (required), path.
p4_diffC
Show differences for files
Inputs: files (required), path.
p4_editC
Open files for edit in Perforce
Inputs: files (required), path.
p4_infoB
Show Perforce configuration info for current directory
Inputs: path.
p4_move_to_changelistB
Move files to a specific changelist
Inputs: files (required), changelist (required), path.
p4_raw_commandA
FOR DEBUGGING: Executes a raw p4 command and returns stdout/stderr
Inputs: command (required), path.
p4_revertC
Revert files or changelist
Inputs: path, files, changelist.
p4_statusB
Get current P4 workspace status and pending changes
Inputs: path.
p4_stream_createC
Create a new stream
Inputs: type (required), stream (required), description (required), path, +1 more.
p4_stream_editB
Edit stream specification
Inputs: stream (required), path, spec.
p4_stream_graphC
Show stream hierarchy graph
Inputs: path, depot.
p4_stream_infoB
Get detailed information about a specific stream
Inputs: stream (required), path.
p4_stream_listB
List all streams or streams matching a pattern
Inputs: path, depot, filter.
p4_stream_switchC
Switch workspace to a different stream
Inputs: stream (required), path, force.
p4_syncC
Sync files from the depot
Inputs: path, files, force.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 25 tools
Each tool targets a distinct resource and action: file operations (add/edit/delete/revert/sync/diff) are clearly separate from changelist, client, and stream operations. Even similar-sounding tools like p4_info and p4_status have distinct purposes (config vs workspace status).
The dominant pattern is p4_<resource>_<action> (e.g., p4_stream_list, p4_client_create) or p4_<verb> for file ops (p4_add, p4_edit). The only outlier is mcp_perforce_version, which uses a different prefix and breaks the p4_ convention.
At 25 tools, the set is large but each tool serves a specific need for Perforce workflows. The count is at the boundary of 'heavy' but is justified by the breadth of Perforce features (files, changelists, clients, streams).
The core CRUD and lifecycle operations for files, changelists, clients, and streams are well covered. Minor gaps exist, such as no stream_delete or changelist_edit, but these can be worked around with p4_raw_command.
Maintenance
Related MCP Connectors
Persistent context for Claude. Your AI always knows your projects and next actions across sessions.
Your Aurentia workspace — projects, CRM, tasks, deliverables — in Claude, Cursor or any MCP client.
Project management MCP for AI agents with safe task reads and writes.
Share one project context across ChatGPT, Claude, Telegram and any MCP client.
Related MCP Servers
- FlicenseBqualityFmaintenanceProvides sophisticated context management for Claude, enabling persistent context across sessions, project-specific organization, and conversation continuity.415-
- AlicenseNot gradedqualityDmaintenanceProvides remote project access via MCP, enabling file operations, code search, git commands, and background Claude CLI execution.5 npmMIT
- FlicenseBqualityDmaintenanceWraps Maven and Spring Boot operations for Claude Code, providing structured JSON output instead of raw build logs to save tokens and focus on code fixes.20-
- AlicenseAqualityDmaintenanceBridges Claude AI with the local filesystem for direct file and project management, enabling incremental saves and automatic work logs to overcome token limits.222MIT