gitlab-mcp-server

by yoda-digital
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Provides tools for interacting with GitLab repositories, including searching, creating, and forking repositories; reading, creating, and updating files; managing branches; handling issues and merge requests; accessing project events and commit history.

Servidor MCP de GitLab

✨ Características

  • Integración completa de la API de GitLab : acceda a repositorios, problemas, solicitudes de fusión, wikis y más
  • Se admiten ambos transportes : se utiliza con stdio o eventos enviados por el servidor (SSE)
  • Formato de respuesta consistente : paginación y estructuras de respuesta estandarizadas
  • Tipificación robusta de TypeScript : creada con el SDK MCP para seguridad de tipos
  • Documentación completa : ejemplos de todas las herramientas disponibles

🔍Operaciones apoyadas

  • Gestión de repositorios : buscar, crear y bifurcar repositorios
  • Manejo de archivos : leer, crear y actualizar archivos
  • Operaciones de sucursales : crear y administrar sucursales
  • Seguimiento de problemas : crear, enumerar y filtrar problemas
  • Solicitudes de fusión : crear, enumerar y revisar solicitudes de fusión
  • Gestión de grupos : enumerar proyectos y miembros del grupo
  • Actividad del proyecto : seguimiento de eventos e historial de confirmaciones
  • Gestión de wikis : soporte completo para wikis de proyectos y grupos con archivos adjuntos
  • Gestión de miembros : enumere y administre a los miembros del proyecto/grupo

🚀 Primeros pasos

Instalación

De npm (recomendado)

npm install @yoda.digital/gitlab-mcp-server

De la fuente

# Clone the repository git clone https://github.com/yoda-digital/mcp-gitlab-server.git cd mcp-gitlab-server # Install dependencies npm install # Build the project npm run build

Configuración

Variables de entorno

El servidor requiere las siguientes variables de entorno:

VariableRequeridoPor defectoDescripción
GITLAB_PERSONAL_ACCESS_TOKEN-Tu token de acceso personal de GitLab
GITLAB_API_URLNohttps://gitlab.com/api/v4URL de la API de GitLab
PORTNo3000Puerto para transporte SSE
USE_SSENofalseEstablezca en 'verdadero' para utilizar el transporte SSE
GITLAB_READ_ONLY_MODENofalseEstablezca en 'verdadero' para habilitar el modo de solo lectura (ver a continuación)

Modo de solo lectura

Cuando GITLAB_READ_ONLY_MODE se establece en true , el servidor solo expondrá operaciones de lectura. Esto es útil para aplicaciones cliente que no deberían tener acceso de escritura a los recursos de GitLab. En el modo de solo lectura, estarán disponibles las siguientes herramientas:

  • search_repositories
  • get_file_contents
  • list_group_projects
  • get_project_events
  • list_commits
  • list_issues
  • list_merge_requests
  • list_project_wiki_pages
  • get_project_wiki_page
  • list_group_wiki_pages
  • get_group_wiki_page
  • list_project_members
  • list_group_members

Cualquier intento de utilizar operaciones de escritura (crear, actualizar, eliminar) generará un error en el modo de solo lectura.

Configuración de ajustes de MCP

Agregue el servidor GitLab MCP a su archivo de configuración de MCP:

{ "mcpServers": { "gitlab": { "command": "npx", "args": ["-y", "@yoda.digital/gitlab-mcp-server"], "env": { "GITLAB_PERSONAL_ACCESS_TOKEN": "your_token_here", "GITLAB_API_URL": "https://gitlab.com/api/v4" }, "alwaysAllow": [], "disabled": false } } }

Para el modo de solo lectura, agregue la variable de entorno GITLAB_READ_ONLY_MODE :

{ "mcpServers": { "gitlab-readonly": { "command": "npx", "args": ["-y", "@yoda.digital/gitlab-mcp-server"], "env": { "GITLAB_PERSONAL_ACCESS_TOKEN": "your_token_here", "GITLAB_API_URL": "https://gitlab.com/api/v4", "GITLAB_READ_ONLY_MODE": "true" }, "alwaysAllow": [], "disabled": false } } }

Uso

Con transporte stdio (predeterminado)

# Set your GitLab personal access token export GITLAB_PERSONAL_ACCESS_TOKEN=your_token_here # Run the server npm start

Con transporte SSE

# Set your GitLab personal access token and enable SSE export GITLAB_PERSONAL_ACCESS_TOKEN=your_token_here export GITLAB_READ_ONLY_MODE=false export USE_SSE=true export PORT=3000 # Optional, defaults to 3000 # Run the server npm start

Con npx

