feat(prd-1): implement M6 - MCP server platform routing

- Add platform detection to prepareMcpConfig() via detectPlatform()
- Skip GitHub public MCP server (ghcr.io/github/github-mcp-server) on Forgejo
- Skip checkActionsReadPermission on Forgejo (workflow token has full access)
- Reuse existing github-actions-server.ts for both platforms (no duplication)
- Add 6 Forgejo-specific tests to install-mcp-server.test.ts
- Updated PRD checkboxes for M6

Progress: 67% complete (6/9 milestones) - M7 now unblocked

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Vlad MocanuandClaude Opus 4.6 committed 2026-02-25 17:57:35 +02:00
1 parent 0802ac18eb
commit ce1459fe7f
3 files changed
+208 -17

No files matched your search

+31 -14
View File
@@ -4,6 +4,7 @@ import type { GitHubContext } from "../github/context";
import { isEntityContext } from "../github/context";
import { Octokit } from "@octokit/rest";
import type { AutoDetectedMode } from "../modes/detector";
import { detectPlatform } from "../platform/detector";
type PrepareConfigParams = {
githubToken: string;
@@ -66,6 +67,10 @@ export async function prepareMcpConfig(
try {
const allowedToolsList = allowedTools || [];
// Detect platform (github vs forgejo)
const platform = detectPlatform();
const isForgejo = platform === "forgejo";
// Detect if we're in agent mode (explicit prompt provided)
const isAgentMode = mode === "agent";
@@ -167,21 +172,31 @@ export async function prepareMcpConfig(
hasWorkflowToken;
if (shouldIncludeCIServer) {
// Verify the token actually has actions:read permission
const actuallyHasPermission = await checkActionsReadPermission(
process.env.DEFAULT_WORKFLOW_TOKEN || "",
owner,
repo,
);
// On Forgejo, the workflow token has full repo access — skip the
// GitHub-specific permission probe which checks for 'actions: read'.
// On GitHub, verify the token actually has actions:read permission.
let includeCIServer = isForgejo;
if (!actuallyHasPermission) {
core.warning(
"The github_ci MCP server requires 'actions: read' permission. " +
"Skipping CI server installation. " +
"To enable CI status checks, add 'actions: read' to your workflow permissions. " +
"See: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token",
if (!includeCIServer) {
const actuallyHasPermission = await checkActionsReadPermission(
process.env.DEFAULT_WORKFLOW_TOKEN || "",
owner,
repo,
);
} else {
if (!actuallyHasPermission) {
core.warning(
"The github_ci MCP server requires 'actions: read' permission. " +
"Skipping CI server installation. " +
"To enable CI status checks, add 'actions: read' to your workflow permissions. " +
"See: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token",
);
} else {
includeCIServer = true;
}
}
if (includeCIServer) {
baseMcpConfig.mcpServers.github_ci = {
command: "bun",
args: [
@@ -200,7 +215,9 @@ export async function prepareMcpConfig(
}
}
if (hasGitHubMcpTools) {
// The GitHub public MCP server (ghcr.io/github/github-mcp-server) is
// GitHub-only — it doesn't work with Forgejo instances.
if (hasGitHubMcpTools && !isForgejo) {
baseMcpConfig.mcpServers.github = {
command: "docker",
args: [