gitlab_get_current_project
Auto-detect and fetch GitLab project details from a local git repository by examining git remotes. Works without parameters, identifying GitLab URLs and retrieving project data via API.
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-108 (handler)The main handler function that implements the gitlab_get_current_project tool. It extracts the optional path argument (defaults to current directory), calls the GitLab client's get_current_project method to detect the project from git remotes, and returns the project details or an error if none 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
- src/mcp_gitlab/server.py:190-199 (schema)The input schema definition for the tool, specifying an optional 'path' parameter of type string for the git repository path (defaults to current directory). This is part of the @server.list_tools() implementation.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:1023-1025 (registration)The TOOL_HANDLERS dictionary maps the tool name TOOL_GET_CURRENT_PROJECT to its handler function handle_get_current_project. This mapping is used by the server.call_tool() to dispatch tool calls.TOOL_GET_PROJECT: handle_get_project, TOOL_GET_CURRENT_PROJECT: handle_get_current_project, TOOL_GET_MR_NOTES: handle_get_merge_request_notes,
- src/mcp_gitlab/server.py:1251-1257 (registration)The @server.call_tool() handler that looks up the tool name in TOOL_HANDLERS and executes the corresponding handler function with the GitLab client and arguments.handler = TOOL_HANDLERS.get(name) if not handler: raise ValueError(f"Unknown tool: {name}") # Execute the handler result = handler(client, arguments)
- src/mcp_gitlab/constants.py:185-185 (helper)Constant defining the canonical tool name string used throughout the codebase for registration and references.TOOL_GET_CURRENT_PROJECT = "gitlab_get_current_project"