-
Notifications
You must be signed in to change notification settings - Fork 1.4k
MCP Server and Vertex AI #2647
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
Comments
I have been facing the very same issue. I'm also using Vertex AI and MCP client inside Spring AI. The response from MCP server that MCP client inside Spring AI receives seems to be correct. However, when this response is then prepared to be sent to Vertex AI, (VertexAiGeminiChatModel#jsonToStruct(String json)), only a part of the response from the MCP server is actually used. This part of the JSON response is the value of the "content" field. This value is a JSON array. A JSON array doesn't work well with VertexAiGeminiChatModel#jsonToStruct(String json) :-).
I think, the source of this issue is:
The response looks more or less like this: As @sidutti wrote:
OR |
hi Team, I am also facing similar issue and using gemini 2.5 pro model. Any solutions for this bug in progress?
Also, similar bug is reported - #2849 |
@sidutti , thank you for reporting this issue. |
Improve the jsonToStruct method in VertexAiGeminiChatModel to handle JSON arrays in addition to JSON objects. When a JSON array is detected, it's now properly converted to a Protobuf Struct with an items field containing the array elements. Resolves spring-projects#2647 , spring-projects#2849 Signed-off-by: Christian Tzolov <[email protected]>
please try the snapshots and reopen if it doesn't solve your issue. |
It's working. Thanks a lot. |
Bug description
The MCP Server responds the results wrapped as List.
McpSchema.CallToolResult(List.of(new McpSchema.TextContent(callResult)), false);
When using the Vertex AI, the response is marshaled as a Struct (protobuf) which expects a MAP.
In the class
VertexAiGeminiChatModel
, methodmessageToGeminiParts
when the message isToolResponseMessage
the response string is still being tried to be de-serialized as map. This throws an exception.Environment
Spring AI Version: 1.0.0-SNAPSHOT
Java : 21
Steps to reproduce
MCP Server : Any ASYNC MCP Server
MCP Client with Vertex AI Chat Model
Expected behavior
The message when is a tool response and if it is an Array, should be mapped and the internal Map should be passed back to VertexAI
The text was updated successfully, but these errors were encountered: