Model Context Protocol Advanced Topics
← Alle Lektionen
Lektion 06Model Context Protocol Advanced Topics

The STDIO transport

Zusammenfassung (Audio)

Keine Audio-Zusammenfassung für diese Lektion.

Studiennotizen

📝 MCP Communication & Transport Notes

🌐 JSON and Messaging

  • Messages: Clients and servers communicate by exchanging JSON objects, referred to as messages.
  • Transports: JSON can be transmitted using various methods (e. g. , HTTP requests, WebSockets, manual methods).
  • Transport Definition: In the MCP specification, the mechanism used to move JSON between a client and a server is called the transport.

🖥️ Standard IO Transport

  • Mechanism: The client launches the server as a separate process.
  • Communication Channels:
  • Input (Client → Server): Client sends messages by writing to the server's standard input (stdin).
  • Output (Server → Client): Server sends messages by writing to the server's standard output (stdout).
  • Key Advantage: Communication can be initiated easily from either side (client or server) at any time.
  • Key Limitation: Standard IO transport only works when the client and server are running on the same physical network.

🔄 MCP Communication Flow (Standard IO)

  • Initialization Sequence (Required by MCP Spec):
  • Client → Server: Must send an initialized request.
  • Server → Client: Must respond with an initialized result.
  • Client → Server: Must send an initialized notification (no response expected).
  • Post-Initialization: Once the three messages are exchanged, the connection is initialized, allowing subsequent requests (e. g. , call tool requests, prompt listing requests).
  • General Communication:
  • Client → Server: Write to stdin → Server processes → Writes response to stdout.
  • Server → Client: Server writes to stdout → Client reads response from stdout.

💡 Comparison: Standard IO vs. Streamable HTTP

  • Standard IO Strength: Allows communication to be initiated by either the client or the server at any point in time.
  • Streamable HTTP Limitation: Unlike Standard IO, there are scenarios where the streamable HTTP transport does not allow the server to send an initial request to the client.
  • Four Scenarios to Handle:
  • Initial request (Client → Server).
  • Response (Server → Client).
  • Initial request (Server → Client).
  • Response (Client → Server).

Takeaways

  • Die Kommunikation zwischen Client und Server erfolgt durch den Austausch von JSON-Objekten, die als Nachrichten definiert sind.
  • Der Standard IO Transport nutzt stdin (Client → Server) und stdout (Server → Client) als Kommunikationskanäle.
  • Die MCP-Spezifikation verlangt eine obligatorische 3-stufiges Initialisierungsprotokoll (Request, Result, Notification).
  • Ein wesentlicher Vorteil von Standard IO ist, dass die Kommunikation von Client oder Server jederzeit initiiert werden kann.
Lernkarten 8 Karten
Frage
zum Aufdecken klicken · ←/→
Antwort
zum Zurückdrehen klicken
Nach Anki exportieren (.tsv) ↓
Wissensüberprüfung 0 Fragen

No quiz for this lesson yet.