Logo MCP Perforce Server

MCP Perforce Server

Tổ chức
Cocoon-AI

MCP Perforce Server

Nhà phát hànhCocoon-AI
Kho mãmcp-perforce
Ngôn ngữTypeScript
Bản fork
5
Sao
29
Công cụ có sẵn
24
Phương thức truyền tảistdio
Danh mục
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    MCP Perforce Server cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 24 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    29 sao và 5 bản fork từ kho mã được liên kết.

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

Installation

Prerequisites

  • Node.js 18+ installed
  • Perforce command-line client (p4) installed and in your PATH
  • .p4config files in your project directories (recommended)

Quick Install with Claude Code

bash
# Install the package globally
npm install -g @cocoon-ai/mcp-perforce

# Add to Claude Code
claude mcp add perforce @cocoon-ai/mcp-perforce

That's it! Claude Code will automatically configure the server for you.

Manual Installation

Via NPM (when published)

bash
npm install -g @cocoon-ai/mcp-perforce

Install from Source

bash
git clone https://github.com/Cocoon-AI/mcp-perforce.git
cd mcp-perforce
npm install
npm run build
npm link  # Makes 'mcp-perforce' available globally

Configuration

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

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:

bash
# ~/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-username

Now 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

  1. Restart Claude Desktop after modifying the configuration
  2. Check that the configuration file is valid JSON
  3. Verify the MCP server is installed: npm list -g @cocoon-ai/mcp-perforce

Perforce authentication errors

  1. Check your .p4config file exists and has the correct settings
  2. Test your connection outside Claude: p4 info
  3. Make sure you're logged in: p4 login
  4. Verify P4CONFIG is being recognized: p4 set P4CONFIG

Wrong Perforce server being used

  1. Check which directory you're in - the server uses .p4config from the current or parent directories
  2. Run p4 info to see which config is being used
  3. Use the p4_info command in Claude to debug: "Show me my P4 configuration"

Command not working as expected

  1. Check Claude's response for error messages
  2. Verify the P4 command works in your terminal from the same directory
  3. Enable debug logging (see below)

Debug Logging

To enable debug output, add to your configuration:

json
{
  "mcpServers": {
    "perforce": {
      "command": "npx",
      "args": ["-y", "@cocoon-ai/mcp-perforce"],
      "env": {
        "P4CONFIG": ".p4config",
        "DEBUG": "mcp:*"
      }
    }
  }
}

Development

Building from source

bash
git clone https://github.com/Cocoon-AI/mcp-perforce.git
cd mcp-perforce
npm install
npm run build

Running tests

bash
npm test

Adding new commands

  1. Add the tool definition in the appropriate file under src/tools/
  2. Add the handler function in the corresponding file under src/handlers/
  3. Update the switch statement in src/handlers/index.ts
  4. Follow the existing pattern for parameter validation and error handling

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-command)
  3. Commit your changes (git commit -am 'Add new P4 command')
  4. Push to the branch (git push origin feature/new-command)
  5. Create a Pull Request

License

MIT License - see LICENSE file for details

Acknowledgments

Support


Made with ❤️ for AIs struggling with P4 command-line operations

Cài đặt

TypingMind
{
  "mcpServers": {
    "mcp-perforce": {
      "command": "npx",
      "args": [
        "-y",
        "@cocoon-ai/mcp-perforce"
      ],
      "env": {
        "P4CONFIG": "<P4CONFIG>"
      }
    }
  }
}

Công cụ có sẵn

  • p4_add

    Add files to Perforce

  • p4_edit

    Open files for edit in Perforce

  • p4_delete

    Mark files for deletion in Perforce

  • p4_revert

    Revert files or changelist

  • p4_sync

    Sync files from the depot

  • p4_diff

    Show differences for files

  • p4_changelist_create

    Create a new changelist with a description

  • p4_changelist_submit

    Submit a changelist

  • p4_move_to_changelist

    Move files to a specific changelist

  • p4_status

    Get current P4 workspace status and pending changes

  • p4_info

    Show Perforce configuration info for current directory

  • mcp_perforce_version

    Show MCP Perforce server version

  • p4_stream_list

    List all streams or streams matching a pattern

  • p4_stream_info

    Get detailed information about a specific stream

  • p4_stream_switch

    Switch workspace to a different stream

  • p4_stream_create

    Create a new stream

  • p4_stream_edit

    Edit stream specification

  • p4_stream_graph

    Show stream hierarchy graph

  • p4_client_list

    List all clients/workspaces for the current user

  • p4_client_info

    Get detailed information about a specific client/workspace

  • p4_client_create

    Create a new client/workspace

  • p4_client_edit

    Edit an existing client/workspace specification

  • p4_client_delete

    Delete a client/workspace

  • p4_client_switch

    Switch to a different client/workspace

Dùng MCP MCP Perforce Server với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối MCP Perforce Server, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm MCP Perforce Server làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của MCP Perforce Server.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "mcp-perforce": {
      "command": "npx",
      "args": [
        "-y",
        "@cocoon-ai/mcp-perforce"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của MCP Perforce Server, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của MCP Perforce Server.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng MCP Perforce Server giúp tôi làm việc này không?
MCP Perforce Server
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng MCP Perforce Server.

Câu hỏi thường gặp

Máy chủ MCP MCP Perforce Server dùng để làm gì?

MCP Perforce Server là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP MCP Perforce Server với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng MCP Perforce Server với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP MCP Perforce Server với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối MCP Perforce Server, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP MCP Perforce Server với TypingMind?

MCP Perforce Server hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP MCP Perforce Server cung cấp những công cụ nào trong TypingMind?

MCP Perforce Server cung cấp 24 công cụ MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP MCP Perforce Server không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu MCP Perforce Server yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