Skip to main content
Glama

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:

  1. Checks git remotes in current/specified directory

  2. Identifies GitLab URLs

  3. Fetches project details from API

Related tools:

  • gitlab_get_project: When you know the project ID

  • gitlab_list_projects: Browse available projects

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoLocal 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

  • 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
  • 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} } } ),
  • 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,
  • 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)
  • Constant defining the canonical tool name string used throughout the codebase for registration and references.
    TOOL_GET_CURRENT_PROJECT = "gitlab_get_current_project"

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Vijay-Duke/mcp-gitlab'

If you have feedback or need assistance with the MCP directory API, please join our Discord server