gitlab_get_current_project
Retrieve current GitLab project details by automatically detecting the repository from git remotes. No parameters needed when working in a git repository with GitLab remote.
Instructions
Auto-detect project from git repository Returns: Same as gitlab_get_project Use when: Working in a git repo with GitLab remote No parameters needed: Examines git remotes
How it works:
Checks git remotes in current/specified directory
Identifies GitLab URLs
Fetches project details from API
Related tools:
gitlab_get_project: When you know the project ID
gitlab_list_projects: Browse available projects
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Local git repository path Type: string Format: Absolute or relative file system path Default: '.' (current directory) Examples: - '.' (current directory) - '/home/user/projects/my-app' (absolute path) - '../other-project' (relative path) - '~/repos/gitlab-project' (home directory) Use case: Detect project from a different directory |
Implementation Reference
- src/mcp_gitlab/tool_handlers.py:100-107 (handler)The primary handler function for the 'gitlab_get_current_project' tool. It extracts an optional 'path' argument (defaults to current directory), calls the GitLabClient's get_current_project method to detect the project from git remotes, and returns the project details or an error if no GitLab project is found.def handle_get_current_project(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]: """Handle getting current project using git detection""" path = get_argument(arguments, "path", ".") result = client.get_current_project(path) if not result: return {"error": ERROR_NO_PROJECT} return result
- The MCP tool schema definition specifying the input parameters (optional 'path' string for git directory) and description for 'gitlab_get_current_project'.types.Tool( name=TOOL_GET_CURRENT_PROJECT, description=desc.DESC_GET_CURRENT_PROJECT, inputSchema={ "type": "object", "properties": { "path": {"type": "string", "description": desc.DESC_GIT_PATH} } } ),
- src/mcp_gitlab/tool_handlers.py:1024-1024 (registration)Registration of the handler function in the TOOL_HANDLERS dictionary mapping, used by the MCP server to dispatch tool calls to the correct implementation.TOOL_GET_CURRENT_PROJECT: handle_get_current_project,
- src/mcp_gitlab/server.py:191-199 (registration)Tool registration in the MCP server's list_tools() method, defining the tool schema and description exposed to clients.name=TOOL_GET_CURRENT_PROJECT, description=desc.DESC_GET_CURRENT_PROJECT, inputSchema={ "type": "object", "properties": { "path": {"type": "string", "description": desc.DESC_GIT_PATH} } } ),
- src/mcp_gitlab/constants.py:185-185 (helper)Constant definition for the tool name string used consistently across the codebase for registration and references.TOOL_GET_CURRENT_PROJECT = "gitlab_get_current_project"