Dependabot Integration
Relevant source files
The following files were used as context for generating this wiki page:
The Dependabot Integration within the GitHub MCP Server provides tools to interact with GitHub's Dependabot alerts. It allows Model Context Protocol (MCP) clients to retrieve detailed information about specific security vulnerabilities and list all alerts associated with a repository, filtered by state or severity.
This module is part of the code_security toolset group. It leverages the GitHub REST API through the google/go-github library to expose read-only security data to AI agents and other MCP-compatible interfaces.
Sources: pkg/github/dependabot.go:1-12, cmd/github-mcp-server/generate_docs.go:174-176
Architecture and Components
The integration is built as a set of MCP tools that wrap the GitHub Dependabot API. Each tool consists of a definition (providing metadata and input schema) and a handler function that executes the actual API calls.
Data Flow for Dependabot Tools
The diagram below illustrates the typical request-response flow when an MCP client invokes a Dependabot tool.
The flow begins with parameter extraction, followed by a GitHub client authorization check, and ends with the marshaling of GitHub API responses into MCP-compliant text results.
Sources: pkg/github/dependabot.go:42-65, pkg/github/dependabot.go:106-130
Core Tools
The integration exposes two primary tools: get_dependabot_alert and list_dependabot_alerts. These tools are marked with a ReadOnlyHint to indicate they do not modify repository state.
Get Dependabot Alert
This tool retrieves the details of a single alert using its unique alert number.
| Parameter | Type | Required | Description |
|---|---|---|---|
owner | String | Yes | The owner of the repository. |
repo | String | Yes | The name of the repository. |
alertNumber | Number | Yes | The number of the alert. |
Sources: pkg/github/dependabot.go:17-36
List Dependabot Alerts
This tool allows for broad retrieval of alerts with optional filtering capabilities.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
owner | String | Yes | - | The owner of the repository. |
repo | String | Yes | - | The name of the repository. |
state | String | No | open | Filter by: open, fixed, dismissed, auto_dismissed. |
severity | String | No | - | Filter by: low, medium, high, critical. |
Sources: pkg/github/dependabot.go:81-101
Logic and Data Structures
The integration utilizes specific data structures from the google/go-github library to represent security information.
Key Data Structures
github.DependabotAlert: The primary object returned by the tools, containing fields such asNumber,State, andHTMLURL.github.DependabotSecurityAdvisory: Nested within an alert, providing severity levels (e.g., "critical", "high").github.ListAlertsOptions: Used by theListRepoAlertsmethod to pass filters for state and severity to the GitHub API.
Sources: pkg/github/dependabot_test.go:30-34, pkg/github/dependabot_test.go:111-125, pkg/github/dependabot.go:118-121
Handler Implementation Logic
The handlers follow a standardized execution pattern:
- Parameter Validation: Uses
RequiredParamorOptionalParamto extract arguments from themcp.CallToolRequest. - Client Initialization: Calls
getClient(ctx)to obtain a token-authenticated GitHub client. - API Execution: Invokes
client.Dependabot.GetRepoAlertorclient.Dependabot.ListRepoAlerts. - Error Handling: Uses
ghErrors.NewGitHubAPIErrorResponseto provide detailed error context back to the MCP client if the API call fails. - Serialization: Marshals the resulting GitHub structs into a JSON string for the MCP
TextContentresponse.
Sources: pkg/github/dependabot.go:37-76, pkg/github/dependabot.go:102-140
Testing and Validation
The integration includes a robust test suite in pkg/github/dependabot_test.go that uses mocked HTTP clients to simulate GitHub API responses.
The test suite ensures that parameters like state and severity are correctly passed as query parameters and that API errors (like 401 Unauthorized or 404 Not Found) are handled gracefully.
Sources: pkg/github/dependabot_test.go:138-230
Conclusion
Dependabot Integration provides essential security visibility within the GitHub MCP Server. By exposing structured access to vulnerability alerts, it enables automated security auditing and context-aware vulnerability management for developers and AI agents interacting with GitHub repositories.
Sources: pkg/github/dependabot.go:1-15