Skip to content

Commit 7a4755c

Browse files
fix(github): send User-Agent on all GitHub API calls (#400)
Cloudflare Workers' fetch doesn't set a default User-Agent, and GitHub's API rejects UA-less requests with 403 "Request forbidden by administrative rules" — the worker was crashing at upstream tool discovery (getAppInstallationToken) on the very first request. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e52ce73 commit 7a4755c

4 files changed

Lines changed: 5 additions & 0 deletions

File tree

github/server/lib/github-app-auth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export async function getAppInstallationToken(): Promise<string> {
154154
Authorization: `Bearer ${jwt}`,
155155
Accept: "application/vnd.github+json",
156156
"X-GitHub-Api-Version": "2022-11-28",
157+
"User-Agent": "deco-cms-github-mcp",
157158
},
158159
},
159160
);
@@ -186,6 +187,7 @@ export async function getAppInstallationToken(): Promise<string> {
186187
Authorization: `Bearer ${jwt}`,
187188
Accept: "application/vnd.github+json",
188189
"X-GitHub-Api-Version": "2022-11-28",
190+
"User-Agent": "deco-cms-github-mcp",
189191
},
190192
},
191193
);

github/server/lib/github-client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ async function postToGitHub(
2626
headers: {
2727
Accept: "application/json",
2828
"Content-Type": "application/json",
29+
"User-Agent": "deco-cms-github-mcp",
2930
},
3031
body: JSON.stringify(body),
3132
});

github/server/lib/installation-map.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export async function captureInstallationMappings(
124124
Authorization: `Bearer ${token}`,
125125
Accept: "application/vnd.github+json",
126126
"X-GitHub-Api-Version": "2022-11-28",
127+
"User-Agent": "deco-cms-github-mcp",
127128
},
128129
},
129130
);

github/server/lib/mcp-proxy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function connectUpstreamClient(token: string): Promise<Client> {
2929
requestInit: {
3030
headers: {
3131
Authorization: `Bearer ${token}`,
32+
"User-Agent": "deco-cms-github-mcp",
3233
},
3334
},
3435
},

0 commit comments

Comments
 (0)