mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-09 07:28:05 -05:00
fix(server/stdio): notifications should not return a response (#638)
Currently the `stdio` transport protocol will throw a `ZodError` during initialization. This is due to Toolbox writing `null` to stdout when it received a notification. This is not expected hence the `ZodError` occurs. Per the MCP protocol, notifications do not expect any response. This fix added a condition to check if the responses is `nil` before writing to stdout.
This commit is contained in:
@@ -106,8 +106,12 @@ func (s *stdioSession) readInputStream(ctx context.Context) error {
|
||||
// server can continue to run.
|
||||
s.server.logger.ErrorContext(ctx, err.Error())
|
||||
}
|
||||
if err = s.write(ctx, res); err != nil {
|
||||
return err
|
||||
|
||||
// no responses for notifications
|
||||
if res != nil {
|
||||
if err = s.write(ctx, res); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user