C/C++test provides an MCP (Model Context Protocol) Server extension that allows you to smoothly integrate your AI agents or applications (for example, Copilot) with C/C++test functionality. The C/C++test MCP Server can be integrated within any LLM-based development environment that supports MCP Server integration, including Eclipse and other environments. With this extension, an AI agent can interact directly with C/C++test, providing context-aware guidance and analysis.
This extension allows you to use your AI agents to:
- Retrieve details about static analysis rules.
Review static analysis violations reported in your project.
Suggest fixes for violations based on provided code snippets or files.
- Suggest rules that are appropriate for specific issues.
- Access information from the product user guide.
The MCP server launcher is located in the <INSTALL_DIR>/integration/mcp directory.
The following procedure demonstrates how to integrate an LLM-based agent (using Copilot as an example) with C/C++test.
Configuring the Eclipse IDE to Use the MCP Server with Copilot Chat
- In Eclipse, go to the chat window, and select the Agent mode from the combo box.
- Click the Configure Tools... button.
- In the GitHub Copilot/MCP window, in the MCP Servers field, create a new Server Configuration:
- Specify the Server ID.
- Specify stdio as the server type.
- Set the path to MCP server launcher as the server command:
<INSTALL_DIR>/integration/mcp/cpptestmcp.exe
- Click Save.
- The MCP Server tools are added and appear in the tool picker. You can enable or disable the tools you want to use.
Using the MCP Tools with Copilot Chat
After configuring the MCP server, you can use the provided MCP tools in Copilot Chat.
Example prompts:
- List all severity-1 violations in goo.cpp.
- Suggest a fix for the violation in line 10.
- Explain the BD-PB-ARRAY rule.
- How to suppress static analysis violations?
Consider using instruction files to explicitly describe your project structure (for example, the location of the report.xml file) or to define more complex workflows.
Using Instructions in Copilot
In some cases, Copilot does not invoke Parasoft MCP tools. To ensure that Parasoft MCP tools are called, you can add custom instructions.
In the Copilot Chat window, click your profile picture, and click Personal instructions.
Add natural language instructions to the text box, for example:
With the instructions provided in the example above, Copilot will use the get_violations_from_report_file tool to extract violations from report.xml (rather than attempting to analyze the file on its own) and will use get_rule_documentation to retrieve documentation details.When analyzing a report containing violations, use the get_violations_from_report_file tool to review the report and provide insights or suggestions based on the findings. Use the get_rule_documentation tool to get information about the violations, their severity, and possible remediation steps.
- Click Save.
MCP Server Tools Reference
| Tool | Description | Notes |
|---|---|---|
| get_relevant_rules | Returns a list of static analysis rules matching the user query. Each entry contains the rule header and a comma-separated list of corresponding rule identifiers. | |
| get_rule_documentation | Returns the documentation for the static analysis rule together with a path to the original documentation file for reference. | An exact rule ID must be provided, for example, BD-PB-ARRAY. |
| get_violations_from_report_file | Extracts violations from a report XML file and outputs them in JSON format along with key details. Results are refined using optional filters: rule ID, severity and source file name. | An absolute path to the report XML file must be provided. The server must have local access to the file. Alternatively, you can use the Copy action in the Quality Tasks View to copy selected violation descriptions to the clipboard and paste them into the Copilot Chat window to request fixes. |
| search_documentation | Searches the documentation to retrieve relevant pages matching the user query. Returns the content of each page and its source URL. To search static analysis rule documentation, use get_rule_documentation or get_relevant_rules tools. |