list_groups
Retrieve a paginated list of GitLab groups. Specify the number of groups per page and an optional access token for authentication.
Instructions
List GitLab groups.
Args:
per_page: Number of groups per page (max 100)
token: GitLab Personal Access Token (optional)
ctx: MCP context (automatically injected)Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| per_page | No | ||
| token | No | ||
| ctx | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The list_groups tool handler function. It calls GitLab API /groups endpoint, paginates with per_page (max 100), and returns a formatted list of group names, paths, and IDs.
async def list_groups(per_page: int = 20, token: str = None, ctx=None) -> str: """List GitLab groups. Args: per_page: Number of groups per page (max 100) token: GitLab Personal Access Token (optional) ctx: MCP context (automatically injected) """ per_page = min(per_page, 100) data = await make_gitlab_request(f"/groups?per_page={per_page}", ctx=ctx, token=token) if isinstance(data, dict) and "error" in data: return f"Error: {data['error']}" if not data: return "No groups found." groups = [] for group in data: groups.append(f"• {group['name']} ({group['path']}) - ID: {group['id']}") return "\n".join(groups) - gitlab_clone_mcp_server/server.py:247-265 (registration)The tool is registered via the @mcp.tool() decorator on the list_groups function at line 246.
async def list_groups(per_page: int = 20, token: str = None, ctx=None) -> str: """List GitLab groups. Args: per_page: Number of groups per page (max 100) token: GitLab Personal Access Token (optional) ctx: MCP context (automatically injected) """ per_page = min(per_page, 100) data = await make_gitlab_request(f"/groups?per_page={per_page}", ctx=ctx, token=token) if isinstance(data, dict) and "error" in data: return f"Error: {data['error']}" if not data: return "No groups found." groups = [] for group in data: groups.append(f"• {group['name']} ({group['path']}) - ID: {group['id']}") return "\n".join(groups)