-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(mcp): Address auth issues with Firebase Studio environment #8871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b990534
still debugging
mbleigh 0a8f315
more timeouts and studio env handling
mbleigh c8e607d
small fixes
mbleigh e2458f3
exclude create_project from firebase studio
mbleigh 54322f6
Merge branch 'master' into mb/mcp/studio-startup
mbleigh 13a2850
Update src/requireAuth.ts
mbleigh afd223b
touche, bot
mbleigh beb291b
Merge branch 'mb/mcp/studio-startup' of github.com:firebase/firebase-…
mbleigh cac5a1e
lint
mbleigh 4d7203f
vscode fix
mbleigh ba4a63e
revert vscode since it isnt picking up
mbleigh 758b7d0
fix
mbleigh 196baca
remove filtering
mbleigh 473a5b1
Merge branch 'master' into mb/mcp/studio-startup
mbleigh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { dirExistsSync } from "./fsutils"; | ||
|
||
let googleIdxFolderExists: boolean | undefined; | ||
export function isFirebaseStudio() { | ||
Check warning on line 4 in src/env.ts
|
||
if (googleIdxFolderExists === true || process.env.MONOSPACE_ENV) return true; | ||
if (googleIdxFolderExists === false) return false; | ||
googleIdxFolderExists = dirExistsSync("/google/idx"); | ||
return googleIdxFolderExists; | ||
} | ||
|
||
export function isFirebaseMcp() { | ||
Check warning on line 11 in src/env.ts
|
||
return !!process.env.IS_FIREBASE_MCP; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; | ||
import { JSONRPCMessage } from "@modelcontextprotocol/sdk/types.js"; | ||
import { appendFileSync } from "fs"; | ||
import { appendFile } from "fs/promises"; | ||
|
||
export class LoggingStdioServerTransport extends StdioServerTransport { | ||
path: string; | ||
|
||
constructor(path: string) { | ||
super(); | ||
this.path = path; | ||
appendFileSync(path, "--- new process start ---\n"); | ||
const origOnData = this._ondata; | ||
this._ondata = (chunk: Buffer) => { | ||
origOnData(chunk); | ||
appendFileSync(path, chunk.toString(), { encoding: "utf8" }); | ||
}; | ||
} | ||
|
||
async send(message: JSONRPCMessage) { | ||
await super.send(message); | ||
await appendFile(this.path, JSON.stringify(message) + "\n"); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Races a promise against a timer, returns a fallback value (without rejecting) when time expires. | ||
*/ | ||
export async function timeoutFallback<T, V>( | ||
promise: Promise<T>, | ||
value: V, | ||
timeoutMillis = 2000, | ||
): Promise<T | V> { | ||
return Promise.race([ | ||
promise, | ||
new Promise<V>((resolve) => setTimeout(() => resolve(value), timeoutMillis)), | ||
]); | ||
} | ||
|
||
export async function timeoutError<T>( | ||
promise: Promise<T>, | ||
error?: string | Error, | ||
timeoutMillis = 5000, | ||
): Promise<T> { | ||
if (typeof error === "string") error = new Error(error); | ||
return Promise.race<T>([ | ||
promise, | ||
new Promise((resolve, reject) => { | ||
setTimeout(() => reject(error || new Error("Operation timed out.")), timeoutMillis); | ||
}), | ||
]); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have monospace specific logic in autoAuth that sets the user from the returned access token as the active user (so that it appears like the user is logged in). I'm concerned about the case where these tokens are present but expired - MCP server will tell them to login, but I think
firebase login
might not work as expected.I think we probably need to clean up the auth strategy overall ASAP - what you have here is probably still an improvement over the current state tho