Labsco
perforce logo

P4 MCP Server

โ˜… 99

from perforce

Perforce P4MCP Server is a Model Context Protocol (MCP) server that integrates with the Perforce P4 version control system.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

Perforce P4 MCP Server


Perforce P4 MCP Server

Perforce P4 MCP Server is a Model Context Protocol (MCP) server that integrates with the Perforce P4 version control system. It is built on FastMCP with direct P4 Python bindings to expose safe, structured read/write tools for changelists, files, shelves, workspaces, jobs, reviews, and server metadata.

Features ยท Prerequisites ยท System Requirements ยท Install ยท Deployment ยท Client Configurations ยท P4 Configurations ยท Tools

Logging ยท Troubleshoot ยท Support ยท Contributions ยท License

Features

  • Comprehensive P4 integration: Read/write tools across files, changelists, shelves, workspaces, jobs, reviews, streams, 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, interactive MCP elicitation (PROCEED/CANCEL) for destructive delete and obliterate operations.
  • Flexible toolsets: Configure which tool categories to enable: server, files, changelists, shelves, workspaces, jobs, reviews, and streams.
  • Robust logging: Application and session logging to the logs/ directory.
  • Optional telemetry: Consent-gated usage statistics. Disabled by default.
  • Cross platform: Supported on macOS, Linux and Windows with pre-built binaries.

Available tools

Query tools (read operations)

query_server - Get server information and current user details
  • Actions:
    • server_info - Get P4 version, uptime, and configuration
    • current_user - Get current user information and permissions
  • Use cases - Server diagnostics, user verification, connection testing
query_workspaces - Workspace information and management
  • Actions:
    • list - List all workspaces (optionally filtered by user)
    • get - Get a detailed workspace specification
    • type - Check workspace type and configuration
    • status - Check workspace sync status
  • Parameters: workspace_name, user, max_results
  • Use cases: Workspace discovery, configuration review, status checking
query_changelists - Access changelist information and history
  • 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
query_files - File operations and information
  • Actions:
    • content - Get file content at a specific revision
    • history - Get file revision history and integration records
    • info - 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
    • search - Search for files by name pattern (wildcard matching)
    • grep - Search for files by content pattern (text search)
  • Parameters: file_path, file2 (for diff), pattern (for search/grep), case_insensitive (for grep), max_results, diff2 (boolean)
  • Use cases: Code analysis, file comparison, history tracking, blame analysis, file discovery, content search
query_shelves - Shelved changelist operations and inspection
  • Actions:
    • list - List shelved changes by user or globally
    • diff - Show differences in shelved files
    • files - List files in a specific shelf
  • Parameters: changelist_id, user, max_results
  • Use cases: Code review, work-in-progress tracking, collaboration
query_jobs - Job tracking and defect management
  • Actions:
    • list_jobs - List jobs associated with a changelist
    • get_job - Get detailed job information and status
  • Parameters: changelist_id, job_id, max_results
  • Use cases: Defect tracking, requirement traceability, project management
query_reviews - Review discovery, details, and activity
  • Actions:
    • list - List all reviews with optional filtering
    • dashboard - Get current user's review dashboard (my reviews, needs attention)
    • get - Get detailed review information
    • transitions - Get available state transitions for a review
    • files_readby - Get files read status by users
    • files - Get files in a review (with optional version range)
    • activity - Get review activity history
    • comments - 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 transitions
    • from_version, to_version - Version range for files action
    • max_results - Maximum results (default: 10)
  • Use cases: Code review discovery, review status tracking, comment retrieval, review activity monitoring
query_streams - Stream hierarchy, integration status, and workspace validation
  • Actions:
    • list - List streams with optional filters (path pattern, owner, type)
    • get - Get a detailed stream specification
    • children - Get child streams of a given stream
    • parent - Get the parent stream
    • graph - Get the full stream graph (parent + children)
    • integration_status - Get integration status between stream and parent (p4 istat)
    • get_workspace - Get a workspace spec bound to a stream
    • list_workspaces - List workspaces bound to a stream
    • validate_file - Validate file paths against a stream's view
    • validate_submit - Validate opened files for submit in a stream workspace
    • check_resolve - Check for pending stream spec conflicts
    • interchanges - List changelists awaiting integration between streams
  • Parameters:
    • stream_name - Stream depot path (required for get, children, parent, graph, check_resolve, interchanges)
    • stream_path - Path pattern(s) for list (e.g., ["//depot/..."])
    • filter - Filter expression for list (e.g., "Owner=alice&Type=development")
    • fields - Fields to return for list (e.g., ["Stream", "Owner", "Type"])
    • workspace - Workspace name for get_workspace, validate_file, validate_submit
    • file_paths - File paths for validate_file
    • view_without_edit - View locked stream spec without opening for edit
    • at_change - Retrieve historical stream spec at a changelist number
    • both_directions - Show integration status in both directions
    • force_refresh - Force istat cache refresh
    • reverse, long_output, limit - Options for interchanges
    • unloaded, all_streams, viewmatch - Filters for list
    • max_results - Maximum results
  • Use cases: Stream hierarchy exploration, integration status tracking, workspace validation, view compatibility checks

Modify tools (write operations)

modify_workspaces - Workspace creation and management
  • Actions - create, update, delete, switch
  • Parameters - name, specs (WorkspaceSpec object with View, Root, Options, etc.)
  • Requires - Read-only mode disabled, appropriate permissions
  • Use cases - Environment setup, workspace maintenance, branch switching
