feat(ui): adapt Web UI to native MCP endpoints#2725
feat(ui): adapt Web UI to native MCP endpoints#2725anubhav756 wants to merge 1 commit intoanubhav-complexfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the Web UI's interaction with the backend tool services. It transitions the entire tool management and execution flow to a standardized JSON-RPC protocol via the Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Link Resolution NoteLocal links and directory changes work differently on GitHub than on the docsite. You must ensure fixes pass the GitHub check and also work with Summary
Errors per inputErrors in DEVELOPER.md
|
There was a problem hiding this comment.
Code Review
This pull request adapts the Web UI to use the native MCP endpoints, which is a great step forward. I've identified an opportunity to improve code clarity by removing an unused parameter, and a bug in how tool results are processed that could lead to data loss in the UI. My detailed comments and suggestions are below.
| try { | ||
| const resultJson = JSON.parse(results.result); | ||
| let content = results; | ||
| if (results.content && results.content.length > 0 && results.content[0].text) { | ||
| content = results.content[0].text; | ||
| } | ||
|
|
||
| const resultJson = JSON.parse(content); | ||
| if (prettify) { | ||
| responseArea.value = JSON.stringify(resultJson, null, 2); | ||
| } else { | ||
| responseArea.value = JSON.stringify(resultJson); | ||
| } | ||
| } catch (error) { | ||
| console.error("Error parsing or stringifying results:", error); | ||
| if (typeof results.result === 'string') { | ||
| responseArea.value = results.result; | ||
| if (results.content && results.content.length > 0 && results.content[0].text) { | ||
| responseArea.value = results.content[0].text; | ||
| } else if (typeof results === 'string') { | ||
| responseArea.value = results; | ||
| } else { | ||
| responseArea.value = "Error displaying results. Invalid format."; | ||
| responseArea.value = JSON.stringify(results, null, 2); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
The current implementation only handles the first element of the results.content array. If a tool returns multiple content parts, the others will be ignored. This is a bug.
The logic should be updated to handle all content parts. If there are multiple, they can be displayed as an array. If parsing fails, all raw text parts should be shown.
try {
let resultJson;
if (results.content && Array.isArray(results.content) && results.content.length > 0) {
const parsedContent = results.content.map(item => {
try {
return JSON.parse(item.text);
} catch {
return item.text;
}
});
resultJson = parsedContent.length === 1 ? parsedContent[0] : parsedContent;
} else {
resultJson = results;
}
if (prettify) {
responseArea.value = JSON.stringify(resultJson, null, 2);
} else {
responseArea.value = JSON.stringify(resultJson);
}
} catch (error) {
console.error("Error parsing or stringifying results:", error);
if (results.content && Array.isArray(results.content) && results.content.length > 0) {
responseArea.value = results.content.map(c => c.text).join('\n');
} else if (typeof results === 'string') {
responseArea.value = results;
} else {
responseArea.value = JSON.stringify(results, null, 2);
}
}| @@ -27,12 +27,31 @@ let toolDetailsAbortController = null; | |||
| export async function loadTools(secondNavContent, toolDisplayArea, toolsetName) { | |||
0a21418 to
5192711
Compare
72170c7 to
180b924
Compare
5192711 to
74d2529
Compare
180b924 to
79789b1
Compare
74d2529 to
b98e5da
Compare
79789b1 to
c744015
Compare
b98e5da to
ecba0c2
Compare
c744015 to
609e550
Compare
Overview
This PR adapts the frontend MCP Toolbox UI directly against the dynamically populated MCP specifications.
Changes
runTool.js,loadTools.js).Note
This PR is Part 4 of 5 to migrate legacy endpoints to standard MCP endpoints.
(Base PR: #2713)