Configure the Perforce SA MCP server

This section explains how to add the MCP server to your VS Code configuration to fix Klocwork defects with AI assistance.

  1. From the VS Code Command palette, go to MCP: Add Server... > Command (stdio).
  2. Add the command to run the downloaded MCP server, specifying the command-line tools location that contains Kwcheck. For example:
  3. /space/kw/mcp_desktop/mcp_desktop_run.bat --klocwork-cmd-path=/space/kw/cmd/bin
    To return AI responses in a specified language, add the --locale parameter (for example, --locale=JA or --local=EN).
  4. Specify the MCP server name (for example, p4-sa).
  5. Save the configuration as Global or Local.

An mcp.json file is created. For example:

Copy
{
    "servers": {
        "Perforce-SA": {
            "type": "stdio",
            "command": "/space/kw/mcp_desktop/mcp_desktop_run.bat",
            "args": [
                "--klocwork-cmd-path=/space/kw/cmd/bin"
            ]
        }
    },
    "inputs": []
}

The mcp.json file will appear in one of the following:

  • Local configuration: the .vscode subdirectory of your project
  • Global configuration: the C:\Users\{username}\AppData\Roaming\Code\User directory

The MCP server will appear under Extensions > MCP Servers: Installed. From here, you can control the server, check the configuration file, and view output.

To augment how the final fix will look, add user fix requirements to a .sa-mcp-desktop/KW_USER_FIX_REQUIREMENTS.MD file inside your user home directory (case-sensitive for Linux). Use with caution, as user fix requirements can affect the accuracy of the final result.