modify_changelists - Changelist lifecycle management
  • Actions - create, update, submit, delete, move_files
  • Parameters - changelist_id, description, file_paths
  • Safety - Ownership checks, interactive PROCEED/CANCEL elicitation prompt for delete operations with item details
  • Use cases - Code submission, work organization, file grouping
modify_files - File system operations and version control
  • 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
modify_shelves - Shelving operations for work in progress
  • 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
modify_jobs - Job and changelist integration
  • Actions - link_job, unlink_job
  • Parameters - changelist_id, job_id
  • Use cases - Defect tracking integration, requirement linking
modify_reviews - Review creation, transitions, participants, and comments
  • Actions:
    • create - Create a new review from a changelist
    • refresh_projects - Refresh project associations
    • vote - Vote on a review (up, down, clear)
    • transition - Change review state (needsRevision, needsReview, approved, committed, rejected, archived)
    • append_participants - Add reviewers/groups to a review
    • replace_participants - Replace all participants
    • delete_participants - Remove participants from a review
    • add_comment - Add a comment to a review
    • reply_comment - Reply to an existing comment
    • append_change - Add a changelist to an existing review
    • replace_with_change - Replace review content with a changelist
    • join - Join a review as a participant
    • leave - Leave a review
    • archive_inactive - Archive inactive reviews
    • mark_comment_read / mark_comment_unread - Mark individual comment read status
    • mark_all_comments_read / mark_all_comments_unread - Mark all comments read status
    • update_author - Change the review author
    • update_description - Update review description
    • obliterate - 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 description
    • reviewers, required_reviewers - Lists of reviewer usernames
    • reviewer_groups - Reviewer groups with requirements
    • vote_value - Vote value: up, down, clear
    • version - Review version for voting
    • transition - Target state: needsRevision, needsReview, approved, committed, approved:commit, rejected, archived
    • jobs, fix_status, cleanup - Job linking and cleanup options for transitions
    • users, groups - Structured participant data for append/replace/delete
    • body - Comment body text
    • task_state - Comment task state: open, comment
    • notify - Notification mode: immediate, delayed
    • comment_id - Comment ID for replies or marking read/unread
    • context - Comment context (file, line numbers, content, version)
    • not_updated_since, max_reviews - Filters for archive_inactive
    • new_author, new_description - Values for update actions
  • Use cases: Code review workflow, review state management, collaborative commenting, participant management, review cleanup
modify_streams - Stream lifecycle, spec editing, propagation, and workspace management
  • Actions:
    • create - Create a new stream (mainline, development, release, task, virtual, etc.)
    • update - Update stream properties (name, description, options, paths, parent_view)
    • delete - Delete a stream
    • edit_spec - Open stream spec for editing (p4 stream edit)
    • resolve_spec - Resolve stream spec conflicts
    • revert_spec - Revert stream spec edits
    • shelve_spec - Shelve stream spec edits to a numbered changelist
    • unshelve_spec - Unshelve stream spec edits
    • copy - Copy changes between parent and child streams
    • merge - Merge changes between parent and child streams
    • integrate - Integrate changes with advanced options
    • populate - Populate a new stream with files (branch)
    • switch - Switch a workspace to a different stream
    • create_workspace - Create a new workspace bound to a stream
  • Parameters:
    • stream_name - Stream depot path (required for create, update, delete, edit_spec, resolve_spec, revert_spec, switch)
    • stream_type - Stream type for create: mainline, development, sparsedev, release, sparserel, task, virtual
    • parent - Parent stream for non-mainline create
    • name, description - Stream display name and description
    • options - Stream options: allsubmit/ownersubmit, unlocked/locked, toparent/notoparent, fromparent/nofromparent, mergedown/mergeany
    • parent_view - Parent view treatment: inherit or noinherit
    • paths, remapped, ignored - Stream view mappings
    • changelist - Changelist for spec editing or propagation operations
    • resolve_mode - Resolve mode for resolve_spec: auto, accept_theirs, accept_yours
    • parent_stream - Override parent for propagation (-P flag)
    • branch - Branch spec for integrate/populate (-b flag)
    • file_paths - File paths for propagation
    • preview - Preview only, no changes (-n flag)
    • force - Force operation (-f flag)
    • reverse - Reverse direction (-r flag)
    • max_files - Limit files processed (-m flag)
    • quiet - Suppress informational messages (-q flag)
    • output_base - Show base revision with scheduled resolve (-Ob flag for merge/integrate) or list files created (-o flag for populate)
    • virtual - Copy using virtual stream (-v flag, copy only)
    • schedule_branch_resolve - Schedule branch resolves instead of automatic branching (-Rb flag, integrate only)
    • integrate_around_deleted - Integrate around deleted revisions (-Di flag, integrate only)
    • skip_cherry_picked - Skip cherry-picked revisions already integrated (-Rs flag, integrate only)
    • source_path, target_path - Source and target paths for populate
    • workspace - Workspace name for switch
    • workspace_name, root, host, alt_roots - Workspace creation parameters
  • Safety: Stream existence validation, locked stream detection, bound workspace warnings, open file checks for view-affecting changes
  • Use cases: Stream creation and management, branch propagation (merge/copy/integrate), spec conflict resolution, workspace provisioning

Warnings in tool responses

When a P4 command produces a benign informational or warning message (for example, file(s) up-to-date or file not on client), the tool returns a success status and includes the message text in an optional top-level warnings list. The field appears only when there is at least one warning. Genuine failures are unaffected and still return an error status with the existing code and error fields.

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