C/C++test CT provides an MCP (Model Context Protocol) Server extension that allows you to smoothly integrate your LLM agents or applications (for example, Copilot) with C/C++test CT functionality. The C/C++test CT MCP Server can be integrated within any LLM-based development environment that supports MCP Server integration, including VS Code and other environments. With this extension, an LLM agent can interact directly with C/C++test CT, providing context-aware guidance and analysis.
This extension allows you to use your LLM agents to:
- Retrieve line coverage information for analyzed code.
- Provide guidance and instructions for applying coverage suppressions to specific code sections.
- 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 CT.
Configuring the VS Code IDE to Use the MCP Server with Copilot Chat
- In VS Code, go to the Command Palette, and choose MCP: Add Server...
- Select Command (stdio) and press ENTER to confirm.
- Enter the MCP server launcher: <
INSTALL_DIR>/integration/mcp/cpptestmcp - Specify the Server ID.
Choose where to save the configuration:
User Settings - available in all workspaces
Workspace settings - available in this workspace
A JSON file will be created containing the MCP configuration.
- The MCP server entry is added to MCP servers JSON configuration file.
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 the uncovered lines in goo.cpp.
- Which lines in this file are coverable?
- Suppress line coverage in line 15 with the reason "Unreachable code".
- What is Simple Condition Coverage?
Consider using instruction files to explicitly describe your project structure (for example, the location of coverage data files) or to define more complex workflows.
MCP Server Tools Reference
| Tool | Description |
|---|---|
query_line_coverage | Returns line coverage information for a source file. Analyzes coverage data files (.cov) to provide a list of line numbers based on the query type: 'coverable', 'covered', 'notcovered', 'suppressed'. |
| how_to_suppress_coverage | Returns instructions on how to apply coverage suppressions in C/C++test CT. Provides guidance on suppressing coverage analysis for specific lines, functions, or code sections that should be excluded from coverage reporting. |
search_documentation | Searches the C/C++test CT documentation to retrieve relevant pages matching the user query. Returns the content of each page and its source URL. Use this tool to learn about code coverage and unit testing. |