@yoda.digital/gitlab-mcp-server
Version:
GitLab MCP Server - A Model Context Protocol server for GitLab integration
423 lines (422 loc) • 18.4 kB
TypeScript
import { z } from 'zod';
import { CreateRepositoryOptionsSchema, CreateIssueOptionsSchema, CreateMergeRequestOptionsSchema, CreateBranchOptionsSchema, type GitLabFork, type GitLabReference, type GitLabRepository, type GitLabIssue, type GitLabMergeRequest, type GitLabContent, type GitLabCreateUpdateFileResponse, type GitLabSearchResponse, type GitLabGroupProjectsResponse, type GitLabCommit, type GitLabEventsResponse, type GitLabCommitsResponse, type GitLabIssuesResponse, type GitLabMergeRequestsResponse, type GitLabWikiPage, type GitLabWikiPagesResponse, type GitLabWikiAttachment, type WikiPageFormat, type FileOperation, type GitLabMembersResponse, type GitLabNotesResponse, type GitLabDiscussionsResponse } from './schemas.js';
/**
* GitLab API client configuration
*/
export interface GitLabApiConfig {
apiUrl: string;
token: string;
}
/**
* GitLab API client for interacting with GitLab resources
*/
export declare class GitLabApi {
private apiUrl;
private token;
constructor(config: GitLabApiConfig);
/**
* Forks a GitLab project to a specified namespace.
*
* @param projectId - The ID or URL-encoded path of the project to fork
* @param namespace - Optional namespace to fork the project into
* @returns A promise that resolves to the forked project details
* @throws Will throw an error if the GitLab API request fails
*/
forkProject(projectId: string, namespace?: string): Promise<GitLabFork>;
/**
* Creates a new branch in a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param options - Options for creating the branch, including name and ref
* @returns A promise that resolves to the created branch details
* @throws Will throw an error if the GitLab API request fails
*/
createBranch(projectId: string, options: z.infer<typeof CreateBranchOptionsSchema>): Promise<GitLabReference>;
/**
* Retrieves the default branch reference for a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @returns A promise that resolves to the default branch reference
* @throws Will throw an error if the GitLab API request fails
*/
getDefaultBranchRef(projectId: string): Promise<string>;
/**
* Retrieves the contents of a file from a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param filePath - The path of the file within the project
* @param ref - The name of the branch, tag, or commit
* @returns A promise that resolves to the file contents
* @throws Will throw an error if the GitLab API request fails
*/
getFileContents(projectId: string, filePath: string, ref: string): Promise<GitLabContent>;
/**
* Creates or updates a file in a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param filePath - The path of the file within the project
* @param content - The content of the file
* @param commitMessage - The commit message for the change
* @param branch - The branch to commit the change to
* @param previousPath - Optional previous path if the file is being renamed
* @returns A promise that resolves to the created or updated file details
* @throws Will throw an error if the GitLab API request fails
*/
createOrUpdateFile(projectId: string, filePath: string, content: string, commitMessage: string, branch: string, previousPath?: string): Promise<GitLabCreateUpdateFileResponse>;
/**
* Creates a commit in a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param message - The commit message
* @param branch - The branch to commit the changes to
* @param actions - An array of file operations to include in the commit
* @returns A promise that resolves to the created commit details
* @throws Will throw an error if the GitLab API request fails
*/
createCommit(projectId: string, message: string, branch: string, actions: FileOperation[]): Promise<GitLabCommit>;
/**
* Searches for GitLab projects based on a query.
*
* @param query - The search query
* @param page - The page number to retrieve (default is 1)
* @param perPage - The number of results per page (default is 20)
* @returns A promise that resolves to the search results
* @throws Will throw an error if the GitLab API request fails
*/
searchProjects(query: string, page?: number, perPage?: number): Promise<GitLabSearchResponse>;
/**
* Lists all projects (repositories) within a specific GitLab group.
*
* @param groupId - The ID or URL-encoded path of the group
* @param options - Optional parameters for filtering and pagination
* @returns A promise that resolves to the list of group projects
* @throws Will throw an error if the GitLab API request fails
*/
listGroupProjects(groupId: string, options?: {
archived?: boolean;
visibility?: 'public' | 'internal' | 'private';
order_by?: 'id' | 'name' | 'path' | 'created_at' | 'updated_at' | 'last_activity_at';
sort?: 'asc' | 'desc';
search?: string;
simple?: boolean;
include_subgroups?: boolean;
page?: number;
per_page?: number;
}): Promise<GitLabGroupProjectsResponse>;
/**
* Retrieves events for a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param options - Optional parameters for filtering and pagination
* @returns A promise that resolves to the events response
* @throws Will throw an error if the GitLab API request fails
*/
getProjectEvents(projectId: string, options?: {
action?: string;
target_type?: string;
before?: string;
after?: string;
sort?: "asc" | "desc";
page?: number;
per_page?: number;
}): Promise<GitLabEventsResponse>;
/**
* Retrieves commits for a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param options - Optional parameters for filtering and pagination
* @returns A promise that resolves to the commits response
* @throws Will throw an error if the GitLab API request fails
*/
listCommits(projectId: string, options?: {
sha?: string;
since?: string;
until?: string;
path?: string;
all?: boolean;
with_stats?: boolean;
first_parent?: boolean;
page?: number;
per_page?: number;
}): Promise<GitLabCommitsResponse>;
/**
* Retrieves issues for a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param options - Optional parameters for filtering and pagination
* @returns A promise that resolves to the issues response
* @throws Will throw an error if the GitLab API request fails
*/
listIssues(projectId: string, options?: {
iid?: number | string;
state?: "opened" | "closed" | "all";
labels?: string;
milestone?: string;
scope?: "created_by_me" | "assigned_to_me" | "all";
author_id?: number;
assignee_id?: number;
search?: string;
created_after?: string;
created_before?: string;
updated_after?: string;
updated_before?: string;
order_by?: string;
sort?: "asc" | "desc";
page?: number;
per_page?: number;
}): Promise<GitLabIssuesResponse>;
/**
* Retrieves merge requests for a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param options - Optional parameters for filtering and pagination
* @returns A promise that resolves to the merge requests response
* @throws Will throw an error if the GitLab API request fails
*/
listMergeRequests(projectId: string, options?: {
state?: "opened" | "closed" | "locked" | "merged" | "all";
order_by?: "created_at" | "updated_at";
sort?: "asc" | "desc";
milestone?: string;
labels?: string;
created_after?: string;
created_before?: string;
updated_after?: string;
updated_before?: string;
scope?: "created_by_me" | "assigned_to_me" | "all";
author_id?: number;
assignee_id?: number;
search?: string;
source_branch?: string;
target_branch?: string;
wip?: "yes" | "no";
page?: number;
per_page?: number;
}): Promise<GitLabMergeRequestsResponse>;
/**
* Creates a new issue in a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param options - Options for creating the issue, including title, description, assignee IDs, milestone ID, and labels
* @returns A promise that resolves to the created issue details
* @throws Will throw an error if the GitLab API request fails
*/
createIssue(projectId: string, options: z.infer<typeof CreateIssueOptionsSchema>): Promise<GitLabIssue>;
/**
* Creates a new merge request in a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param options - Options for creating the merge request, including title, description, source branch, target branch, allow collaboration, and draft status
* @returns A promise that resolves to the created merge request details
* @throws Will throw an error if the GitLab API request fails
*/
createMergeRequest(projectId: string, options: z.infer<typeof CreateMergeRequestOptionsSchema>): Promise<GitLabMergeRequest>;
/**
* Creates a new repository in GitLab.
*
* @param options - Options for creating the repository, including name, description, visibility, and initialization with README
* @returns A promise that resolves to the created repository details
* @throws Will throw an error if the GitLab API request fails
*/
createRepository(options: z.infer<typeof CreateRepositoryOptionsSchema>): Promise<GitLabRepository>;
/**
* Lists all wiki pages for a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param options - Optional parameters for the request
* @returns A promise that resolves to the wiki pages response
* @throws Will throw an error if the GitLab API request fails
*/
listProjectWikiPages(projectId: string, options?: {
with_content?: boolean;
}): Promise<GitLabWikiPagesResponse>;
/**
* Gets a specific wiki page for a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param slug - The slug of the wiki page
* @param options - Optional parameters for the request
* @returns A promise that resolves to the wiki page
* @throws Will throw an error if the GitLab API request fails
*/
getProjectWikiPage(projectId: string, slug: string, options?: {
render_html?: boolean;
version?: string;
}): Promise<GitLabWikiPage>;
/**
* Creates a new wiki page for a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param options - Options for creating the wiki page
* @returns A promise that resolves to the created wiki page
* @throws Will throw an error if the GitLab API request fails
*/
createProjectWikiPage(projectId: string, options: {
title: string;
content: string;
format?: WikiPageFormat;
}): Promise<GitLabWikiPage>;
/**
* Edits an existing wiki page for a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param slug - The slug of the wiki page
* @param options - Options for editing the wiki page
* @returns A promise that resolves to the edited wiki page
* @throws Will throw an error if the GitLab API request fails
*/
editProjectWikiPage(projectId: string, slug: string, options: {
title?: string;
content?: string;
format?: WikiPageFormat;
}): Promise<GitLabWikiPage>;
/**
* Deletes a wiki page from a GitLab project.
*
* @param projectId - The ID or URL-encoded path of the project
* @param slug - The slug of the wiki page
* @returns A promise that resolves when the wiki page is deleted
* @throws Will throw an error if the GitLab API request fails
*/
deleteProjectWikiPage(projectId: string, slug: string): Promise<void>;
/**
* Uploads an attachment to a GitLab project wiki.
*
* @param projectId - The ID or URL-encoded path of the project
* @param options - Options for uploading the attachment
* @returns A promise that resolves to the uploaded attachment details
* @throws Will throw an error if the GitLab API request fails
*/
uploadProjectWikiAttachment(projectId: string, options: {
file_path: string;
content: string;
branch?: string;
}): Promise<GitLabWikiAttachment>;
/**
* Lists all wiki pages for a GitLab group.
*
* @param groupId - The ID or URL-encoded path of the group
* @param options - Optional parameters for the request
* @returns A promise that resolves to the wiki pages response
* @throws Will throw an error if the GitLab API request fails
*/
listGroupWikiPages(groupId: string, options?: {
with_content?: boolean;
}): Promise<GitLabWikiPagesResponse>;
/**
* Gets a specific wiki page for a GitLab group.
*
* @param groupId - The ID or URL-encoded path of the group
* @param slug - The slug of the wiki page
* @param options - Optional parameters for the request
* @returns A promise that resolves to the wiki page
* @throws Will throw an error if the GitLab API request fails
*/
getGroupWikiPage(groupId: string, slug: string, options?: {
render_html?: boolean;
version?: string;
}): Promise<GitLabWikiPage>;
/**
* Creates a new wiki page for a GitLab group.
*
* @param groupId - The ID or URL-encoded path of the group
* @param options - Options for creating the wiki page
* @returns A promise that resolves to the created wiki page
* @throws Will throw an error if the GitLab API request fails
*/
createGroupWikiPage(groupId: string, options: {
title: string;
content: string;
format?: WikiPageFormat;
}): Promise<GitLabWikiPage>;
/**
* Edits an existing wiki page for a GitLab group.
*
* @param groupId - The ID or URL-encoded path of the group
* @param slug - The slug of the wiki page
* @param options - Options for editing the wiki page
* @returns A promise that resolves to the edited wiki page
* @throws Will throw an error if the GitLab API request fails
*/
editGroupWikiPage(groupId: string, slug: string, options: {
title?: string;
content?: string;
format?: WikiPageFormat;
}): Promise<GitLabWikiPage>;
/**
* Deletes a wiki page from a GitLab group.
*
* @param groupId - The ID or URL-encoded path of the group
* @param slug - The slug of the wiki page
* @returns A promise that resolves when the wiki page is deleted
* @throws Will throw an error if the GitLab API request fails
*/
deleteGroupWikiPage(groupId: string, slug: string): Promise<void>;
/**
* Uploads an attachment to a GitLab group wiki.
*
* @param groupId - The ID or URL-encoded path of the group
* @param options - Options for uploading the attachment
* @returns A promise that resolves to the uploaded attachment details
* @throws Will throw an error if the GitLab API request fails
*/
uploadGroupWikiAttachment(groupId: string, options: {
file_path: string;
content: string;
branch?: string;
}): Promise<GitLabWikiAttachment>;
/**
* Lists members of a GitLab project (including inherited members).
*
* @param projectId - The ID or URL-encoded path of the project
* @param options - Options for listing members
* @returns A promise that resolves to the members response
* @throws Will throw an error if the GitLab API request fails
*/
listProjectMembers(projectId: string, options?: {
query?: string;
page?: number;
per_page?: number;
}): Promise<GitLabMembersResponse>;
/**
* Lists members of a GitLab group (including inherited members).
*
* @param groupId - The ID or URL-encoded path of the group
* @param options - Options for listing members
* @returns A promise that resolves to the members response
* @throws Will throw an error if the GitLab API request fails
*/
listGroupMembers(groupId: string, options?: {
query?: string;
page?: number;
per_page?: number;
}): Promise<GitLabMembersResponse>;
/**
* Retrieves notes for a GitLab issue.
*
* @param projectId - The ID or URL-encoded path of the project
* @param issueIid - The internal ID of the issue
* @param options - Optional parameters for filtering and pagination
* @returns A promise that resolves to the notes response
* @throws Will throw an error if the GitLab API request fails
*/
getIssueNotes(projectId: string, issueIid: number, options?: {
sort?: "asc" | "desc";
order_by?: "created_at" | "updated_at";
page?: number;
per_page?: number;
}): Promise<GitLabNotesResponse>;
/**
* Retrieves discussions for a GitLab issue.
*
* @param projectId - The ID or URL-encoded path of the project
* @param issueIid - The internal ID of the issue
* @param options - Optional parameters for pagination
* @returns A promise that resolves to the discussions response
* @throws Will throw an error if the GitLab API request fails
*/
getIssueDiscussions(projectId: string, issueIid: number, options?: {
page?: number;
per_page?: number;
}): Promise<GitLabDiscussionsResponse>;
}