Skip to content

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

MCP Sign in card: a turn that parks after the card failed still hears why

AdityaUmale237f93a7ab21
diff --git a/server/host/mcp-sign-in-cards.ts b/server/host/mcp-sign-in-cards.ts
index 6b62681389..4c9c14bd2e 100644
--- a/server/host/mcp-sign-in-cards.ts
+++ b/server/host/mcp-sign-in-cards.ts
@@ -57,6 +57,8 @@ const NO_CARD: Reply = { status: 404, body: { error: "no such connection request
* replaced, set aside, or refused before the browser opened. */
const ENDED: Partial<Record<McpSignInPhase, ServerLineKey>> = { expired: "server.mcp.signIn.expired", failed: "server.mcp.signIn.failed" };
+const failedText = (slug: string, reason: string): string => `OpenMausBot MCP sign-in for ${slug}: ${reason} Nothing was signed in.`;
+
export const isMcpSignInCard = (message: Message | undefined): message is McpCard =>
message?.kind === "connector" && message.connector?.source === "mcp";
@@ -191,7 +193,7 @@ export function createMcpSignInCards(deps: McpSignInCardDeps) {
function unreachable(threadId: string, card: McpCard, server: Unreachable, extra: Record<string, unknown> = {}): Reply {
const error = server.reason(deps.language(threadId));
patch(threadId, card.id, { status: "failed", error });
- const said = `OpenMausBot MCP sign-in for ${card.connector.slug}: ${server.reason(undefined)} Nothing was signed in.`;
+ const said = failedText(card.connector.slug, server.reason(undefined));
if (!find(threadId, card.id)!.connector.resumed && deps.answer(threadId, card.id, said)) patch(threadId, card.id, { resumed: true });
return { status: server.status, body: { error, ...extra } };
}
@@ -290,6 +292,7 @@ export function createMcpSignInCards(deps: McpSignInCardDeps) {
parkedAnswer(card: ConnectorCardData): string | null {
if (card.superseded || card.resumed) return null;
if (card.status === "connected") return signedInTextNow(card.slug);
+ if (card.status === "failed" && card.error) return failedText(card.slug, card.error);
return card.dismissed ? notSignedInText(card.slug) : null;
},
};
diff --git a/server/mcp-sign-in-card.test.ts b/server/mcp-sign-in-card.test.ts
index 62a62e191e..e4999bb726 100644
--- a/server/mcp-sign-in-card.test.ts
+++ b/server/mcp-sign-in-card.test.ts
@@ -399,6 +399,24 @@ describe("the Sign in card", () => {
expect(f.answers).toHaveLength(1);
});
+ it("a server that registers no apps, refused before the turn parks, still reaches the bot once it parks", async () => {
+ const f = await setup();
+ const oauth = await startFakeOAuth({ noRegistration: true });
+ const mcp = await startFakeHttpMcp({ acceptBearer: oauth.isValid, wwwAuthenticate: oauth.challenge });
+ fixtures.push(oauth, mcp);
+ f.cfg.mcpServers!.linear = { type: "http", url: mcp.url, headers: {}, enabled: true } as never;
+ const { card } = await f.signIn();
+ f.turn.parked = false;
+ const refused = await f.authorize(card);
+ expect(f.answers).toEqual([]);
+ expect(f.current(card).connector).toMatchObject({ status: "failed", error: refused.body.error });
+ expect(f.current(card).connector!.resumed).toBeFalsy();
+ const waited = resumableCards({ activePath: (threadId: string) => f.store.messagesFor(threadId) } as never, "main-chat", 0);
+ expect(waited.map((entry) => entry.id)).toEqual([card.id]);
+ expect(f.cards.parkedAnswer(f.current(card).connector!)).toBe(`OpenMausBot MCP sign-in for linear: ${refused.body.error as string} Nothing was signed in.`);
+ expect(f.cards.parkedAnswer({ ...f.current(card).connector!, resumed: true })).toBeNull();
+ });
+
it("dismiss cancels the flow and resumes with the not-signed-in text", async () => {
const f = await setup();
const { card } = await f.signIn();