octocode-mcp
Version:
Model Context Protocol (MCP) server for advanced GitHub repository analysis and code discovery. Provides AI assistants with powerful tools to search, analyze, and understand codebases across GitHub.
354 lines (353 loc) • 14.3 kB
TypeScript
export declare const CONFIG_ERRORS: {
readonly NOT_INITIALIZED: {
readonly code: "CONFIG_NOT_INITIALIZED";
readonly message: "Configuration not initialized. Call initialize() and await its completion before calling getServerConfig().";
};
readonly NO_GITHUB_TOKEN: {
readonly code: "CONFIG_NO_GITHUB_TOKEN";
readonly message: "No GitHub token found. Please authenticate with GitHub CLI (gh auth login) or set GITHUB_TOKEN/GH_TOKEN environment variable";
};
};
export declare const VALIDATION_ERRORS: {
readonly PROMISES_NOT_ARRAY: {
readonly code: "VALIDATION_PROMISES_NOT_ARRAY";
readonly message: "promises must be an array";
};
readonly TIMEOUT_NOT_POSITIVE: {
readonly code: "VALIDATION_TIMEOUT_NOT_POSITIVE";
readonly message: "timeout must be positive";
};
readonly CONCURRENCY_NOT_POSITIVE: {
readonly code: "VALIDATION_CONCURRENCY_NOT_POSITIVE";
readonly message: "concurrency must be positive";
};
readonly INVALID_PARAMETERS: {
readonly code: "VALIDATION_INVALID_PARAMETERS";
readonly message: "Invalid parameters: must be an object";
};
readonly INVALID_PARAMETER_KEY: {
readonly code: "VALIDATION_INVALID_PARAMETER_KEY";
readonly message: (key: string) => string;
};
readonly INVALID_NESTED_OBJECT: {
readonly code: "VALIDATION_INVALID_NESTED_OBJECT";
readonly message: (key: string, warnings: string) => string;
};
};
export declare const FETCH_ERRORS: {
readonly FETCH_NOT_AVAILABLE: {
readonly code: "FETCH_NOT_AVAILABLE";
readonly message: "Global fetch is not available in this environment.";
};
readonly FETCH_FAILED_AFTER_RETRIES: {
readonly code: "FETCH_FAILED_AFTER_RETRIES";
readonly message: (attempts: number, errorMessage: string) => string;
};
readonly FETCH_HTTP_ERROR: {
readonly code: "FETCH_HTTP_ERROR";
readonly message: (status: number, statusText: string) => string;
};
};
export declare const TOOL_METADATA_ERRORS: {
readonly INVALID_FORMAT: {
readonly code: "TOOL_METADATA_INVALID_FORMAT";
readonly message: "Invalid tool metadata format from remote source.";
};
readonly INVALID_API_RESPONSE: {
readonly code: "TOOL_METADATA_INVALID_API_RESPONSE";
readonly message: "Invalid API response structure";
};
};
export declare const FILE_OPERATION_ERRORS: {
readonly PATH_IS_DIRECTORY: {
readonly code: "FILE_PATH_IS_DIRECTORY";
readonly message: (toolName: string) => string;
};
readonly FILE_TOO_LARGE: {
readonly code: "FILE_TOO_LARGE";
readonly message: (fileSizeKB: number, maxSizeKB: number, toolName: string) => string;
};
readonly FILE_EMPTY: {
readonly code: "FILE_EMPTY";
readonly message: "File is empty - no content to display";
};
readonly BINARY_FILE: {
readonly code: "FILE_BINARY";
readonly message: "Binary file detected. Cannot display as text - download directly from GitHub";
};
readonly DECODE_FAILED: {
readonly code: "FILE_DECODE_FAILED";
readonly message: "Failed to decode file. Encoding may not be supported (expected UTF-8)";
};
readonly UNSUPPORTED_TYPE: {
readonly code: "FILE_UNSUPPORTED_TYPE";
readonly message: (type: string) => string;
};
readonly MATCH_STRING_NOT_FOUND: {
readonly code: "FILE_MATCH_STRING_NOT_FOUND";
readonly message: (matchString: string) => string;
};
};
export declare const REPOSITORY_ERRORS: {
readonly NOT_FOUND: {
readonly code: "REPO_NOT_FOUND";
readonly message: (owner: string, repo: string, error: string) => string;
};
readonly PATH_NOT_FOUND: {
readonly code: "REPO_PATH_NOT_FOUND";
readonly message: (path: string, owner: string, repo: string, branch: string) => string;
};
readonly PATH_NOT_FOUND_ANY_BRANCH: {
readonly code: "REPO_PATH_NOT_FOUND_ANY_BRANCH";
readonly message: (path: string, owner: string, repo: string) => string;
};
readonly ACCESS_FAILED: {
readonly code: "REPO_ACCESS_FAILED";
readonly message: (owner: string, repo: string, error: string) => string;
};
readonly BRANCH_NOT_FOUND: {
readonly code: "REPO_BRANCH_NOT_FOUND";
readonly message: (branch: string) => string;
};
readonly STRUCTURE_EXPLORATION_FAILED: {
readonly code: "REPO_STRUCTURE_EXPLORATION_FAILED";
readonly message: "Failed to explore repository structure";
};
};
export declare const SEARCH_ERRORS: {
readonly QUERY_EMPTY: {
readonly code: "SEARCH_QUERY_EMPTY";
readonly message: "Search query cannot be empty";
};
readonly NO_VALID_PARAMETERS: {
readonly code: "SEARCH_NO_VALID_PARAMETERS";
readonly message: "No valid search parameters provided";
};
readonly PR_REQUIRED_PARAMS: {
readonly code: "SEARCH_PR_REQUIRED_PARAMS";
readonly message: "Owner, repo, and prNumber are required parameters";
};
readonly PR_SINGLE_VALUES: {
readonly code: "SEARCH_PR_SINGLE_VALUES";
readonly message: "Owner and repo must be single values";
};
readonly API_REQUEST_FAILED: {
readonly code: "SEARCH_API_REQUEST_FAILED";
readonly message: (error: string) => string;
};
readonly PULL_REQUEST_SEARCH_FAILED: {
readonly code: "SEARCH_PR_SEARCH_FAILED";
readonly message: (error: string) => string;
};
readonly PULL_REQUEST_LIST_FAILED: {
readonly code: "SEARCH_PR_LIST_FAILED";
readonly message: (error: string) => string;
};
readonly PULL_REQUEST_FETCH_FAILED: {
readonly code: "SEARCH_PR_FETCH_FAILED";
readonly message: (prNumber: number, error: string) => string;
};
};
export declare const STARTUP_ERRORS: {
readonly NO_TOOLS_REGISTERED: {
readonly code: "STARTUP_NO_TOOLS_REGISTERED";
readonly message: "No tools were successfully registered";
};
readonly UNCAUGHT_EXCEPTION: {
readonly code: "STARTUP_UNCAUGHT_EXCEPTION";
readonly message: (error: string) => string;
};
readonly UNHANDLED_REJECTION: {
readonly code: "STARTUP_UNHANDLED_REJECTION";
readonly message: (reason: string) => string;
};
readonly STARTUP_FAILED: {
readonly code: "STARTUP_FAILED";
readonly message: (error: string) => string;
};
};
export declare const PROMISE_ERRORS: {
readonly TIMEOUT: {
readonly code: "PROMISE_TIMEOUT";
readonly message: (index: number, timeout: number) => string;
};
readonly NOT_A_FUNCTION: {
readonly code: "PROMISE_NOT_A_FUNCTION";
readonly message: (index: number) => string;
};
readonly FUNCTION_UNDEFINED: {
readonly code: "PROMISE_FUNCTION_UNDEFINED";
readonly message: "Promise function is undefined";
};
};
export declare const ALL_ERROR_CODES: {
readonly TIMEOUT: {
readonly code: "PROMISE_TIMEOUT";
readonly message: (index: number, timeout: number) => string;
};
readonly NOT_A_FUNCTION: {
readonly code: "PROMISE_NOT_A_FUNCTION";
readonly message: (index: number) => string;
};
readonly FUNCTION_UNDEFINED: {
readonly code: "PROMISE_FUNCTION_UNDEFINED";
readonly message: "Promise function is undefined";
};
readonly NO_TOOLS_REGISTERED: {
readonly code: "STARTUP_NO_TOOLS_REGISTERED";
readonly message: "No tools were successfully registered";
};
readonly UNCAUGHT_EXCEPTION: {
readonly code: "STARTUP_UNCAUGHT_EXCEPTION";
readonly message: (error: string) => string;
};
readonly UNHANDLED_REJECTION: {
readonly code: "STARTUP_UNHANDLED_REJECTION";
readonly message: (reason: string) => string;
};
readonly STARTUP_FAILED: {
readonly code: "STARTUP_FAILED";
readonly message: (error: string) => string;
};
readonly QUERY_EMPTY: {
readonly code: "SEARCH_QUERY_EMPTY";
readonly message: "Search query cannot be empty";
};
readonly NO_VALID_PARAMETERS: {
readonly code: "SEARCH_NO_VALID_PARAMETERS";
readonly message: "No valid search parameters provided";
};
readonly PR_REQUIRED_PARAMS: {
readonly code: "SEARCH_PR_REQUIRED_PARAMS";
readonly message: "Owner, repo, and prNumber are required parameters";
};
readonly PR_SINGLE_VALUES: {
readonly code: "SEARCH_PR_SINGLE_VALUES";
readonly message: "Owner and repo must be single values";
};
readonly API_REQUEST_FAILED: {
readonly code: "SEARCH_API_REQUEST_FAILED";
readonly message: (error: string) => string;
};
readonly PULL_REQUEST_SEARCH_FAILED: {
readonly code: "SEARCH_PR_SEARCH_FAILED";
readonly message: (error: string) => string;
};
readonly PULL_REQUEST_LIST_FAILED: {
readonly code: "SEARCH_PR_LIST_FAILED";
readonly message: (error: string) => string;
};
readonly PULL_REQUEST_FETCH_FAILED: {
readonly code: "SEARCH_PR_FETCH_FAILED";
readonly message: (prNumber: number, error: string) => string;
};
readonly NOT_FOUND: {
readonly code: "REPO_NOT_FOUND";
readonly message: (owner: string, repo: string, error: string) => string;
};
readonly PATH_NOT_FOUND: {
readonly code: "REPO_PATH_NOT_FOUND";
readonly message: (path: string, owner: string, repo: string, branch: string) => string;
};
readonly PATH_NOT_FOUND_ANY_BRANCH: {
readonly code: "REPO_PATH_NOT_FOUND_ANY_BRANCH";
readonly message: (path: string, owner: string, repo: string) => string;
};
readonly ACCESS_FAILED: {
readonly code: "REPO_ACCESS_FAILED";
readonly message: (owner: string, repo: string, error: string) => string;
};
readonly BRANCH_NOT_FOUND: {
readonly code: "REPO_BRANCH_NOT_FOUND";
readonly message: (branch: string) => string;
};
readonly STRUCTURE_EXPLORATION_FAILED: {
readonly code: "REPO_STRUCTURE_EXPLORATION_FAILED";
readonly message: "Failed to explore repository structure";
};
readonly PATH_IS_DIRECTORY: {
readonly code: "FILE_PATH_IS_DIRECTORY";
readonly message: (toolName: string) => string;
};
readonly FILE_TOO_LARGE: {
readonly code: "FILE_TOO_LARGE";
readonly message: (fileSizeKB: number, maxSizeKB: number, toolName: string) => string;
};
readonly FILE_EMPTY: {
readonly code: "FILE_EMPTY";
readonly message: "File is empty - no content to display";
};
readonly BINARY_FILE: {
readonly code: "FILE_BINARY";
readonly message: "Binary file detected. Cannot display as text - download directly from GitHub";
};
readonly DECODE_FAILED: {
readonly code: "FILE_DECODE_FAILED";
readonly message: "Failed to decode file. Encoding may not be supported (expected UTF-8)";
};
readonly UNSUPPORTED_TYPE: {
readonly code: "FILE_UNSUPPORTED_TYPE";
readonly message: (type: string) => string;
};
readonly MATCH_STRING_NOT_FOUND: {
readonly code: "FILE_MATCH_STRING_NOT_FOUND";
readonly message: (matchString: string) => string;
};
readonly INVALID_FORMAT: {
readonly code: "TOOL_METADATA_INVALID_FORMAT";
readonly message: "Invalid tool metadata format from remote source.";
};
readonly INVALID_API_RESPONSE: {
readonly code: "TOOL_METADATA_INVALID_API_RESPONSE";
readonly message: "Invalid API response structure";
};
readonly FETCH_NOT_AVAILABLE: {
readonly code: "FETCH_NOT_AVAILABLE";
readonly message: "Global fetch is not available in this environment.";
};
readonly FETCH_FAILED_AFTER_RETRIES: {
readonly code: "FETCH_FAILED_AFTER_RETRIES";
readonly message: (attempts: number, errorMessage: string) => string;
};
readonly FETCH_HTTP_ERROR: {
readonly code: "FETCH_HTTP_ERROR";
readonly message: (status: number, statusText: string) => string;
};
readonly PROMISES_NOT_ARRAY: {
readonly code: "VALIDATION_PROMISES_NOT_ARRAY";
readonly message: "promises must be an array";
};
readonly TIMEOUT_NOT_POSITIVE: {
readonly code: "VALIDATION_TIMEOUT_NOT_POSITIVE";
readonly message: "timeout must be positive";
};
readonly CONCURRENCY_NOT_POSITIVE: {
readonly code: "VALIDATION_CONCURRENCY_NOT_POSITIVE";
readonly message: "concurrency must be positive";
};
readonly INVALID_PARAMETERS: {
readonly code: "VALIDATION_INVALID_PARAMETERS";
readonly message: "Invalid parameters: must be an object";
};
readonly INVALID_PARAMETER_KEY: {
readonly code: "VALIDATION_INVALID_PARAMETER_KEY";
readonly message: (key: string) => string;
};
readonly INVALID_NESTED_OBJECT: {
readonly code: "VALIDATION_INVALID_NESTED_OBJECT";
readonly message: (key: string, warnings: string) => string;
};
readonly NOT_INITIALIZED: {
readonly code: "CONFIG_NOT_INITIALIZED";
readonly message: "Configuration not initialized. Call initialize() and await its completion before calling getServerConfig().";
};
readonly NO_GITHUB_TOKEN: {
readonly code: "CONFIG_NO_GITHUB_TOKEN";
readonly message: "No GitHub token found. Please authenticate with GitHub CLI (gh auth login) or set GITHUB_TOKEN/GH_TOKEN environment variable";
};
};
export type ErrorCategory = 'CONFIG' | 'VALIDATION' | 'FETCH' | 'TOOL_METADATA' | 'FILE_OPERATION' | 'REPOSITORY' | 'SEARCH' | 'STARTUP' | 'PROMISE';
export type ErrorCode = (typeof ALL_ERROR_CODES)[keyof typeof ALL_ERROR_CODES]['code'];
export declare function getErrorsByCategory(category: ErrorCategory): Record<string, unknown>;
export declare function getAllErrorCodes(): string[];
export declare function isValidErrorCode(code: string): boolean;