get_project_labels
Retrieve all labels from a specified GitLab project using its project ID. Optionally authenticate with a personal access token.
Instructions
Get project labels.
Args:
project_id: GitLab project ID
token: GitLab Personal Access Token (optional)
ctx: MCP context (automatically injected)Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| token | No | ||
| ctx | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The 'get_project_labels' async function is the MCP tool handler that fetches project labels from the GitLab API. It is registered as an MCP tool via the @mcp.tool() decorator on line 620. It takes a project_id parameter, calls the GitLab API endpoint /projects/{project_id}/labels, and formats the labels as a bulleted list showing each label's name and color.
# Labels @mcp.tool() async def get_project_labels(project_id: int, token: str = None, ctx=None) -> str: """Get project labels. Args: project_id: GitLab project ID token: GitLab Personal Access Token (optional) ctx: MCP context (automatically injected) """ data = await make_gitlab_request(f"/projects/{project_id}/labels", ctx=ctx, token=token) if isinstance(data, dict) and "error" in data: return f"Error: {data['error']}" if not data: return "No labels found." labels = [] for label in data: labels.append(f"• {label['name']} ({label['color']})") return "\n".join(labels) - gitlab_clone_mcp_server/server.py:619-620 (registration)The tool is registered as an MCP tool using the @mcp.tool() decorator on line 620, which is the FastMCP instance defined on line 9.
# Labels @mcp.tool()