@devries-cameron20 / t3code-1 / commits / 2a66bf26e8
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): read_pull_request_guide reads no-checkout hosts through the caller's project (#35913)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 14, 2026 at 20:41 UTC 2a66bf26e868ffa0393da8fdb2db3d62519820ed
2 files changed +53 -9
apps/server/src/mcp/toolkits/pullRequests/handlers.test.ts
+30
@@ -726,6 +726,36 @@ describe("pull request guide tools", () => {
726 }),
727 );
728
729 + it.effect(
730 + "reads a guide on a host readable without a checkout through the caller's project",
731 + () =>
732 + Effect.gen(function* () {
733 + const api = makeProject({
734 + canonicalKey: "bitbucket.org/acme/api",
735 + locator: {
736 + source: "git-remote",
737 + remoteName: "origin",
738 + remoteUrl: "git@bitbucket.org:acme/api.git",
739 + },
740 + provider: SourceControlProviderKind.make("bitbucket"),
741 + displayName: "acme/api",
742 + owner: "acme",
743 + name: "api",
744 + });
745 + const harness = yield* makeHarness({ project: api });
746 + const result = yield* harness.call("read_pull_request_guide", {
747 + url: "https://bitbucket.org/acme/web/pull-requests/123",
748 + });
749 + expect(result).toMatchObject({
750 + host: "bitbucket.org",
751 + repository: "acme/web",
752 + number: 123,
753 + guide: null,
754 + currentHeadSha: "head-1",
755 + });
756 + }),
757 + );
758 +
759 it.effect("finds an Azure DevOps checkout for a pull request named by its full path", () =>
760 Effect.gen(function* () {
761 const azure = {
apps/server/src/mcp/toolkits/pullRequests/handlers.ts
+23 -9
@@ -244,10 +244,17 @@ const make = Effect.gen(function* () {
244 input,
245 target,
246 project: projectForPullRequest(known, target, callerProject),
247 + callerProject,
248 failure: null,
249 })),
250 Effect.catch((error) =>
250 - Effect.succeed({ input, target: null, project: undefined, failure: error.message }),
251 + Effect.succeed({
252 + input,
253 + target: null,
254 + project: undefined,
255 + callerProject,
256 + failure: error.message,
257 + }),
258 ),
259 ),
260 );
@@ -492,18 +499,25 @@ const make = Effect.gen(function* () {
499 if (entry !== undefined && entry.target === null) {
500 return yield* new PullRequestGuideFailedError({ detail: entry.failure ?? "" });
501 }
495 - if (entry === undefined || entry.target === null || entry.project === undefined) {
502 + // Hosts readable without a checkout (GitHub, Bitbucket, Forgejo) are read through the
503 + // caller's project; PullRequestService decides whether the host allows that.
504 + const project = entry?.project ?? entry?.callerProject;
505 + if (entry === undefined || entry.target === null || project === undefined) {
506 return yield* new PullRequestProjectNotFoundError({
507 repository: entry?.target.repository ?? input.repository ?? "",
508 });
509 }
500 - const result = yield* reviewGuides.get(guideReference(entry.project, entry.target)).pipe(
501 - Effect.mapError(
502 - (error) =>
503 - new PullRequestGuideFailedError({
504 - detail: guideFailureDetail(error),
505 - cause: error,
506 - }),
510 + const target = entry.target;
511 + const result = yield* reviewGuides.get(guideReference(project, target)).pipe(
512 + Effect.mapError((error) =>
513 + entry.project === undefined &&
514 + error._tag === "PullRequestUnavailableError" &&
515 + error.reason === "provider-unsupported"
516 + ? new PullRequestProjectNotFoundError({ repository: target.repository })
517 + : new PullRequestGuideFailedError({
518 + detail: guideFailureDetail(error),
519 + cause: error,
520 + }),
521 ),
522 );
523 return {