演習 › 全問
問題 Q8-06
101 / 106分野8・MCPサーバーの開発
まだ解いていません。
stdioで動くMCPサーバーを作ったら、クライアントとの通信がときどき壊れる。コードでは、デバッグ用に print() で状況を出力している。最も考えられる原因はどれか。
正解は B
- A通信が壊れる原因ではありません。
- B正解です。stdioのサーバーでは標準出力がメッセージの通り道なので、ログを書くと壊れます。ログは別の出力に書きます。
- C誤りです。stdioは標準の通信方式の1つです。
- D通信が壊れる原因ではありません。
考え方:stdioのサーバーは標準出力にログを書かない。
出典:Build an MCP server
Never write to stdout. Writing to stdout will corrupt the JSON-RPC messages and break your server.https://modelcontextprotocol.io/docs/2026-07-28/develop/build-server.m…(取得 2026-11-17)