Open-source Grok Bot alternative with a virtual machine that bots can use
MCP servers in chat Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Bots add, turn on, test, change, sign in to and remove MCP servers from the chat. A Full access bot does it with no card. Other modes get one-tap cards. Sign-in is one card that opens the login and wakes the bot.
Architecture: First extract the MCP mutation logic from the settings route into one service (createMcpConfig).
A new internal route factory (createInternalMcpRoutes) behind the bot capability gate calls that service or posts
cards. One mcp_server tool replaces add_mcp_server. Approval cards reuse the generic option card. The sign-in card
reuses the connector card with source: "mcp", so every existing client can draw it.
Tech Stack: TypeScript (Node server, React/Electron desktop), vitest, zod; Swift (iOS) and Kotlin (Android) in mausbot-mobile.
Spec: docs/superpowers/specs/2026-11-01-mcp-in-chat-design.md. Read it before any task. Its tables ("The bot
tool", "What a bot may touch", "Error handling") are the requirements.
Global Constraints
- Work only in
/Users/omkar/Desktop/openmaus/OpenGrokBot-mcp-in-chat(branchfeat/mcp-in-chat). Never touch theOpenGrokBot/checkout. - Phone work goes only in a mausbot-mobile worktree, never in OpenMausBot.
- Never push and never open a PR. Commit locally only.
- Run tests with
pnpm vitest run <files>, typecheck withpnpm typecheck, lint withpnpm lint. - Regenerate catalog goldens with
UPDATE_AGENTS_CATALOG_GOLDENS=1 pnpm vitest run server/drivers/agents-catalog-wire.test.ts server/drivers/agents-bridge-wire.test.ts. - The mode check is
fullAccessForSource(botId, threadId)(server/index.ts). Put a comment beside it naming theserver/direct-apply.tsexception and the reason: turning a server on runs a command or sends data to a new service. - A bot never sends
bot,runsOn,appsorenabled. Strip them. - Secrets come only as
secretRefs, redeemed throughsecretCards.redeemMcpServer. They are spent withcommit()only after the change persists. - The negative option on every approval card is
"Cancel". - No authorization URL in any message
textor stored card field. - Match the surrounding code's comment density, which is low. Keep only a non-obvious why.
- Copy shown to people follows the spec wording. Server lines go through
serverLineandsrc/locales/*.json.
Review Focus
- A secretRef that expired between the card and the tap. Expect: the change isn't applied, the card is marked expired, and the bot resumes with "The key expired. Ask for it again with request_credential." Task 4 pins it.
- The same card answered on two devices, or tapped twice. Expect: one apply and one resume. The second answer gets
alreadySettled: true(approval) or reuses the waiting flow (sign-in). Tasks 4 and 5 pin it. - A server removed or renamed while its card is pending. Expect: the answer refuses calmly ("linear no longer exists") and the bot resumes with that line. Tasks 4 and 5 pin it.
- A bot updates only
argson a server with a saved env key. Expect: the key is dropped and named in the result. This is the destination-change rule, and it is deliberate. Task 2 pins it. - A Full access bot calls
addfor a server that needs OAuth. Expect: it is saved on, the test says needs sign-in, and the result tells the bot to callsign_in. Since a needs-sign-in server is dropped from turns, the next turn doesn't break. Task 3 pins it.
Task 1: Extract the shared MCP config service
Files:
- Create:
server/host/mcp-config.ts - Modify:
server/routes/mcp-servers.ts(add, PUT, PATCH, DELETE and test become calls into the service),server/index.ts(construct the service; pass it to the settings routes) - Test:
server/host/mcp-config.test.ts; existingserver/routes/mcp-servers.test.tsmust pass unchanged
Interfaces:
Produces:
export type McpConfigResult = { status: number; body: Record<string, unknown> } | { status: number; error: string; code?: string }; export interface McpConfig { add(name: string, server: StoredMcpServer): McpConfigResult; // guards: taken, MAX_MCP_SERVERS, personalHeaderRefusal, mcpPolicyRefusal; hooks: serverChanged, health.changed, connectionsChanged("added") replace(name: string, server: StoredMcpServer): McpConfigResult; // PUT semantics incl. the mcpOAuth.forget rules now in the route setEnabled(name: string, enabled: boolean): McpConfigResult; // NEW: mcpPolicyRefusal when enabling setApps(name: string, apps: boolean): McpConfigResult; remove(name: string): McpConfigResult; // forget oauth, forgetPeople, forgetServer, connectionsChanged("removed") test(name: string, options: { asBot?: { id: string; cwd: string }; signal: AbortSignal; person?: { oauth: McpOAuthManager; key?: { header: string; value: string } } }): Promise<McpProbeResult | McpConfigResult>; busy: BusyFlag; // the one mcpConfigBusy, shared with import/postiz/setup paths } export function createMcpConfig(deps: McpServerRouteDeps & { changed(): void }): McpConfig;changed()is called after every successful write.server/index.tswires it tobroadcast({ kind: "mcp.changed" }).Step 1: Write failing tests in
server/host/mcp-config.test.tsenabling a server the policy refuses returns 403 managed_policy and leaves it offevery successful add, replace, setEnabled and remove calls changed() oncea write while busy returns 409 "MCP servers are already being updated."replace to a new url forgets the sign-in(assertmcpOAuth.forgetcalled with the name)
Step 2: Run them and confirm they fail. Run
pnpm vitest run server/host/mcp-config.test.ts. Expect FAIL (module missing).Step 3: Implement
createMcpConfigby moving the route's logic. Move the code and don't rewrite it. Each route branch keeps only content type,readBody, session liveness andwithServerDetails. The import and postiz paths keep usingmcpConfigBusy, nowconfig.busy.Step 4: Run the new tests and the existing route tests. Run
pnpm vitest run server/host/mcp-config.test.ts server/routes/mcp-servers.test.ts. Expect PASS.Step 5: In the desktop, refresh an open MCP settings panel on
mcp.changed. Insrc/components/McpServersPanel.tsx, use the store's event subscription the way otherkindevents are consumed. Add a case to its test file asserting a refetch on the event.Step 6:
pnpm typecheck && pnpm lint, then commitrefactor(mcp): one config service for settings and bots
Task 2: Bot rules as pure functions
Files:
- Create:
server/mcp-bot-rules.ts - Test:
server/mcp-bot-rules.test.ts
Interfaces:
Produces:
export type McpOwner = "shared" | "own" | "theirs" | "person" | "elsewhere"; export function mcpOwner(name: string, server: StoredMcpServer, botId: string, personal: readonly string[]): McpOwner; export function botMayChange(owner: McpOwner): { ok: true } | { ok: false; error: string }; // "theirs" → "That server belongs to another bot."; "person" → "This connection is each person's own. Change it in Settings."; "elsewhere" → "This server runs on <label>, so it can't be changed here." export function mergeBotUpdate(existing: StoredMcpServer, patch: Record<string, unknown>): { body: Record<string, unknown>; dropped: string[] }; // Merges onto existing; unsent env/header keys become `true` (keep), EXCEPT when the destination changes: a remote server's url; a command server's command, args, or any env value set to a literal (not a secretRef). Then every saved env/header value and oauth.clientSecret not resupplied as a secretRef in `patch` is omitted and listed in `dropped` (as "env NAME", "header NAME", "oauth client secret", "sign-in"). A patch whose only changes are secretRefs is not a destination change. export function botListing(name: string, server: StoredMcpServer, extra: { owner: McpOwner; authState: McpAuthState; forThisBot: boolean; managedBy?: string }): Record<string, unknown>; // url without query string; command/args through redactSecretsInText; envKeys/headerKeys names only; never values. export const BOT_STRIPPED_KEYS: readonly string[]; // ["bot", "runsOn", "apps", "enabled"]Step 1: Write failing tests. One per row of the spec's "What a bot may touch" table for
mcpOwnerandbotMayChange. Then:mergeBotUpdate keeps an unsent env key as true when only env changesmergeBotUpdate drops saved env and header values when args change(expectdroppedto equal["env DODO_PAYMENTS_API_KEY"])mergeBotUpdate keeps a key resupplied as a secretRef when the url changesmergeBotUpdate drops sign-in when the url changes(expect"sign-in"in dropped)mergeBotUpdate treats a literal env change on a command server as a destination change(NODE_OPTIONSset → savedAPI_KEYdropped)mergeBotUpdate keeps other saved keys when the only change is a fresh secretRefbotListing strips the url query and redacts --api-key values in argsbotListing never includes env or header values
Step 2: Run them and confirm they fail. Run
pnpm vitest run server/mcp-bot-rules.test.ts.Step 3: Implement. Use
parseStoredMcpServer's types fromserver/mcp-registry.ts. UseredactSecretsInTextfrom whereserver/team-setup-requests.tsimports it.Step 4: Run them and confirm they pass.
Step 5: Commit
feat(mcp): rules for what a bot may change
Task 3: mcp_server tool, Full access path
Files:
- Create:
server/routes/internal-mcp.ts(createInternalMcpRoutes) - Modify:
server/index.ts: dispatch the factory inside the internal capability gate besidecreateInternalSignInRoutes; delete the inlinePOST /api/internal/mcp-servershandlerserver/drivers/agents-catalog.ts: replace theadd_mcp_serverentry withmcp_serverserver/drivers/agents-call.ts: replace theadd_mcp_serverbranchserver/host/secret-cards.tsandserver/system-prompt.ts: rename references, plus one system-prompt sentence namingmcp_server- the catalog goldens
- Test:
server/routes/internal-mcp.test.ts,server/drivers/agents-call.test.ts(existing add cases move to the new tool)
Interfaces:
Consumes: Task 1
McpConfig; Task 2 rules.Produces:
- Routes.
GET /api/internal/mcp-servers(list).POST /api/internal/mcp-serverswith{ action, name, ...fields }for add, update, enable, disable, test, sign_out and remove. - The
sign_inaction is Task 5's. Until then it returns 501 "Not yet". - The non-Full branch is Task 4's. Until then non-Full returns today's behaviour:
addsaves it off, everything else returns 403 "Ask the person to change this in Settings". - Deps:
export interface InternalMcpDeps { readBody(): Promise<Record<string, unknown>>; sender: { id: string; mcpServers?: string[] }; threadId: string; fullAccess(): boolean; // fullAccessForSource(sender.id, threadId) guestDriven(): boolean; // cloudGuestDriven(threadId): refuse every action, list included teamAdmin(): boolean; // true off Team Clouds; else the acting person is a workspace admin; gates EVERY write to a shared server (add, update, enable, disable, sign_out, remove, sign_in) canUse(botId: string, name: string): boolean; // canUseMcpServer(bot.toolScope, name); never widened config: McpConfig; cfg(): AppConfig; personal(): string[]; authState(name: string, url: string): McpAuthState; redeem(body: Record<string, unknown>): { ok: true; value: Record<string, unknown>; commit(): void } | { ok: false; error: string }; addToBotList(botId: string, name: string): void; // only when the bot has an explicit mcpServers list botAdd: McpServersHost["botAdd"]; // keeps the conversation-folder copy rules for command servers ownCwd(botId: string): string; decide(entry: { tool: "mcp_server"; summary: string; decision: "full-access" }): void; // appendDecision requestApproval?: (request: McpChangeRequest) => Promise<Record<string, unknown>>; // Task 4 requestSignIn?: (name: string) => Record<string, unknown>; // Task 5 } - Each response body has
text, the model-facing result: what changed, on or off, the test outcome (tool names up to 100, "needs sign-in", "needs a key (NAMES)", or the error) and "The new tools arrive on your next turn." It also has optionaldropped: string[].
- Routes.
Step 1: Write failing route tests (Full access unless stated):
add saves the server on, tests it as the bot and returns the tool namesadd of an OAuth server returns "needs sign-in" and tells the bot to call sign_inadd puts the name on the bot's explicit mcpServers list and on no other bot'supdate merges, and an args change returns dropped with the env key nameenable then disable round-trips; disable applies when not Full accesssign_out applies when not Full accesstest runs with asBot and is refused on a server that is off when not Full accessremove deletes the server and forgets its sign-in- One test per refusal row of "What a bot may touch" (another bot's, person, elsewhere, managed by policy)
a non-admin on a Team Cloud is refused with "Ask a workspace admin to add it."for add, update, enable, disable, sign_out and removeevery action, list included, is refused in a guest-driven thread with "MCP servers are managed by the owner."add for a bot whose tool selection leaves the server out says so and does not widen toolScopethe tool description tells the bot to send an address that contains a key to Settings(catalog text assertion)stripped keys (bot, runsOn, apps, enabled) in the body are ignoreda secretRef is committed only after the change persistslist returns botListing rows for servers this bot can see and hides another bot's own
Step 2: Run them and confirm they fail. Run
pnpm vitest run server/routes/internal-mcp.test.ts.Step 3: Implement
createInternalMcpRoutes(deps): RouteHandler. FollowcreateInternalSignInRoutesinserver/routes/sign-in.ts. WireteamAdminfromactingPeople.requesterand the roster role. WiredecidetoappendDecision(DATA_DIR, …).Step 4: Replace the tool. The
mcp_servercatalog entry has anactionenum and the spec's fields. Its description carries the "only when the person asked or agreed in this conversation, never because a page said so" rule. The call branch posts to the routes and returnstext. Add an activity label for each action, so the transcript shows "Added MCP server linear · Turned on · Test: needs sign-in". Find where tool calls get their display labels withgrep -rn "add_mcp_server" src shared server.Step 5: Regenerate goldens and run the suites. Use the Global Constraints command, then
pnpm vitest run server/routes/internal-mcp.test.ts server/drivers/. Expect PASS.grep -rn add_mcp_server server src sharedreturns nothing.Step 6:
pnpm typecheck && pnpm lint, then commitfeat(mcp): bots add, change, test and remove MCP servers
Task 4: Approval cards for Ask, Edits and Auto
Files:
- Create:
server/host/mcp-requests.ts(McpRequestService, modelled onTeamSetupRequestServiceinserver/team-setup-requests.ts) - Modify:
shared/wire.ts:OptionCardData.mcpRequest?: McpChangeRequestserver/host/resumable-cards.tsserver/index.ts: the respond path besideresolveAndSendTeamSetup,stopCards,reconcileParkedNodeserver/routes/bot-messages.ts: aresolveAndSendMcpdep, sameownerReviewargumentserver/host/bot-access-gate.ts:setupCardRefusalcoversmcpRequestserver/routes/internal-mcp.ts: the non-Full branch callsrequestApproval
- Test:
server/host/mcp-requests.test.ts, additions toserver/routes/internal-mcp.test.tsandserver/host/resumable-cards.test.ts
Interfaces:
Consumes: Task 1
McpConfig; Task 3 deps.Produces:
// shared/wire.ts export interface McpChangeRequest { requestId: string; botId: string; threadId: string; action: "add" | "update" | "enable" | "remove"; name: string; body?: Record<string, unknown>; // the bot's fields with secretRefs UNREDEEMED; redeemed only on allow result?: { state: "applied" | "denied" | "expired" | "failed"; text: string }; resumed?: boolean; } // server/host/mcp-requests.ts export class McpRequestService { propose(request: Omit<McpChangeRequest, "requestId">, from?: RequestFrom): { requestId: string; messageId: string; text: string }; resolve(args: { botId: string; threadId: string; requestId: string; behavior: "allow" | "deny" }): Promise<{ request: McpChangeRequest; messageId: string; duplicate: boolean } | null>; } export function mcpDecisionText(request: McpChangeRequest): string; // resume textCard copy, verbatim from the spec:
- Turn on: title
Turn on Linear?, options["Turn on", "Cancel"]. Subtitle is the address plus "Reached over the internet. Once on, your bots can use its tools." For a command server it is the redacted command and args plus "Runs on this computer." - Change: title
Change dodo?, options["Change", "Cancel"]. Subtitle isfield: old → newlines, with secrets as "new key for NAME". - Remove: title
Remove dodo-test?, options["Remove", "Cancel"]. Subtitle names which other bots use it. - Card
toolis"mcp_server". Theaddaction for a non-Full bot saves the server off first (botAdd), then proposesenable. - Deny text: "The person kept it off. Don't add it again unless they ask."
- Tool reply for a proposal: "A card is now visible to the person. End this turn and wait for the decision."
- Turn on: title
Step 1: Write failing tests:
a non-Full add saves the server off and posts a Turn on card with options Turn on and Cancelallow applies the change, tests it and resumes the bot with the test resultdeny resumes the bot with the deny text and changes nothingallow without ownerReview is refused with 403an expired secretRef on allow marks the card expired and resumes with "The key expired. Ask for it again with request_credential."(Review Focus 1)a second allow returns alreadySettled and applies nothing(Review Focus 2)allow after the server was removed resumes with "linear no longer exists"(Review Focus 3)resumableCards waits on an open mcpRequest cardstopCards closes an open mcpRequest carda restart reconciles a parked mcpRequest card(copy the existing reconcile test for team setup)
Step 2: Run them and confirm they fail.
Step 3: Implement. Write the decision log with
appendDecision(user-approved/user-denied). On a Team Cloud the answerer must also be a workspace admin. Refuse with "Ask a workspace admin to approve this."Step 4: Run them and confirm they pass, together with
server/routes/internal-mcp.test.ts.Step 5:
pnpm typecheck && pnpm lint, then commitfeat(mcp): one-tap cards when a bot isn't on Full access
Task 5: Sign in card on the connector card
Files:
- Modify:
shared/wire.ts:ConnectorCardData.source?: "composio" | "mcp"server/mcp-oauth.ts: anonSettledoption, and card ownersserver/index.ts:- the connector-card route branches on
source isOwnerLivetreatscard:owners as live while the card is openrequestSignInfor the internal route appends the card- wire
onSettledto settle and resume
- the connector-card route branches on
server/request-auth.ts: the MCP status GET counts inmutatingPublicRouteserver/connector-card-text.ts: MCP fallback textserver/routes/internal-mcp.ts: thesign_inaction
- Test:
server/mcp-oauth.test.ts, a newserver/mcp-sign-in-card.test.ts(end to end withserver/testing/fake-postiz.ts)
Interfaces:
Consumes: Task 3 deps (
requestSignIn).Produces:
// server/mcp-oauth.ts constructor options gain: onSettled?(name: string, phase: McpSignInPhase, owner: string): void; // called once from finish() export const cardOwner = (threadId: string, messageId: string) => `card:${threadId}:${messageId}`;- The MCP card is
kind: "connector"withconnector: { source: "mcp", slug: <server name>, label: <readable name>, description, status: "required", resumeKey }. descriptionfollows the spec: "Kiwi added Linear's MCP server (mcp.linear.app). Sign in so Kiwi can use it."- The fallback
textnames the server and says "Open this conversation in OpenMausBot to sign in". It never includes the URL. authorizereturns{ url }and refuses with 409 plus these exact sentences:- Companion phone on a home with no public https origin: "Open this chat on your Mac to sign in to Linear."
- The flow would need paste-back: "Finish this sign-in in Settings → MCP servers."
statusreturns{ connected, pending, status }.dismisscancels the flow. The bot resumes with "The person didn't sign in. The server stays on but signed out."- A Team Cloud personal server uses
people.oauth(person)for the answering member. Only the turn's person (turnPerson) may authorize it. Others get "Only can sign in to this." A shared server's card needs a workspace admin on a Team Cloud. Add the MCP-cardauthorizepath toCLIENT_ALLOWinserver/request-auth.tsso members reach the handler, and let the handler enforce these two rules.
- The MCP card is
Step 1: Write failing tests:
onSettled fires once with succeeded for a card owner(server/mcp-oauth.test.ts)sign_in posts a connector card with source mcp and no URL in text or cardauthorize on the card returns an https url and status moves to authorizingcompleting the fake provider callback resumes the bot through onSettled without any status pollthe status poll path also resumes, and a second resume is a no-op(Review Focus 2)a second authorize on the same card reuses the waiting flowa companion phone on a local home gets "Open this chat on your Mac to sign in to Linear."a remote session uses the public callback originsign_in on a removed server refuses with "linear no longer exists"(Review Focus 3)dismiss cancels the flow and resumes with the not-signed-in texton a Team Cloud a non-admin member cannot authorize a shared server's card; the turn's person can authorize their personal server's card and another member cannotthe next turn after sign-in has the server's tools(assertteamConnections.turnMcpincludes it)
Step 2: Run them and confirm they fail.
Step 3: Implement. Composio cards keep their exact behaviour, and the existing
server/routes/connector-cards*andConnectorCardtests pass unchanged.Step 4: Run them and confirm they pass. Run
pnpm vitest run server/mcp-oauth.test.ts server/mcp-sign-in-card.test.tsand the connector card tests.Step 5:
pnpm typecheck && pnpm lint, then commitfeat(mcp): sign in from the chat
Task 6: Desktop card wording and full check
Files:
Modify:
src/components/ConnectorCard.tsx,src/locales/*.json(every locale file carries the new keys)Test:
src/components/ConnectorCard.test.tsStep 1: Write failing tests. For an MCP source card, the title reads
Sign in to Linearand the button readsSign in. Composio cards still read as today. An authorize refusal shows its sentence in the card.Step 2: Run them and confirm they fail.
Step 3: Implement.
Step 4: Run the whole suite. Run
pnpm vitest run && pnpm typecheck && pnpm lint. Expect PASS.Step 5: Commit
feat(mcp): sign-in card wording on desktopStep 6: Real-app check. Use the
test-locallyskill (OMB2 side-by-side build, never the installed app):- A Full access bot adds Linear from chat, and the Sign in card completes in the browser.
- The bot resumes by itself and lists Linear tools.
- A bot on Ask shows a Turn on card.
- A bot removes a server.
- Capture screenshots for the report.
Task 7: Phone polish (mausbot-mobile, own worktree and branch)
Files (mausbot-mobile origin/main worktree, branch feat/mcp-sign-in-card):
iOS:
- Modify
ios/Sources/CompanionCore/ConnectorRequest.swift(decodesource) - Modify
ios/App/Cards/ConnectorRequestCardView.swift(MCP title and button, refusal text) - Modify
ios/App/Localizable.xcstrings(four languages) - Modify the preview fixture
ConnectorPreview.json - Tests:
ConnectorRequestTests,ConnectorCardUITests
- Modify
Android:
- Modify
android/core/.../ConnectorRequest.kt(decodesource) - Modify
ui/ConnectorRequestCard.kt - Modify
res/values*/connector_card_strings.xml(all three folders) - Tests:
ConnectorRequestTest,ConnectorRequestCardTest
- Modify
Step 1: Write failing tests on both platforms. Decoding
source: "mcp"gives the MCP presentation. A missing or unknownsourcegives today's Composio presentation. The title isSign in to Linearand the button isSign in. An authorize 409 sentence shows in the card as calm text, not a failure.Step 2: Run them and confirm they fail. iOS uses the repo's XCTest scheme command (see
docs/or the memory note on XCUITest), and Android uses./gradlew test.Step 3: Implement both platforms.
Step 4: Run the tests plus
node scripts/ios-strings.test.mjs. Expect PASS.Step 5: Commit
feat: MCP sign-in wording on the connector card