Skip to main content
Glama
rajbos

GHAS MCP server (GitHub Advanced Security)

list_code_scanning_alerts

Retrieve GitHub Advanced Security code scanning alerts for a specific repository to identify and address potential vulnerabilities in your codebase.

Instructions

List the current GitHub Advanced Security code scanning alerts for a repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYes
repoYes

Implementation Reference

  • The core handler function that validates access token and repository permissions, then fetches and returns the list of code scanning alerts using the GitHub Octokit API.
    export async function listCodeScanningAlerts(owner: string, repo: string) {
        const octokit = await validateAccessToken(owner, repo);
    
        console.log(`Fetching code scanning alerts for repository: [${owner}/${repo}]`);
        try {
            const { data } = await octokit.codeScanning.listAlertsForRepo({
                owner,
                repo
            });
            console.log(`Fetched [${data.length}] code scanning alerts.`);
            return data;
        } catch (error) {
            console.error("Error fetching code scanning alerts:", error);
            throw error;
        }
    }
  • src/index.ts:49-55 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining the tool name, description, and input schema (owner and repo strings).
        name: "list_code_scanning_alerts",
        description: "List the current GitHub Advanced Security code scanning alerts for a repository",
        inputSchema: zodToJsonSchema(z.object({
            owner: z.string(),
            repo: z.string(),
        })),
    },
  • src/index.ts:82-88 (registration)
    Dispatch logic in the CallToolRequestSchema handler that validates input arguments, calls the handler function, and formats the response as JSON text.
    case "list_code_scanning_alerts": {
        const args = z.object({ owner: z.string(), repo: z.string() }).parse(request.params.arguments);
        const alerts = await listCodeScanningAlerts(args.owner, args.repo);
        return {
            content: [{ type: "text", text: JSON.stringify(alerts, null, 2) }],
        };
    }
  • Helper function to retrieve and validate the GitHub token (from env or gh CLI), create Octokit instance, and check admin permissions on the repository.
    async function validateAccessToken(owner: string, repo: string): Promise<Octokit> {
    
        console.log("Validating GitHub Personal Access Token...");
    
        let authToken = null;
        if (process.env.GITHUB_PERSONAL_ACCESS_TOKEN_USE_GHCLI) {
            const token = getGitHubToken();
            authToken = token;
        } else {
            if (!process.env.GITHUB_PERSONAL_ACCESS_TOKEN) {
                throw new Error("GITHUB_PERSONAL_ACCESS_TOKEN is not set in environment variables. This is needed to be able to find code scanning alerts.");
            } else {
                console.log(`GITHUB_PERSONAL_ACCESS_TOKEN is set in environment variables with length: [${process.env.GITHUB_PERSONAL_ACCESS_TOKEN.length}]`);
                authToken = process.env.GITHUB_PERSONAL_ACCESS_TOKEN.trim();
            }
        }
    
        const octokit = new Octokit({
            auth: authToken
        });
    
        // Validate token access and scope
        try {
            console.log("Starting to validate token access and scope...");
            const user = await octokit.rest.users.getAuthenticated();
            console.log(`Authenticated as: [${user.data.login}]`);
            const repoInfo = await octokit.rest.repos.get({
                owner,
                repo
            });
    
            console.log(`Repository information fetched: [${repoInfo.data.name}]`);
            if (!repoInfo.data.permissions || !repoInfo.data.permissions.admin) {
                throw new Error("The provided token does not have admin access to the repository. Admin access is required to fetch security information.");
            } else {
                console.log("Token has admin access to the repository.");
            }
            console.log("Token has sufficient permissions for the repository.");
        } catch (error) {
            console.error("Error validating token or repository access:", error);
            throw new Error("Failed to validate token or repository access. Ensure the token has the necessary scopes and permissions.");
        }
    
        return octokit;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'List the current... alerts' but does not specify whether this is a read-only operation, if it requires authentication, rate limits, pagination, or what the output format entails. This leaves significant gaps in understanding the tool's behavior.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and appropriately sized, making it easy to parse quickly.

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

Completeness2/5

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

Given the tool's complexity (listing security alerts), lack of annotations, and no output schema, the description is incomplete. It does not cover behavioral aspects like permissions, response format, or error handling, which are crucial for effective use. The description alone is insufficient for an agent to fully understand how to invoke and interpret results.

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

Parameters3/5

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

The input schema has 0% description coverage, but the description does not add any meaning to the parameters 'owner' and 'repo' beyond implying they relate to a GitHub repository. Since there are only 2 parameters, the baseline is 4, but the description fails to compensate for the lack of schema details, such as explaining what 'owner' and 'repo' represent, resulting in a score of 3.

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 verb ('List') and resource ('GitHub Advanced Security code scanning alerts for a repository'), making the tool's purpose specific and understandable. However, it does not explicitly differentiate from sibling tools like 'list_dependabot_alerts' or 'list_secret_scanning_alerts', which prevents a score of 5.

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?

The description provides no guidance on when to use this tool versus alternatives, such as the sibling tools for Dependabot or secret scanning alerts. It lacks any context about prerequisites, exclusions, or specific scenarios where this tool is preferred, offering only a basic statement of function.

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

Related 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/rajbos/ghas-mcp-server'

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