Repository navigation
Description
Context
The ProPR MCP server registers tools that permit autonomous coding agents and chat clients to inspect and drive the platform. Existing context tools in packages/api/mcp/toolsContext.ts provide high-level summary trees (get_repository_context) and entity name resolution (resolve_reference), but do not allow an agent to search repository code or read file contents. Because the GitHub connector's get_file_contents does not surface file bodies inline, an MCP client cannot perform a search-then-read loop. This task registers search_repository_files and read_repository_file as first-class, read-only MCP tools in packages/api/mcp/toolsContext.ts, enforcing repository grant authorization, standard input validation schemas, and error envelopes.
Requirements
- Tool Registration in
packages/api/mcp/toolsContext.ts:- Register
search_repository_files:- Parameters:
repository(repositorySchema),query(1-1000 chars),mode('semantic' | 'literal', default'semantic'),branch(optional string),ref(optional string),path(optional subpath string),caseSensitive(optional boolean), and...pageShape(offset,limit). scope: 'read',readOnly: true.- Description clearly explaining that
semanticuses index-based planner relevance whileliteralperforms exact string grep across the git tree at the specified ref.
- Parameters:
- Register
read_repository_file:- Parameters:
repository(repositorySchema),path(1-1024 chars),branch(optional string),ref(optional string),startLine(int >= 1, default 1),endLine(optional int >= 1),maxLines(int 1-1000, default 800),maxBytes(int 1-500000, default 120000). scope: 'read',readOnly: true.- Description explaining line-chunked reading without local cloning.
- Parameters:
- Register
- Security & Authorization:
- Call
await policy.repository(principal, args.repository)at the start of both handlers. This ensures the repository is configured, enabled in the instance, explicitly granted to the principal, and accessible via the user's GitHub credential. - Reject paths with directory traversal (
..), leading slashes, or backslashes before running git operations.
- Call
- Execution & Error Mapping:
- Forward authenticated tokens (
principal.user.accessTokenor installation token) tosearchRepositoryFilesandreadRepositoryFileContent. - Wrap domain errors in
McpErrorenvelopes with stable error codes:- 400
INVALID_PATH - 400
BINARY_FILE - 404
FILE_NOT_FOUND - 403
REPOSITORY_FORBIDDEN
- 400
- Wrap successful results in
ok({ ... }).
- Forward authenticated tokens (
Implementation Specification
- File:
packages/api/mcp/toolsContext.ts(modify)
Acceptance Criteria
search_repository_filesandread_repository_fileare registered in the tool catalog withscope: 'read'andreadOnly: true.search_repository_filesacceptsmode: 'semantic'andmode: 'literal', returning matching paths without dumping full file contents.read_repository_filereturns bounded file contents with startLine, endLine, totalLines, and truncated indicator.- Path traversal returns 400
INVALID_PATH, binary files return 400BINARY_FILE, missing files return 404FILE_NOT_FOUND. - Inaccessible repositories return 403
REPOSITORY_FORBIDDEN.
Created by ProPR AI Planner
Activity
propr-dev commentedon Oct 6, 2026
Suggested Implementation:
Implementation Approach
This task exposes the core repository retrieval engine over the Model Context Protocol (MCP) by registering two lightweight, composable tools in
packages/api/mcp/toolsContext.ts:search_repository_filesandread_repository_file. We deliberately keep these tools separate rather than combining them into one monolithic call so that AI agent clients can drive flexible search-then-read loops without paying token costs for unneeded file bodies. Both tools inherit the standard ProPR MCP security architecture: they enforce repository grant validation viapolicy.repository(principal, args.repository), declarescope: 'read'andreadOnly: true, validate input with Zod schemas, and map domain errors to stableMcpErrorenvelopes.File:
packages/api/mcp/toolsContext.tsWhy this file:
toolsContext.tsmanages all repository-inspection tools on the MCP surface (alongsideresolve_referenceandget_repository_context). Addingsearch_repository_filesandread_repository_filehere keeps repository reading and navigation tools grouped logically, ensuring they receivepolicyanddbdependencies from the tool catalog factory.propr-dev commentedon Oct 6, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-5-52798/claude-opus-5-5-expose-repository-search--20261006-1503-b8h2797-epic-repository-search-sgjissue-2798-20261006-1503-claude-opus-5-5-b8h🔍 Track Task Execution