Skip to content

Commit 8d188e6

Browse files
chore(mcp-server): return access instructions for 404 without API key
1 parent 61d1a70 commit 8d188e6

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

packages/mcp-server/src/code-tool.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ const remoteStainlessHandler = async ({
176176
});
177177

178178
if (!res.ok) {
179+
if (res.status === 404 && !reqContext.stainlessApiKey) {
180+
throw new Error(
181+
'Could not access code tool for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.',
182+
);
183+
}
179184
throw new Error(
180185
`${res.status}: ${
181186
res.statusText

packages/mcp-server/src/docs-search-tool.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ export const handler = async ({
7373
},
7474
'Got error response from docs search tool',
7575
);
76+
77+
if (result.status === 404 && !reqContext.stainlessApiKey) {
78+
throw new Error(
79+
'Could not find docs for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.',
80+
);
81+
}
82+
7683
throw new Error(
7784
`${result.status}: ${result.statusText} when using doc search tool. Details: ${errorText}`,
7885
);

0 commit comments

Comments
 (0)