Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

MCP Sign in card: a discovery that fails for now leaves the card retryable

AdityaUmale9b065ddc281e
diff --git a/server/host/mcp-sign-in-cards.ts b/server/host/mcp-sign-in-cards.ts
index 4c9c14bd2e..f894114bb1 100644
--- a/server/host/mcp-sign-in-cards.ts
+++ b/server/host/mcp-sign-in-cards.ts
@@ -171,9 +171,10 @@ export function createMcpSignInCards(deps: McpSignInCardDeps) {
} catch (error) {
if (error instanceof McpSignInError) return { status: error.status, body: { error: error.message } };
if (error instanceof McpOAuthError) {
- // A busy port frees up; the other failures last until the server is set up differently.
+ // Only a server that registers no apps stays refused until it is set up differently. "not-oauth" also covers a
+ // discovery request that failed for now, and a busy port frees up: those leave the card for another tap.
const now = find(threadId, card.id);
- if (error.code === "port-busy" || !now || now.connector.dismissed) return { status: 400, body: { error: error.message, code: error.code } };
+ if (error.code !== "no-registration" || !now || now.connector.dismissed) return { status: 400, body: { error: error.message, code: error.code } };
return unreachable(threadId, now, { status: 400, reason: () => error.message }, { code: error.code });
}
return { status: 502, body: { error: error instanceof Error ? error.message : "Sign-in could not start." } };
diff --git a/server/mcp-sign-in-card.test.ts b/server/mcp-sign-in-card.test.ts
index e4999bb726..53e9c4b904 100644
--- a/server/mcp-sign-in-card.test.ts
+++ b/server/mcp-sign-in-card.test.ts
@@ -417,6 +417,21 @@ describe("the Sign in card", () => {
expect(f.cards.parkedAnswer({ ...f.current(card).connector!, resumed: true })).toBeNull();
});
+ it("a discovery that fails for now leaves the card for another tap and tells the bot nothing", async () => {
+ const f = await setup();
+ const oauth = await startFakeOAuth();
+ const mcp = await startFakeHttpMcp({ acceptBearer: oauth.isValid, wwwAuthenticate: oauth.challenge });
+ fixtures.push(mcp);
+ f.cfg.mcpServers!.linear = { type: "http", url: mcp.url, headers: {}, enabled: true } as never;
+ const { card } = await f.signIn();
+ await oauth.close();
+ const refused = await f.authorize(card);
+ expect(refused).toMatchObject({ status: 400, body: { code: "not-oauth" } });
+ expect(f.current(card).connector!.status).not.toBe("failed");
+ expect(f.current(card).connector!.error).toBeUndefined();
+ expect(f.answers).toEqual([]);
+ });
+
it("dismiss cancels the flow and resumes with the not-signed-in text", async () => {
const f = await setup();
const { card } = await f.signIn();