-
Notifications
You must be signed in to change notification settings - Fork 2.3k
chore: Implement install_extension command #764
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
9 commits
Select commit
Hold shift + click to select a range
e313702
Implement install_extension command
aa08758
Implement install_extension command
2d7a8dc
Fix extension tests
181c466
Update formatting
4a2611d
Hide extensions from docs
25f85bb
Fix pr comments
be49b6b
Move extension test to fixtures
f94c6aa
Update license year
6b7f2a9
pr comments
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
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
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,29 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import {zod} from '../third_party/index.js'; | ||
|
|
||
| import {ToolCategory} from './categories.js'; | ||
| import {defineTool} from './ToolDefinition.js'; | ||
|
|
||
| export const installExtension = defineTool({ | ||
|
nattallius marked this conversation as resolved.
|
||
| name: 'install_extension', | ||
| description: 'Installs a Chrome extension from the given path.', | ||
| annotations: { | ||
| category: ToolCategory.EXTENSIONS, | ||
| readOnlyHint: false, | ||
| }, | ||
| schema: { | ||
| path: zod | ||
| .string() | ||
| .describe('Absolute path to the unpacked extension folder.'), | ||
| }, | ||
| handler: async (request, response, context) => { | ||
| const {path} = request.params; | ||
| const id = await context.installExtension(path); | ||
| response.appendResponseLine(`Extension installed. Id: ${id}`); | ||
| }, | ||
| }); | ||
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
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 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import assert from 'node:assert'; | ||
| import path from 'node:path'; | ||
| import {describe, it} from 'node:test'; | ||
|
|
||
| import {installExtension} from '../../src/tools/extensions.js'; | ||
| import {withMcpContext} from '../utils.js'; | ||
|
|
||
| const EXTENSION_PATH = path.join( | ||
| import.meta.dirname, | ||
| '../../../tests/tools/fixtures/extension', | ||
| ); | ||
|
|
||
| describe('extension', () => { | ||
| it('installs an extension and verifies it is listed in chrome://extensions', async () => { | ||
|
nattallius marked this conversation as resolved.
|
||
| await withMcpContext(async (response, context) => { | ||
| await installExtension.handler( | ||
| {params: {path: EXTENSION_PATH}}, | ||
| response, | ||
| context, | ||
| ); | ||
|
|
||
| const responseLine = response.responseLines[0]; | ||
| assert.ok(responseLine, 'Response should not be empty'); | ||
| const match = responseLine.match(/Extension installed\. Id: (.+)/); | ||
| const extensionId = match ? match[1] : null; | ||
| assert.ok(extensionId, 'Response should contain a valid key'); | ||
|
|
||
| const page = context.getSelectedPage(); | ||
| await page.goto('chrome://extensions'); | ||
|
|
||
| const element = await page.waitForSelector( | ||
| `extensions-manager >>> extensions-item[id="${extensionId}"]`, | ||
| ); | ||
| assert.ok( | ||
| element, | ||
| `Extension with ID "${extensionId}" should be visible on chrome://extensions`, | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
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,8 @@ | ||
| { | ||
| "manifest_version": 3, | ||
| "name": "Test Extension", | ||
| "version": "1.0", | ||
| "action": { | ||
| "default_popup": "popup.html" | ||
| } | ||
| } |
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,6 @@ | ||
| <!doctype html> | ||
| <html> | ||
| <body> | ||
| <h1>Test Popup</h1> | ||
| </body> | ||
| </html> |
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
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.