Skip to main content
Glama
SongJiangzhou

C++ Style Guide MCP Server

suggest_modern_cpp

Upgrade C++ code to modern standards by analyzing existing code and providing specific suggestions with rewrite examples for newer C++ versions.

Instructions

建议将代码升级为现代 C++ 写法

参数:
    code: 要分析的 C++ 代码
    target_standard: 目标 C++ 标准,可选值:
                    - cpp11: C++11
                    - cpp14: C++14
                    - cpp17: C++17 (默认)
                    - cpp20: C++20
                    - cpp23: C++23

返回:
    现代化建议报告,包括可以使用的新特性和重写示例

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
target_standardNocpp17

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler and registration for 'suggest_modern_cpp'. Delegates to ModernCppSuggester instance.
    @mcp.tool()
    def suggest_modern_cpp(code: str, target_standard: str = "cpp17") -> str:
        """
        建议将代码升级为现代 C++ 写法
    
        参数:
            code: 要分析的 C++ 代码
            target_standard: 目标 C++ 标准,可选值:
                            - cpp11: C++11
                            - cpp14: C++14
                            - cpp17: C++17 (默认)
                            - cpp20: C++20
                            - cpp23: C++23
    
        返回:
            现代化建议报告,包括可以使用的新特性和重写示例
        """
        suggester = get_modern_cpp_suggester()
        suggestions, report = suggester.suggest_modern_cpp(code, target_standard)
        return report
  • Core implementation of modern C++ suggestions in ModernCppSuggester class. Uses regex to detect patterns and collects suggestions per C++ standard.
    def suggest_modern_cpp(self, code: str, target_standard: str = "cpp17") -> Tuple[List[Dict], str]:
        """
        建议将代码升级为现代 C++ 写法
    
        Args:
            code: 要分析的 C++ 代码
            target_standard: 目标标准 (cpp11, cpp14, cpp17, cpp20, cpp23)
    
        Returns:
            (建议列表, 格式化的建议报告)
        """
        suggestions = []
    
        # 根据目标标准检查可用特性
        if target_standard in ['cpp11', 'cpp14', 'cpp17', 'cpp20', 'cpp23']:
            suggestions.extend(self._check_cpp11_features(code))
    
        if target_standard in ['cpp14', 'cpp17', 'cpp20', 'cpp23']:
            suggestions.extend(self._check_cpp14_features(code))
    
        if target_standard in ['cpp17', 'cpp20', 'cpp23']:
            suggestions.extend(self._check_cpp17_features(code))
    
        if target_standard in ['cpp20', 'cpp23']:
            suggestions.extend(self._check_cpp20_features(code))
    
        if target_standard == 'cpp23':
            suggestions.extend(self._check_cpp23_features(code))
    
        # 生成报告
        report = self._generate_report(suggestions, target_standard)
    
        return suggestions, report
  • Singleton factory function to get the ModernCppSuggester instance, used by the tool handler.
    # 全局实例
    _suggester = None
    
    def get_suggester() -> ModernCppSuggester:
        """获取全局现代 C++ 建议器实例"""
        global _suggester
        if _suggester is None:
            _suggester = ModernCppSuggester()
        return _suggester
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions the tool '建议' (suggests) upgrades and returns a report, but lacks details on behavioral traits like whether it modifies code, requires specific permissions, handles errors, or has rate limits. For a tool with no annotations, this is insufficient disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with a clear purpose statement followed by structured parameter and return sections. Every sentence earns its place by providing essential information without redundancy, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (code analysis with parameter options), no annotations, and an output schema (implied by '返回' section), the description is fairly complete. It covers purpose, parameters, and return values, but could improve by adding more behavioral context or usage guidelines to fully compensate for the lack of annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains that 'code' is the C++ code to analyze and 'target_standard' is the target C++ standard with optional values and default, including a detailed enum-like list. This compensates well for the low schema coverage, though it doesn't cover all possible parameter nuances.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '建议将代码升级为现代 C++ 写法' (suggests upgrading code to modern C++ style). It specifies the verb '建议' (suggest) and resource '代码' (code), but doesn't explicitly differentiate from sibling tools like 'analyze_memory_safety' or 'check_const_correctness', which focus on specific aspects rather than general modernization.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention sibling tools or contexts where this tool is preferred, such as for general code modernization versus specific checks like memory safety or naming conventions. Usage is implied but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SongJiangzhou/cpp_guidelines_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server