Configuring AI Remediation for Static Analysis
Perforce QAC includes an MCP server that provides information (such as diagnostic details, fix guidelines, and checker documentation) from static analysis tools to AI assistants (such as GitHub Copilot Chat) in a standardized, tool-agnostic format.
This allows AI assistants to generate high-quality, compliant fixes for detected issues, based on analysis results.
You can integrate the MCP Server provided with Perforce QAC to suggest code fixes for issues identified by Perforce QAC.
To use AI remediation feature, you will require the following:
- An active internet connection
- The latest version of Visual Studio Code (VSCode)
- The latest Perforce QAC Visual Studio Code extension (installed via VSIX file)
- MCP Servers Marketplace enabled in VS Code. You can enable this by clicking MCP Servers in the Extensions and then clicking Enable MCP Servers Marketplace
-
The P4SA MCP Server. You can find this in the QAC components folder - see Configuring the MCP Server for more information.
- A GitHub account
- GitHub Copilot or Copilot Chat Extension (installed from Visual Studio Marketplace)
- (Optional) An API key if using a custom large language model (LLM) instead of presets
Configure Copilot Chat
To configure Copilot Chat in your VS Code IDE:
- In VS Code, open Copilot Chat settings.
- From the drop-down, set Copilot to Agent Mode.
- From the drop-down, select the LLM to use. To use a custom LLM, select Manage models, select a provider, and enter your API key.
Configuring the MCP Server
To install the MCP server in VS Code:
- Click Ctrl+Shift+P > MCP:Add server
- Select Command (stdio) > insert the following command:
- Give the MCP server a name: P4-SA-MCP
- Select whether you want it to run Globally or just in the current Workspace.
- Start your server. You can do this using the Ctrl+Shift+X shortcut, then click MCP Servers > Gear > Start Server
If you did not install to this location, change this command to match the path of your installation.
You can now see the log for the MCP server in the output window. If it does not automatically display the MCP logs, select MCP: P4-SA-MCP from the list.
The MCP server is now available to be used in the Perforce QAC Visual Studio Code plugin when you view diagnostics produced by analysis and select the Fix with QAC Tools menu option.
Running AI Remediation
AI remediation works for defects identified by Perforce QAC in VS Code. To run the AI remediation:
- Right-click a defect and select Fix using QAC tools.
- The VS Code plugin generates an agentic request that will use the QAC tools provided by the MCP server.
- For initial requests, VS Code will ask for access to the MCP Server QAC tools. For the first few fixes your can allow each prompt individually and review the results of each step if you wish.
- Once you are comfortable with the AI process you can select Always allow/Allow without review each time.
- The tool generates a fix based on the details provided by the MCP tools:
- Fix requirements - The prompt used to guide the AI agent, including instructions about what it should or should not do.
- Diagnostic info - The details of the problem found by QAC.
- Diagnostic help - Describing the issue and possible solutions.
Configuring Fix Requirements
The MCP server has built-in fix requirements that guide the AI agent fixing the problems found. However, you can add additional instructions to improve accuracy of the fixes.
To do this, you need to create a mark-down file in your user home folder:
The location of this folder will vary. For example:
On Windows:
On Linux:
The contents of this file will be added to the end of the default fix requirements provided by the MCP Server.
USER_FIX_REQUIREMENTS.MD, and if you have an existing CoPilot session, you should start a new one in order for the changes to be detected.