# Run directly with npx GITLAB_PERSONAL_ACCESS_TOKEN=your_token_here npx @yoda.digital/gitlab-mcp-server

🛠️ Herramientas disponibles

Operaciones del repositorio

{ "search": "project-name", "page": 1, "per_page": 20 }
{ "name": "new-project", "description": "A new project", "visibility": "private", "initialize_with_readme": true }
{ "project_id": "username/project", "namespace": "target-namespace" }
{ "group_id": "group-name", "archived": false, "visibility": "public", "include_subgroups": true, "page": 1, "per_page": 20 }

Operaciones con archivos

{ "project_id": "username/project", "file_path": "path/to/file.txt", "ref": "main" }
{ "project_id": "username/project", "file_path": "path/to/file.txt", "content": "File content here", "commit_message": "Add/update file", "branch": "main", "previous_path": "old/path/to/file.txt" }
{ "project_id": "username/project", "files": [ { "path": "file1.txt", "content": "Content for file 1" }, { "path": "file2.txt", "content": "Content for file 2" } ], "commit_message": "Add multiple files", "branch": "main" }

Operaciones de sucursal

{ "project_id": "username/project", "branch": "new-branch", "ref": "main" }

Operaciones de emisión

{ "project_id": "username/project", "title": "Issue title", "description": "Issue description", "assignee_ids": [1, 2], "milestone_id": 1, "labels": ["bug", "critical"] }
{ "project_id": "username/project", "state": "opened", "labels": "bug,critical", "milestone": "v1.0", "author_id": 1, "assignee_id": 2, "search": "keyword", "created_after": "2023-01-01T00:00:00Z", "created_before": "2023-12-31T23:59:59Z", "updated_after": "2023-06-01T00:00:00Z", "updated_before": "2023-06-30T23:59:59Z", "page": 1, "per_page": 20 }
{ "project_id": "username/project", "issue_iid": 42, "sort": "desc", "order_by": "created_at", "page": 1, "per_page": 20 }

Formato de respuesta:

