-
Notifications
You must be signed in to change notification settings - Fork 1k
initial apphosting mcp tool #8605
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
+188
−1
Merged
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
cc064c0
initial apphosting mcp tool
bkendall 214d190
Merge branch 'master' into bk-mcp-apphosting
bkendall a51bd5c
Merge branch 'master' of github.com:firebase/firebase-tools into bk-m…
bkendall a4088ba
add fetchServiceLogs function
bkendall 98d42f3
add run tool to fetch logs
bkendall 9cb48c1
add a little more description for location
bkendall b6916b9
cleaning up logic a bit
bkendall 5f8ed3a
Merge remote-tracking branch 'origin/master' into bk-mcp-apphosting
bkendall 77575ea
Merge remote-tracking branch 'origin' into bk-mcp-apphosting
bkendall d757d2d
add new tools to smoke test
bkendall dccc983
don't reinvent the cloud run logs wheel
bkendall 4312b49
back out cloud run tool
bkendall 6a092a6
creates a new logs helper for app hosting for both build and runtime …
bkendall c0de917
Merge branch 'master' of github.com:firebase/firebase-tools into bk-m…
bkendall 049df71
lint issues
bkendall c020877
some funny business got into my code. undoing it
bkendall 4dad065
add changelog
bkendall 67e3d14
formatting.
bkendall 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -266,7 +266,7 @@ | |
done: boolean; | ||
// oneof result | ||
error?: Status; | ||
response?: any; | ||
// end oneof result | ||
} | ||
|
||
|
@@ -333,6 +333,19 @@ | |
return res.body; | ||
} | ||
|
||
/** | ||
* Gets traffic details. | ||
*/ | ||
export async function getTraffic( | ||
projectId: string, | ||
location: string, | ||
backendId: string, | ||
): Promise<Traffic> { | ||
const name = `projects/${projectId}/locations/${location}/backends/${backendId}/traffic`; | ||
const res = await client.get<Traffic>(name); | ||
return res.body; | ||
} | ||
|
||
/** | ||
* List all backends present in a project and location. | ||
*/ | ||
|
@@ -548,14 +561,14 @@ | |
/** | ||
* Ensure that the App Hosting API is enabled on the project. | ||
*/ | ||
export async function ensureApiEnabled(options: any): Promise<void> { | ||
const projectId = needProjectId(options); | ||
return await ensure(projectId, apphostingOrigin(), "app hosting", true); | ||
} | ||
|
||
/** | ||
* Generates the next build ID to fit with the naming scheme of the backend API. | ||
* @param counter Overrides the counter to use, avoiding an API call. | ||
Check warning on line 571 in src/gcp/apphosting.ts
|
||
*/ | ||
export async function getNextRolloutId( | ||
projectId: string, | ||
|
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,4 @@ | ||
import { ServerTool } from "../../tool"; | ||
import { list_backends } from "./list_backends"; | ||
|
||
export const appHostingTools: ServerTool[] = [list_backends]; |
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,46 @@ | ||
import { z } from "zod"; | ||
import { tool } from "../../tool.js"; | ||
import { toContent } from "../../util.js"; | ||
import { NO_PROJECT_ERROR } from "../../errors.js"; | ||
import { | ||
Backend, | ||
getTraffic, | ||
listBackends, | ||
parseBackendName, | ||
Traffic, | ||
} from "../../../gcp/apphosting.js"; | ||
|
||
export const list_backends = tool( | ||
{ | ||
name: "list_backends", | ||
description: | ||
"Retrieves a list of App Hosting backends in the current project. The `uri` is the public URL of the backend.", | ||
inputSchema: z.object({ | ||
location: z | ||
.string() | ||
.optional() | ||
.default("-") | ||
.describe("Limit the listed backends to this region."), | ||
}), | ||
annotations: { | ||
title: "List App Hosting backends.", | ||
readOnlyHint: true, | ||
}, | ||
_meta: { | ||
requiresAuth: true, | ||
requiresProject: true, | ||
}, | ||
}, | ||
async ({ location } = {}, { projectId }) => { | ||
if (!projectId) return NO_PROJECT_ERROR; | ||
bkendall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!location) location = "-"; | ||
const data: (Backend & { traffic: Traffic })[] = []; | ||
const backends = await listBackends(projectId, location); | ||
bkendall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for (const backend of backends.backends) { | ||
const { location, id } = parseBackendName(backend.name); | ||
const traffic = await getTraffic(projectId, location, id); | ||
data.push({ ...backend, traffic: traffic }); | ||
} | ||
return toContent(data); | ||
}, | ||
); |
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
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.
Uh oh!
There was an error while loading. Please reload this page.