Model Context Protocol Advanced Topics
← All lessons
Lesson 05Model Context Protocol Advanced Topics

JSON message types

Summary audio

Spoken summary — press play to read along: the line being spoken stays near the top.

Study notes

📚 MCP Messaging and Transport Fundamentals

🌐 Core Communication Concepts

  • Format: All communication between clients and servers uses JSON messages.
  • Purpose: Understanding MCP messages and standard IO transport is crucial for grasping the limitations of MCP servers when using the streamable HTTP transport.
  • Message Flow Example:
  • Client $\rightarrow$ Server: Sends a call tool request.
  • Server $\rightarrow$ Client: Sends a call tool result (containing the outcome).

🛠️ Technical Specification Details

  • Source of Truth: The full list of message types is defined in the MCP spec repository (on GitHub).
  • Implementation: The types are defined in a TypeScript file (schema. ts).
  • Note: This TypeScript file is for type description only and is not executed by the system.
  • Structure:
  • Requests: Must include a method (e. g. , tool/call) and a params object.
  • JSON-RPC: Requires a unique ID field.

🏷️ Message Type Categorization

Message types fall into distinct categories based on their function and direction:

  • Request/Result Pairs:
  • These types always come in pairs (e. g. , X request $\leftrightarrow$ X result).
  • They describe an action sent and the expected response/outcome.
  • Notification Messages:
  • These act like events (e. g. , progress notification, logging message notification).
  • They inform the recipient of an occurrence but do not require a response.

🔄 Directionality (Client vs. Server)

Message types are categorized by the entity sending them:

| Message Type | Sender | Receiver | Description | | :--- | :--- | :--- | :--- | | Client Request | Client | Server | Action initiated by the client. | | Server Request | Server | Client | Action initiated by the server. | | Client Notification | Client | Server | Event reported by the client. | | Server Notification | Server | Client | Event reported by the server. |

🔑 Key Takeaway for Streamable HTTP Transport:

  • The Server Request and Server Notification types are critical because they represent messages that are sent from the server over to the client.

Takeaways

📚 MCP Messaging and Transport Fundamentals

🌐 Core Communication Standards

  • Format: All client-server communication must use JSON messages.
  • Source of Truth: The definitive list of message types is maintained in the MCP spec repository (GitHub).
  • Purpose: Understanding these message types is essential for grasping the limitations of MCP servers, particularly when using streamable HTTP transport.

🛠️ Message Structure Requirements

  • Requests: Must contain a method (e. g. , tool/call) and a params object.
  • JSON-RPC: Requires a unique ID field for tracking request/result pairs.

🏷️ Message Type Categorization

Message types are categorized by their function and required response:

  • Request/Result Pairs: These types describe an action and always come in pairs (e. g. , X request $\leftrightarrow$ X result).
  • Notification Messages: These are one-way event reports (e. g. , progress updates) that inform the recipient but do not require a response.

🔄 Directionality and Flow

Messages are defined by both the sender and the message intent:

  • Client $\rightarrow$ Server: Initiates actions (Client Requests) or reports events (Client Notifications).
  • Server $\rightarrow$ Client: Represents actions or events sent from the server (Server Requests/Notifications).
  • Key Focus (Streamable HTTP): The Server Request and Server Notification types are critical as they define the flow of data from the server back to the client.
Flashcards 7 cards
Question
click to reveal · ←/→
Answer
click to flip back
Export to Anki (.tsv) ↓
Knowledge check 6 questions