Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/mcp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,7 @@ export class GittensoryMcp {
private async predictGate(input: z.infer<z.ZodObject<typeof predictGateShape>>): Promise<ToolPayload> {
this.requireContributorAccess(input.login);
const repoFullName = `${input.owner}/${input.repo}`;
await this.requireRepoAccess(repoFullName);
const [repo, issues, pullRequests, bounties, issueQuality, manifest] = await Promise.all([
getRepository(this.env, repoFullName),
listIssues(this.env, repoFullName),
Expand Down
15 changes: 15 additions & 0 deletions test/unit/mcp-predict-gate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ describe("MCP gittensory_predict_gate", () => {
expect((minimal.structuredContent as { pack: string }).pack).toBe("oss-anti-slop");
});

it("is repo-scoped: a session cannot predict against an inaccessible repo", async () => {
const env = createTestEnv();
await upsertRepositoryFromGitHub(env, { name: "private-roadmap", full_name: "victimco/private-roadmap", private: true, owner: { login: "victimco" } });
await upsertRepoFocusManifest(env, "victimco/private-roadmap", { gate: { pack: "oss-anti-slop", linkedIssue: "block" } });
const { session } = await createSessionForGitHubUser(env, { login: "miner1", id: 1 });
const client = await connect(env, { kind: "session", actor: "miner1", session });

const result = await client.callTool({
name: "gittensory_predict_gate",
arguments: { login: "miner1", owner: "victimco", repo: "private-roadmap", title: "Probe private repo" },
});
expect(result.isError).toBe(true);
expect(JSON.stringify(result.content)).toContain("session cannot access this repository");
});

it("is self-scoped: a session cannot predict for another login", async () => {
const env = createTestEnv();
const { session } = await createSessionForGitHubUser(env, { login: "miner1", id: 1 });
Expand Down