-
Notifications
You must be signed in to change notification settings - Fork 14.5k
feat(mcp): add progress bar, throttling, and input validation for MCP tool progress #19772
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
jacob314
merged 3 commits into
google-gemini:main
from
jasmeetsb:feature/mcp-progress-enhancements
Feb 24, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
72 changes: 72 additions & 0 deletions
72
packages/cli/src/ui/components/messages/ToolShared.test.tsx
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,72 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Google LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { describe, it, expect, vi } from 'vitest'; | ||
| import { render } from '../../../test-utils/render.js'; | ||
| import { Text } from 'ink'; | ||
| import { McpProgressIndicator } from './ToolShared.js'; | ||
|
|
||
| vi.mock('../GeminiRespondingSpinner.js', () => ({ | ||
| GeminiRespondingSpinner: () => <Text>MockSpinner</Text>, | ||
| })); | ||
|
|
||
| describe('McpProgressIndicator', () => { | ||
| it('renders determinate progress at 50%', async () => { | ||
| const { lastFrame, waitUntilReady } = render( | ||
| <McpProgressIndicator progress={50} total={100} barWidth={20} />, | ||
| ); | ||
| await waitUntilReady(); | ||
| const output = lastFrame(); | ||
| expect(output).toMatchSnapshot(); | ||
| expect(output).toContain('50%'); | ||
| }); | ||
|
|
||
| it('renders complete progress at 100%', async () => { | ||
| const { lastFrame, waitUntilReady } = render( | ||
| <McpProgressIndicator progress={100} total={100} barWidth={20} />, | ||
| ); | ||
| await waitUntilReady(); | ||
| const output = lastFrame(); | ||
| expect(output).toMatchSnapshot(); | ||
| expect(output).toContain('100%'); | ||
| }); | ||
|
|
||
| it('renders indeterminate progress with raw count', async () => { | ||
| const { lastFrame, waitUntilReady } = render( | ||
| <McpProgressIndicator progress={7} barWidth={20} />, | ||
| ); | ||
| await waitUntilReady(); | ||
| const output = lastFrame(); | ||
| expect(output).toMatchSnapshot(); | ||
| expect(output).toContain('7'); | ||
| expect(output).not.toContain('%'); | ||
| }); | ||
|
|
||
| it('renders progress with a message', async () => { | ||
| const { lastFrame, waitUntilReady } = render( | ||
| <McpProgressIndicator | ||
| progress={30} | ||
| total={100} | ||
| message="Downloading..." | ||
| barWidth={20} | ||
| />, | ||
| ); | ||
| await waitUntilReady(); | ||
| const output = lastFrame(); | ||
| expect(output).toMatchSnapshot(); | ||
| expect(output).toContain('Downloading...'); | ||
| }); | ||
|
|
||
| it('clamps progress exceeding total to 100%', async () => { | ||
| const { lastFrame, waitUntilReady } = render( | ||
| <McpProgressIndicator progress={150} total={100} barWidth={20} />, | ||
| ); | ||
| await waitUntilReady(); | ||
| const output = lastFrame(); | ||
| expect(output).toContain('100%'); | ||
| expect(output).not.toContain('150%'); | ||
| }); | ||
| }); |
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
22 changes: 22 additions & 0 deletions
22
packages/cli/src/ui/components/messages/__snapshots__/ToolShared.test.tsx.snap
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,22 @@ | ||
| // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
|
||
| exports[`McpProgressIndicator > renders complete progress at 100% 1`] = ` | ||
| "████████████████████ 100% | ||
| " | ||
| `; | ||
|
|
||
| exports[`McpProgressIndicator > renders determinate progress at 50% 1`] = ` | ||
| "██████████░░░░░░░░░░ 50% | ||
| " | ||
| `; | ||
|
|
||
| exports[`McpProgressIndicator > renders indeterminate progress with raw count 1`] = ` | ||
| "███████░░░░░░░░░░░░░ 7 | ||
| " | ||
| `; | ||
|
|
||
| exports[`McpProgressIndicator > renders progress with a message 1`] = ` | ||
| "██████░░░░░░░░░░░░░░ 30% | ||
| Downloading... | ||
| " | ||
| `; |
Oops, something went wrong.
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.
The snapshot test here is good, but it might be beneficial to explicitly assert the presence of the progress bar characters (e.g.,
\u2588and\u2591) to ensure the visual representation is as expected, rather than just relying on the percentage and message. This would make the test more robust against accidental changes to the progress bar's rendering.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.
Good suggestion. Added explicit \u2588 and \u2591 character assertions to all three progress bar test cases.