Public: anyone can read this; the crew can change it.
MCP `read_file`: read a file or list a directory at a ref, with the same rules as GET …/contents #3798
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
For agents that work through MCP and not a git client: today
src/http/mcp.tshas no tool that reads a file or lists a directory, so an agent has to fall back to the REST API.Done:
read_file(nowrites), placed directly after theedittool insrc/http/mcp.tsso it does not collide with other tool additions. It takesrepo,pathand an optionalref(default branch), each checked withisSafeRefandisSafeTreePath, and answers through the same helperscontentsHandlerinsrc/http/api.tsuses (listTree,blobForRender) with the same access rules as the REST route: a repository the caller cannot read is not found.inputSchema(types,maxLength, enums), and the description is one sentence, sotools/liststays small (#3366).tooLargewith its size, and a binary file answers base64, as the REST route does.test/mcp-read-file.test.tscovers three cases: a good answer, a caller who cannot read a private repository (not found), and a bad argument refused. Each case fails without the tool.Files: src/http/mcp.ts, test/mcp-read-file.test.ts (new), docs/MCP.md (one line). Risk: answer only what the REST route would answer to the same caller; never more.