@mcp-consultant-tools/github-enterprise
Version:
MCP server for GitHub Enterprise - repositories, commits, pull requests, and code search
179 lines • 5.5 kB
TypeScript
/**
* GitHub Enterprise Repository Configuration
*/
export interface GitHubRepoConfig {
id: string;
owner: string;
repo: string;
defaultBranch?: string;
active: boolean;
description?: string;
}
/**
* GitHub Enterprise Service Configuration
*/
export interface GitHubEnterpriseConfig {
baseUrl: string;
apiVersion: string;
authMethod: 'pat' | 'github-app';
pat?: string;
appId?: string;
appPrivateKey?: string;
appInstallationId?: string;
repos: GitHubRepoConfig[];
enableWrite: boolean;
enableCreate: boolean;
enableCache: boolean;
cacheTtl: number;
maxFileSize: number;
maxSearchResults: number;
}
/**
* Branch Selection Result
*/
export interface BranchSelection {
branch: string;
reason: string;
confidence: 'high' | 'medium' | 'low';
alternatives?: string[];
message?: string;
}
/**
* GitHub Enterprise Service
* Manages authentication, API requests, caching, and branch selection for GitHub Enterprise Cloud
*/
export declare class GitHubEnterpriseService {
private config;
private readonly baseApiUrl;
private octokit;
private accessToken;
private tokenExpirationTime;
private cache;
constructor(config: GitHubEnterpriseConfig);
/**
* Initialize Octokit client based on authentication method
*/
private initializeOctokit;
/**
* Get access token with caching (for GitHub App auth)
* Implements 5-minute buffer pattern before expiry
*/
private getAccessToken;
/**
* Get cache key for a request
*/
private getCacheKey;
/**
* Get cached response
*/
private getCached;
/**
* Set cache entry
*/
private setCache;
/**
* Clear cache entries
* @param pattern Optional pattern to match cache keys
* @param repoId Optional repo ID to clear cache for specific repo
* @returns Number of cache entries cleared
*/
clearCache(pattern?: string, repoId?: string): number;
/**
* Make API request with error handling and caching
*/
private makeRequest;
/**
* Get all configured repositories
*/
getAllRepos(): GitHubRepoConfig[];
/**
* Get active repositories only
*/
getActiveRepos(): GitHubRepoConfig[];
/**
* Get repository by ID with validation
*/
getRepoById(repoId: string): GitHubRepoConfig;
/**
* List all branches for a repository
*/
listBranches(repoId: string, protectedOnly?: boolean): Promise<any[]>;
/**
* Auto-detect default branch for a repository
* Handles typos gracefully and provides alternatives
*/
getDefaultBranch(repoId: string, userSpecified?: string): Promise<BranchSelection>;
/**
* Get file content from a repository
*/
getFile(repoId: string, path: string, branch?: string): Promise<any>;
/**
* Search code across repositories
*/
searchCode(query: string, repoId?: string, path?: string, extension?: string): Promise<any>;
/**
* List files in a directory
*/
listFiles(repoId: string, path?: string, branch?: string): Promise<any>;
/**
* Get commit history for a branch
*/
getCommits(repoId: string, branch?: string, since?: string, until?: string, author?: string, path?: string, limit?: number): Promise<any[]>;
/**
* Get commit details
*/
getCommitDetails(repoId: string, sha: string): Promise<any>;
/**
* Search commits by message
*/
searchCommits(query: string, repoId?: string, author?: string, since?: string, until?: string): Promise<any>;
/**
* Compare two branches
*/
compareBranches(repoId: string, base: string, head: string): Promise<any>;
/**
* Get branch details
*/
getBranchDetails(repoId: string, branch: string): Promise<any>;
/**
* List pull requests
*/
listPullRequests(repoId: string, state?: 'open' | 'closed' | 'all', base?: string, head?: string, sort?: 'created' | 'updated' | 'popularity', limit?: number): Promise<any[]>;
/**
* Get pull request details
*/
getPullRequest(repoId: string, prNumber: number): Promise<any>;
/**
* Get pull request files
*/
getPullRequestFiles(repoId: string, prNumber: number): Promise<any[]>;
/**
* Create a new branch (requires GHE_ENABLE_CREATE=true)
*/
createBranch(repoId: string, branchName: string, fromBranch?: string): Promise<any>;
/**
* Update file content (requires GHE_ENABLE_WRITE=true)
*/
updateFile(repoId: string, path: string, content: string, message: string, branch: string, sha: string): Promise<any>;
/**
* Create a new file (requires GHE_ENABLE_CREATE=true)
*/
createFile(repoId: string, path: string, content: string, message: string, branch: string): Promise<any>;
/**
* Search repositories
*/
searchRepositories(query: string, owner?: string): Promise<any>;
/**
* Get directory structure recursively
*/
getDirectoryStructure(repoId: string, path?: string, branch?: string, depth?: number): Promise<any>;
/**
* Get file commit history
*/
getFileHistory(repoId: string, path: string, branch?: string, limit?: number): Promise<any[]>;
/**
* Get commit diff
*/
getCommitDiff(repoId: string, sha: string, format?: 'diff' | 'patch'): Promise<string>;
}
//# sourceMappingURL=GitHubEnterpriseService.d.ts.map