Skip to main content
Glama
torshepherd

Compiler Explorer MCP

by torshepherd

list_compilers_for_language

Retrieve available compilers for a programming language to enable code compilation and optimization analysis.

Instructions

Get available compilers for a specific programming language.

Args:
    language: Programming language to get compilers for (e.g., 'cpp', 'rust')

Returns:
    List of unversioned compiler names available for the language

Raises:
    HTTPException: If the API request fails

Example:
    >>> await list_compilers_for_language("cpp")
    ["gcc", "clang", "msvc"]

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
languageYes

Implementation Reference

  • The main handler function for the 'list_compilers_for_language' tool, decorated with @mcp.tool() for registration. It fetches compilers for the specified language using ce_client, extracts unversioned names, and returns a unique list.
    @mcp.tool()
    async def list_compilers_for_language(language: str) -> list[str]:
        """Get available compilers for a specific programming language.
    
        Args:
            language: Programming language to get compilers for (e.g., 'cpp', 'rust')
    
        Returns:
            List of unversioned compiler names available for the language
    
        Raises:
            HTTPException: If the API request fails
    
        Example:
            >>> await list_compilers_for_language("cpp")
            ["gcc", "clang", "msvc"]
        """
        try:
            compilers = await ce_client.list_compilers(language)
            return list(
                {get_unversioned_compiler_name(c["name"], c["semver"]) for c in compilers}
            )
        except CompilerExplorerError as e:
            raise HTTPException(status_code=e.status_code, detail=str(e))
  • Helper utility function used by the handler to derive unversioned compiler names from full names and semantic versions.
    def get_unversioned_compiler_name(compiler_name: str, semver: str) -> str:
        """Get the unversioned compiler name from the versioned name.
    
        Args:
            compiler_name: Full compiler name including version
            semver: Version string to remove
    
        Returns:
            Cleaned compiler name without version information
    
        Example:
            >>> get_unversioned_compiler_name("gcc-12.2", "12.2")
            "gcc"
        """
        return (
            compiler_name.replace(semver, "").replace("none", "").replace("()", "").strip()
        )
Behavior3/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 discloses that the tool makes an API request and can raise an HTTPException on failure, adding useful behavioral context. However, it lacks details on rate limits, authentication needs, or pagination behavior, which are relevant for a tool that fetches data.

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, starting with the core purpose, followed by structured sections for Args, Returns, Raises, and an Example. Every sentence adds value 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 low complexity (1 parameter, no output schema), the description is mostly complete, covering purpose, input, output, errors, and an example. It could improve by specifying the return format more precisely (e.g., list structure) or mentioning any dependencies, but it adequately supports tool selection and invocation.

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?

With 0% schema description coverage, the description compensates well by explaining the 'language' parameter's purpose and providing an example with values ('cpp', 'rust'). This adds meaningful semantics beyond the basic schema, though it could further clarify allowed language formats or constraints.

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

Purpose5/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 with a specific verb ('Get') and resource ('available compilers for a specific programming language'), distinguishing it from siblings like 'list_compiler_versions' (which focuses on versions) and 'list_languages' (which lists languages).

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

Usage Guidelines4/5

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

The description implies usage context by specifying the input parameter ('language') and providing an example, but does not explicitly state when to use this tool versus alternatives like 'list_compiler_versions' or 'compile_code'. It clearly indicates the tool's scope but lacks explicit exclusions or comparisons.

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/torshepherd/compiler-explorer-mcp'

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