Labsco
Cocoon-AI logo

MCP Perforce Server

โ˜… 30

from Cocoon-AI

A server for Perforce (P4) version control operations, wrapping P4 commands for easier and more reliable use.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeNeeds API keys

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 .p4config files for per-project settings

  • Common 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

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

Copy & paste โ€” that's it
"Show me my pending P4 changes"
"Check P4 status in the gamedev directory"

p4_add: Add files to Perforce

Copy & paste โ€” that's it
"Add all .js files in the src directory to Perforce"

p4_edit: Open files for edit

Copy & paste โ€” that's it
"Open config.json for editing in Perforce"

p4_delete: Mark files for deletion

Copy & paste โ€” that's it
"Delete the old_module.py file from Perforce"

p4_sync: Sync files from depot

Copy & paste โ€” that's it
"Sync all files in the project"
"Force sync the src directory"

p4_revert: Revert files or entire changelists

Copy & paste โ€” that's it
"Revert all files in changelist 12345"
"Revert changes to config.json"

p4_diff: Show differences for files

Copy & paste โ€” that's it
"Show me the diff for all my open files"

Changelist Operations

p4_changelist_create: Create a new changelist

Copy & paste โ€” that's it
"Create a new changelist with description 'Fix login bug'"

p4_changelist_submit: Submit a changelist

Copy & paste โ€” that's it
"Submit changelist 12345"

p4_move_to_changelist: Move files between changelists

Copy & paste โ€” that's it
"Move all my open files to changelist 12345"

Stream Operations

p4_stream_list: List streams in a depot

Copy & paste โ€” that's it
"List all streams in //depot"
"Show me development streams matching 'feature'"

p4_stream_info: Get detailed stream information

Copy & paste โ€” that's it
"Show me details about //depot/main stream"

p4_stream_switch: Switch workspace to a different stream

Copy & paste โ€” that's it
"Switch to the //depot/dev stream"
"Force switch to //depot/release-2.0"

p4_stream_create: Create a new stream

Copy & paste โ€” that's it
"Create a development stream //depot/feature-xyz from //depot/main"

p4_stream_edit: Edit stream specification

Copy & paste โ€” that's it
"Edit the //depot/feature-xyz stream spec"

p4_stream_graph: Show stream hierarchy

Copy & paste โ€” that's it
"Show the stream hierarchy for //depot"

Client/Workspace Operations

p4_client_list: List all clients/workspaces

Copy & paste โ€” that's it
"List all my Perforce workspaces"
"Show clients for user jsmith"

p4_client_info: Get client/workspace details

Copy & paste โ€” that's it
"Show me details about my current workspace"
"Show info for client gamedev-workspace"

p4_client_create: Create a new client/workspace

Copy & paste โ€” that's it
"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

Copy & paste โ€” that's it
"Edit the view mappings for client dev-workspace"

p4_client_delete: Delete a client/workspace

Copy & paste โ€” that's it
"Delete the old-feature workspace"
"Force delete the broken-client workspace"

p4_client_switch: Switch to a different client

Copy & paste โ€” that's it
"Switch to the production-client workspace"

Information Operations

p4_info: Show current Perforce configuration

Copy & paste โ€” that's it
"Show me which P4 server and workspace I'm using"

mcp_perforce_version: Show MCP Perforce server version

Copy & paste โ€” that's it
"What version of mcp-perforce is running?"

Debug Logging

To enable debug output, add to your configuration:

Copy & paste โ€” that's it
{
 "mcpServers": {
 "perforce": {
 "command": "npx",
 "args": ["-y", "@cocoon-ai/mcp-perforce"],
 "env": {
 "P4CONFIG": ".p4config",
 "DEBUG": "mcp:*"
 }
 }
 }
}

Development

Building from source

Copy & paste โ€” that's it
git clone https://github.com/Cocoon-AI/mcp-perforce.git
cd mcp-perforce
npm install
npm run build

Running tests

Copy & paste โ€” that's it
npm test

Adding 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.ts

  • Follow 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

Support

Made with โค๏ธ for AIs struggling with P4 command-line operations