UNPKG

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.

463 lines (428 loc) 17.9 kB
import { CompleteMetadata } from '@octocodeai/octocode-core/types'; export { CompleteMetadata } from '@octocodeai/octocode-core/types'; import { GitHubCodeSearchQuerySchema, GitHubReposSearchSingleQuerySchema, GitHubViewRepoStructureQuerySchema, FindFilesQuerySchema, NpmPackageQuerySchema } from '@octocodeai/octocode-core/schemas'; export { CloneRepoQuerySchema, FetchContentQuerySchema, FileContentQuerySchema, FindFilesQuerySchema, GitHubCodeSearchQuerySchema, GitHubPullRequestSearchQuerySchema, GitHubReposSearchSingleQuerySchema, GitHubViewRepoStructureQuerySchema, NpmPackageQuerySchema as NpmSearchQuerySchema, RipgrepQuerySchema, ViewStructureQuerySchema } from '@octocodeai/octocode-core/schemas'; import { CallToolResult } from '@modelcontextprotocol/sdk/types.js'; import { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js'; import { z } from 'zod'; type WithOptionalMeta<T> = Partial<T>; interface ToolExecutionArgs<TQuery> { queries: TQuery[]; responseCharOffset?: number; responseCharLength?: number; authInfo?: AuthInfo; sessionId?: string; signal?: AbortSignal; hintContext?: Record<string, unknown>; } type MinifyMode = 'none' | 'standard' | 'symbols'; interface ProviderDiagnostic { provider: string; ok: boolean; error?: string; } declare function initializeProviders(): Promise<ProviderDiagnostic[]>; declare function initialize(): Promise<void>; declare const CloneRepoQueryLocalSchema: z.ZodObject<{ owner: z.ZodString; repo: z.ZodString; branch: z.ZodOptional<z.ZodString>; sparsePath: z.ZodOptional<z.ZodString>; forceRefresh: z.ZodOptional<z.ZodBoolean>; id: z.ZodOptional<z.ZodString>; mainResearchGoal: z.ZodOptional<z.ZodString>; researchGoal: z.ZodOptional<z.ZodString>; reasoning: z.ZodOptional<z.ZodString>; }, z.core.$strip>; type PartialCloneRepoQuery = WithOptionalMeta<CloneRepoQuery>; type CloneRepoQuery = z.infer<typeof CloneRepoQueryLocalSchema>; declare function executeCloneRepo(args: ToolExecutionArgs<PartialCloneRepoQuery>): Promise<CallToolResult>; declare const FileContentQueryLocalSchema: z.ZodObject<{ owner: z.ZodString; repo: z.ZodString; branch: z.ZodOptional<z.ZodString>; path: z.ZodString; startLine: z.ZodOptional<z.ZodNumber>; endLine: z.ZodOptional<z.ZodNumber>; fullContent: z.ZodOptional<z.ZodBoolean>; matchString: z.ZodOptional<z.ZodString>; matchStringIsRegex: z.ZodOptional<z.ZodBoolean>; matchStringCaseSensitive: z.ZodOptional<z.ZodBoolean>; forceRefresh: z.ZodOptional<z.ZodBoolean>; type: z.ZodDefault<z.ZodEnum<{ file: "file"; directory: "directory"; }>>; contextLines: z.ZodDefault<z.ZodNumber>; charOffset: z.ZodOptional<z.ZodNumber>; charLength: z.ZodOptional<z.ZodNumber>; minify: z.ZodDefault<z.ZodEnum<{ none: "none"; standard: "standard"; symbols: "symbols"; }>>; id: z.ZodOptional<z.ZodString>; mainResearchGoal: z.ZodOptional<z.ZodString>; researchGoal: z.ZodOptional<z.ZodString>; reasoning: z.ZodOptional<z.ZodString>; }, z.core.$strip>; type FileContentInputQuery = z.input<typeof FileContentQueryLocalSchema>; declare function fetchMultipleGitHubFileContents(args: ToolExecutionArgs<FileContentInputQuery>): Promise<CallToolResult>; type GitHubCodeSearchQuery = z.infer<typeof GitHubCodeSearchQuerySchema>; type PartialCodeSearchQuery = WithOptionalMeta<GitHubCodeSearchQuery>; declare function searchMultipleGitHubCode(args: ToolExecutionArgs<PartialCodeSearchQuery>): Promise<CallToolResult>; declare const GitHubPullRequestSearchQueryLocalSchema: z.ZodObject<{ type: z.ZodDefault<z.ZodEnum<{ prs: "prs"; commits: "commits"; }>>; since: z.ZodOptional<z.ZodString>; until: z.ZodOptional<z.ZodString>; path: z.ZodOptional<z.ZodString>; branch: z.ZodOptional<z.ZodString>; includeDiff: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; includeAssets: z.ZodOptional<z.ZodBoolean>; keywordsToSearch: z.ZodOptional<z.ZodArray<z.ZodString>>; prNumber: z.ZodOptional<z.ZodNumber>; owner: z.ZodOptional<z.ZodString>; repo: z.ZodOptional<z.ZodString>; concise: z.ZodOptional<z.ZodBoolean>; state: z.ZodOptional<z.ZodEnum<{ open: "open"; closed: "closed"; merged: "merged"; }>>; assignee: z.ZodOptional<z.ZodString>; author: z.ZodOptional<z.ZodString>; committer: z.ZodOptional<z.ZodString>; commenter: z.ZodOptional<z.ZodString>; mentions: z.ZodOptional<z.ZodString>; "review-requested": z.ZodOptional<z.ZodString>; "reviewed-by": z.ZodOptional<z.ZodString>; label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>; checks: z.ZodOptional<z.ZodEnum<{ success: "success"; failure: "failure"; pending: "pending"; }>>; review: z.ZodOptional<z.ZodEnum<{ none: "none"; approved: "approved"; changes_requested: "changes_requested"; required: "required"; }>>; head: z.ZodOptional<z.ZodString>; base: z.ZodOptional<z.ZodString>; created: z.ZodOptional<z.ZodString>; updated: z.ZodOptional<z.ZodString>; closed: z.ZodOptional<z.ZodString>; "merged-at": z.ZodOptional<z.ZodString>; comments: z.ZodOptional<z.ZodString>; reactions: z.ZodOptional<z.ZodString>; draft: z.ZodOptional<z.ZodBoolean>; match: z.ZodOptional<z.ZodArray<z.ZodEnum<{ comments: "comments"; title: "title"; body: "body"; }>>>; sort: z.ZodOptional<z.ZodEnum<{ updated: "updated"; created: "created"; "best-match": "best-match"; comments: "comments"; reactions: "reactions"; }>>; order: z.ZodOptional<z.ZodEnum<{ asc: "asc"; desc: "desc"; }>>; limit: z.ZodDefault<z.ZodNumber>; page: z.ZodDefault<z.ZodNumber>; archived: z.ZodOptional<z.ZodBoolean>; filePage: z.ZodOptional<z.ZodNumber>; commentPage: z.ZodOptional<z.ZodNumber>; commitPage: z.ZodOptional<z.ZodNumber>; itemsPerPage: z.ZodDefault<z.ZodNumber>; reviewMode: z.ZodOptional<z.ZodLiteral<"full">>; content: z.ZodOptional<z.ZodObject<{ metadata: z.ZodOptional<z.ZodBoolean>; body: z.ZodOptional<z.ZodBoolean>; changedFiles: z.ZodOptional<z.ZodBoolean>; patches: z.ZodOptional<z.ZodObject<{ mode: z.ZodDefault<z.ZodEnum<{ none: "none"; selected: "selected"; all: "all"; }>>; files: z.ZodOptional<z.ZodArray<z.ZodString>>; ranges: z.ZodOptional<z.ZodArray<z.ZodObject<{ file: z.ZodString; additions: z.ZodOptional<z.ZodArray<z.ZodNumber>>; deletions: z.ZodOptional<z.ZodArray<z.ZodNumber>>; }, z.core.$strip>>>; }, z.core.$strip>>; comments: z.ZodOptional<z.ZodObject<{ discussion: z.ZodOptional<z.ZodBoolean>; reviewInline: z.ZodOptional<z.ZodBoolean>; includeBots: z.ZodDefault<z.ZodBoolean>; file: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; reviews: z.ZodOptional<z.ZodBoolean>; commits: z.ZodOptional<z.ZodObject<{ list: z.ZodOptional<z.ZodBoolean>; includeFiles: z.ZodOptional<z.ZodBoolean>; }, z.core.$strip>>; }, z.core.$strip>>; matchString: z.ZodOptional<z.ZodString>; commentBodyOffset: z.ZodOptional<z.ZodNumber>; charOffset: z.ZodOptional<z.ZodNumber>; charLength: z.ZodOptional<z.ZodNumber>; minify: z.ZodDefault<z.ZodEnum<{ none: "none"; standard: "standard"; }>>; id: z.ZodOptional<z.ZodString>; mainResearchGoal: z.ZodOptional<z.ZodString>; researchGoal: z.ZodOptional<z.ZodString>; reasoning: z.ZodOptional<z.ZodString>; }, z.core.$strip>; type GitHubPullRequestSearchInput = z.input<typeof GitHubPullRequestSearchQueryLocalSchema>; declare function searchMultipleGitHubPullRequests(args: ToolExecutionArgs<GitHubPullRequestSearchInput>): Promise<CallToolResult>; type GitHubReposSearchSingleQuery = z.infer<typeof GitHubReposSearchSingleQuerySchema>; type RepositorySearchExtraFields = { archived?: boolean; visibility?: 'public' | 'private'; forks?: string; license?: string; goodFirstIssues?: string; }; type PartialReposSearchQuery = WithOptionalMeta<GitHubReposSearchSingleQuery> & RepositorySearchExtraFields; declare function searchMultipleGitHubRepos(args: ToolExecutionArgs<PartialReposSearchQuery>): Promise<CallToolResult>; type GitHubViewRepoStructureQuery = z.infer<typeof GitHubViewRepoStructureQuerySchema>; type PartialRepoStructureQuery = WithOptionalMeta<GitHubViewRepoStructureQuery>; declare function exploreMultipleRepositoryStructures(args: ToolExecutionArgs<PartialRepoStructureQuery>): Promise<CallToolResult>; declare const LocalFetchContentQuerySchema: z.ZodObject<{ path: z.ZodString; fullContent: z.ZodOptional<z.ZodBoolean>; matchString: z.ZodOptional<z.ZodString>; matchStringIsRegex: z.ZodOptional<z.ZodBoolean>; matchStringCaseSensitive: z.ZodOptional<z.ZodBoolean>; startLine: z.ZodOptional<z.ZodNumber>; endLine: z.ZodOptional<z.ZodNumber>; contextLines: z.ZodDefault<z.ZodNumber>; charOffset: z.ZodOptional<z.ZodNumber>; charLength: z.ZodOptional<z.ZodNumber>; minify: z.ZodDefault<z.ZodEnum<{ none: "none"; standard: "standard"; symbols: "symbols"; }>>; id: z.ZodOptional<z.ZodString>; mainResearchGoal: z.ZodOptional<z.ZodString>; researchGoal: z.ZodOptional<z.ZodString>; reasoning: z.ZodOptional<z.ZodString>; }, z.core.$strip>; type FetchContentQuery = z.infer<typeof LocalFetchContentQuerySchema> & { minify?: MinifyMode; }; declare function executeFetchContent(args: ToolExecutionArgs<FetchContentQuery>): Promise<CallToolResult>; type FindFilesQuery = Omit<z.infer<typeof FindFilesQuerySchema>, 'regexType'>; declare function executeFindFiles(args: ToolExecutionArgs<FindFilesQuery>): Promise<CallToolResult>; declare const LocalRipgrepQuerySchema: z.ZodObject<{ searchText: z.ZodOptional<z.ZodString>; path: z.ZodString; mode: z.ZodDefault<z.ZodEnum<{ paginated: "paginated"; discovery: "discovery"; detailed: "detailed"; structural: "structural"; }>>; pattern: z.ZodOptional<z.ZodString>; rule: z.ZodOptional<z.ZodString>; regex: z.ZodDefault<z.ZodEnum<{ fixed: "fixed"; smart: "smart"; perl: "perl"; }>>; caseMode: z.ZodDefault<z.ZodEnum<{ smart: "smart"; sensitive: "sensitive"; insensitive: "insensitive"; }>>; wholeWord: z.ZodOptional<z.ZodBoolean>; invertMatch: z.ZodOptional<z.ZodBoolean>; include: z.ZodOptional<z.ZodArray<z.ZodString>>; exclude: z.ZodOptional<z.ZodArray<z.ZodString>>; excludeDir: z.ZodOptional<z.ZodArray<z.ZodString>>; noIgnore: z.ZodOptional<z.ZodBoolean>; hidden: z.ZodOptional<z.ZodBoolean>; contextLines: z.ZodOptional<z.ZodNumber>; matchContentLength: z.ZodDefault<z.ZodNumber>; maxMatchesPerFile: z.ZodOptional<z.ZodNumber>; maxFiles: z.ZodOptional<z.ZodNumber>; multiline: z.ZodDefault<z.ZodEnum<{ off: "off"; on: "on"; dotall: "dotall"; }>>; sort: z.ZodDefault<z.ZodEnum<{ path: "path"; created: "created"; relevance: "relevance"; matchCount: "matchCount"; modified: "modified"; accessed: "accessed"; }>>; sortReverse: z.ZodOptional<z.ZodBoolean>; rankingProfile: z.ZodDefault<z.ZodEnum<{ auto: "auto"; typescript: "typescript"; javascript: "javascript"; rust: "rust"; python: "python"; go: "go"; java: "java"; scala: "scala"; markdown: "markdown"; json: "json"; yaml: "yaml"; generic: "generic"; }>>; langType: z.ZodOptional<z.ZodString>; captureText: z.ZodOptional<z.ZodBoolean>; output: z.ZodDefault<z.ZodEnum<{ content: "content"; files: "files"; filesWithout: "filesWithout"; countLines: "countLines"; countMatches: "countMatches"; matchOnly: "matchOnly"; }>>; unique: z.ZodDefault<z.ZodEnum<{ list: "list"; off: "off"; count: "count"; }>>; matchWindow: z.ZodOptional<z.ZodNumber>; matchPage: z.ZodOptional<z.ZodNumber>; itemsPerPage: z.ZodOptional<z.ZodNumber>; page: z.ZodDefault<z.ZodNumber>; id: z.ZodOptional<z.ZodString>; mainResearchGoal: z.ZodOptional<z.ZodString>; researchGoal: z.ZodOptional<z.ZodString>; reasoning: z.ZodOptional<z.ZodString>; }, z.core.$strip>; type RipgrepQuery = z.infer<typeof LocalRipgrepQuerySchema>; declare function executeRipgrepSearch(args: ToolExecutionArgs<RipgrepQuery>): Promise<CallToolResult>; declare const LocalViewStructureQuerySchema: z.ZodObject<{ path: z.ZodString; detail: z.ZodDefault<z.ZodEnum<{ full: "full"; modified: "modified"; basic: "basic"; }>>; hidden: z.ZodOptional<z.ZodBoolean>; sortBy: z.ZodDefault<z.ZodEnum<{ extension: "extension"; size: "size"; name: "name"; time: "time"; }>>; reverse: z.ZodOptional<z.ZodBoolean>; pattern: z.ZodOptional<z.ZodString>; entryType: z.ZodOptional<z.ZodEnum<{ f: "f"; d: "d"; }>>; recursive: z.ZodOptional<z.ZodBoolean>; extensions: z.ZodOptional<z.ZodArray<z.ZodString>>; maxDepth: z.ZodOptional<z.ZodNumber>; limit: z.ZodOptional<z.ZodNumber>; page: z.ZodDefault<z.ZodNumber>; itemsPerPage: z.ZodOptional<z.ZodNumber>; id: z.ZodOptional<z.ZodString>; mainResearchGoal: z.ZodOptional<z.ZodString>; researchGoal: z.ZodOptional<z.ZodString>; reasoning: z.ZodOptional<z.ZodString>; }, z.core.$strip>; type ViewStructureQuery = z.infer<typeof LocalViewStructureQuerySchema>; declare function executeViewStructure(args: ToolExecutionArgs<ViewStructureQuery>): Promise<CallToolResult>; declare const SEMANTIC_CONTENT_TYPES: readonly ["definition", "references", "callers", "callees", "callHierarchy", "hover", "documentSymbols", "typeDefinition", "implementation", "workspaceSymbol", "supertypes", "subtypes", "diagnostic"]; type SemanticContentType = (typeof SEMANTIC_CONTENT_TYPES)[number]; type SemanticOutputFormat = 'structured' | 'compact'; type SemanticQueryBase = { id?: string; type: SemanticContentType; uri?: string; workspaceRoot?: string; page?: number; itemsPerPage?: number; contextLines?: number; format?: SemanticOutputFormat; mainResearchGoal?: string; researchGoal?: string; reasoning?: string; }; type SymbolAnchoredSemanticQuery = SemanticQueryBase & { type: Exclude<SemanticContentType, 'documentSymbols' | 'workspaceSymbol' | 'diagnostic'>; symbolName: string; lineHint: number; orderHint?: number; depth?: number; includeDeclaration?: boolean; groupByFile?: boolean; }; type DocumentSymbolsSemanticQuery = SemanticQueryBase & { type: 'documentSymbols'; }; /** `workspace/symbol`: project-wide fuzzy symbol search. `symbolName` is the query string. */ type WorkspaceSymbolSemanticQuery = SemanticQueryBase & { type: 'workspaceSymbol'; symbolName: string; }; /** `textDocument/diagnostic` (pull): errors/warnings for a file without a position anchor. */ type DiagnosticSemanticQuery = SemanticQueryBase & { type: 'diagnostic'; }; type LspGetSemanticsQuery = SymbolAnchoredSemanticQuery | DocumentSymbolsSemanticQuery | WorkspaceSymbolSemanticQuery | DiagnosticSemanticQuery; declare function executeLspGetSemantics(args: ToolExecutionArgs<LspGetSemanticsQuery>): Promise<CallToolResult>; declare const LspGetSemanticsQuerySchema: z.ZodObject<{ uri: z.ZodOptional<z.ZodString>; type: z.ZodDefault<z.ZodEnum<{ definition: "definition"; references: "references"; callers: "callers"; callees: "callees"; callHierarchy: "callHierarchy"; hover: "hover"; documentSymbols: "documentSymbols"; typeDefinition: "typeDefinition"; implementation: "implementation"; workspaceSymbol: "workspaceSymbol"; supertypes: "supertypes"; subtypes: "subtypes"; diagnostic: "diagnostic"; }>>; symbolName: z.ZodOptional<z.ZodString>; lineHint: z.ZodOptional<z.ZodNumber>; orderHint: z.ZodDefault<z.ZodNumber>; depth: z.ZodOptional<z.ZodNumber>; includeDeclaration: z.ZodDefault<z.ZodBoolean>; groupByFile: z.ZodOptional<z.ZodBoolean>; page: z.ZodDefault<z.ZodNumber>; itemsPerPage: z.ZodOptional<z.ZodNumber>; contextLines: z.ZodOptional<z.ZodNumber>; format: z.ZodDefault<z.ZodEnum<{ structured: "structured"; compact: "compact"; }>>; workspaceRoot: z.ZodOptional<z.ZodString>; id: z.ZodOptional<z.ZodString>; mainResearchGoal: z.ZodOptional<z.ZodString>; researchGoal: z.ZodOptional<z.ZodString>; reasoning: z.ZodOptional<z.ZodString>; }, z.core.$strip>; type NpmSearchQuery = z.input<typeof NpmPackageQuerySchema>; declare function searchPackages(args: ToolExecutionArgs<NpmSearchQuery>): Promise<CallToolResult>; declare function loadToolContent(): Promise<CompleteMetadata>; export { LspGetSemanticsQuerySchema, executeCloneRepo, executeFetchContent, executeFindFiles, executeLspGetSemantics, executeRipgrepSearch, executeViewStructure, exploreMultipleRepositoryStructures, fetchMultipleGitHubFileContents, initialize, initializeProviders, loadToolContent, searchMultipleGitHubCode, searchMultipleGitHubPullRequests, searchMultipleGitHubRepos, searchPackages };