{ "count": 15, "notes": [ { "id": 123456, "body": "This is a comment on the issue", "author": { "id": 1, "username": "username", "name": "User Name" }, "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z", "system": false, "type": "comment" }, { "id": 123457, "body": "added label ~bug", "author": { "id": 1, "username": "username", "name": "User Name" }, "created_at": "2023-01-02T00:00:00Z", "updated_at": "2023-01-02T00:00:00Z", "system": true, "type": "system" } // ... other notes ] }
{ "project_id": "username/project", "issue_iid": 42, "page": 1, "per_page": 20 }

Formato de respuesta:

{ "count": 5, "discussions": [ { "id": "discussion-123", "individual_note": true, "notes": [ { "id": 123456, "body": "This is a comment on the issue", "author": { "id": 1, "username": "username", "name": "User Name" }, "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z", "system": false, "type": "comment" } ] }, { "id": "discussion-124", "individual_note": false, "notes": [ { "id": 123457, "body": "This is a thread starter", "author": { "id": 1, "username": "username", "name": "User Name" }, "created_at": "2023-01-02T00:00:00Z", "updated_at": "2023-01-02T00:00:00Z", "system": false, "type": "comment" }, { "id": 123458, "body": "This is a reply in the thread", "author": { "id": 2, "username": "username2", "name": "User Name 2" }, "created_at": "2023-01-03T00:00:00Z", "updated_at": "2023-01-03T00:00:00Z", "system": false, "type": "comment" } ] } // ... other discussions ] }

Operaciones de solicitud de fusión

{ "project_id": "username/project", "title": "Merge request title", "description": "Merge request description", "source_branch": "feature-branch", "target_branch": "main", "allow_collaboration": true, "draft": false }
{ "project_id": "username/project", "state": "opened", "order_by": "created_at", "sort": "desc", "milestone": "v1.0", "labels": "feature,enhancement", "created_after": "2023-01-01T00:00:00Z", "created_before": "2023-12-31T23:59:59Z", "updated_after": "2023-06-01T00:00:00Z", "updated_before": "2023-06-30T23:59:59Z", "author_id": 1, "assignee_id": 2, "search": "keyword", "source_branch": "feature-branch", "target_branch": "main", "page": 1, "per_page": 20 }

Actividad del proyecto

{ "project_id": "username/project", "action": "pushed", "target_type": "issue", "before": "2023-12-31T23:59:59Z", "after": "2023-01-01T00:00:00Z", "sort": "desc", "page": 1, "per_page": 20 }
{ "project_id": "username/project", "sha": "branch-or-commit-sha", "path": "path/to/file", "since": "2023-01-01T00:00:00Z", "until": "2023-12-31T23:59:59Z", "all": true, "with_stats": true, "first_parent": true, "page": 1, "per_page": 20 }

Operaciones de miembros

{ "project_id": "username/project", "query": "search term", "page": 1, "per_page": 20 }

Formato de respuesta:

{ "count": 3, "items": [ { "id": 123, "username": "username", "name": "User Name", "state": "active", "avatar_url": "https://gitlab.com/avatar.png", "web_url": "https://gitlab.com/username", "access_level": 50, "access_level_description": "Owner" } // ... other members ] }
{ "group_id": "group-name", "query": "search term", "page": 1, "per_page": 20 }

Formato de respuesta:

{ "count": 5, "items": [ { "id": 456, "username": "username", "name": "User Name", "state": "active", "avatar_url": "https://gitlab.com/avatar.png", "web_url": "https://gitlab.com/username", "access_level": 30, "access_level_description": "Developer" } // ... other members ] }

Operaciones del Proyecto Wiki

{ "project_id": "username/project", "with_content": false }
{ "project_id": "username/project", "slug": "page-slug", "render_html": false, "version": "commit-sha" }
{ "project_id": "username/project", "title": "Page Title", "content": "Wiki page content", "format": "markdown" }
{ "project_id": "username/project", "slug": "page-slug", "title": "New Page Title", "content": "Updated wiki page content", "format": "markdown" }
{ "project_id": "username/project", "slug": "page-slug" }
{ "project_id": "username/project", "file_path": "path/to/attachment.png", "content": "base64-encoded-content", "branch": "main" }

Operaciones de wiki grupal

{ "group_id": "group-name", "with_content": false }
{ "group_id": "group-name", "slug": "page-slug", "render_html": false, "version": "commit-sha" }
{ "group_id": "group-name", "title": "Page Title", "content": "Wiki page content", "format": "markdown" }
{ "group_id": "group-name", "slug": "page-slug", "title": "New Page Title", "content": "Updated wiki page content", "format": "markdown" }
{ "group_id": "group-name", "slug": "page-slug" }
{ "group_id": "group-name", "file_path": "path/to/attachment.png", "content": "base64-encoded-content", "branch": "main" }

🔧 Desarrollo

Requisitos

  • Node.js 16+
  • npm 7+
  • Una cuenta de GitLab con un token de acceso personal

Construyendo el Proyecto

npm run build

Ejecución de pruebas

npm test

Estilo de código y pelusa

npm run lint

Proceso de liberación

  1. Actualizar la versión en package.json
  2. Actualizar CHANGELOG.md
  3. Crear una nueva versión en GitHub
  4. Publicar en npm con npm publish

📖 Documentación

Para obtener documentación más detallada, visite nuestro sitio de documentación o consulte las definiciones de TypeScript en el código fuente.

💼 Casos de uso

  • Flujos de trabajo de desarrollo impulsados por IA : permita que los asistentes de IA interactúen con sus repositorios de GitLab
  • Gestión automatizada de problemas y relaciones públicas : optimice los procesos de desarrollo con el apoyo de IA
  • Gestión de wikis : automatice las actualizaciones de la documentación y la gestión de la base de conocimientos
  • Colaboración en equipo : integre asistentes de IA en el flujo de trabajo de GitLab de su equipo

📊 Hoja de ruta

  • [ ] Integración CI/CD de GitLab
  • [ ] Análisis avanzado de proyectos
  • [ ] Conjunto completo de pruebas
  • [ ] Compatibilidad con la API GraphQL de GitLab
  • [ ] Soporte extendido para webhooks

🤝 Contribuyendo

¡Agradecemos y agradecemos sus contribuciones! Aquí le mostramos cómo contribuir:

  1. Bifurcar el repositorio
  2. Crea tu rama de funciones ( git checkout -b feature/amazing-feature )
  3. Confirme sus cambios ( git commit -m 'Add some amazing feature' )
  4. Empujar a la rama ( git push origin feature/amazing-feature )
  5. Abrir una solicitud de extracción

Asegúrese de actualizar las pruebas según corresponda y seguir el estilo de código del proyecto.

📝 Licencia

Este proyecto está licenciado bajo la licencia MIT: consulte el archivo de LICENCIA para obtener más detalles.

👥 Colaboradores

Gracias a todos los colaboradores que han ayudado a mejorar este proyecto:

Agradecimientos especiales a:

  • thomasleveil : Se implementó la funcionalidad de listado de miembros de GitLab para proyectos y grupos con un formato de respuesta consistente.

Paquete NPM

Este paquete está disponible en npm:
https://www.npmjs.com/package/@yoda.digital/gitlab-mcp-server

ID: jk2pjeuy0y