Skip to main content
Glama

list_projects

Retrieve accessible GitLab projects with search filters and pagination controls to manage project visibility.

Instructions

列出可存取的 GitLab 專案

Args: search: 搜尋關鍵字(專案名稱) membership: 僅列出已加入的專案(預設 True) page: 頁碼(預設 1) per_page: 每頁筆數(預設 20,最大 100)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchNo
membershipNo
pageNo
per_pageNo

Implementation Reference

  • The 'list_projects' MCP tool implementation in server.py. It handles tool registration with @mcp.tool(), validates input via GitLab client, and formats the output for the user.
    @mcp.tool()
    def list_projects(search: str = None, membership: bool = True,
                      page: int = 1, per_page: int = 20) -> str:
        """列出可存取的 GitLab 專案
    
        Args:
            search: 搜尋關鍵字(專案名稱)
            membership: 僅列出已加入的專案(預設 True)
            page: 頁碼(預設 1)
            per_page: 每頁筆數(預設 20,最大 100)
        """
        try:
            client = get_client()
            projects = client.list_projects(search=search, membership=membership,
                                            page=page, per_page=per_page)
            if not projects:
                return "找不到符合條件的專案"
    
            lines = [f"找到 {len(projects)} 個專案:\n"]
            for p in projects:
                desc = p.get("description") or ""
                if len(desc) > 60:
                    desc = desc[:60] + "..."
                lines.append(
                    f"- [{p['id']}] {p['path_with_namespace']}"
                    f"\n  {desc}"
                    f"\n  預設分支: {p.get('default_branch', 'N/A')} | {p.get('web_url', '')}\n"
                )
            return "\n".join(lines)
        except GitLabAPIError as e:
            return f"列出專案失敗: {str(e)}"

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/snowild/gitlab-mcp'

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