| layout | default |
|---|---|
| title | Chapter 4: Transport Model: stdio, Streamable HTTP, and Sessions |
| nav_order | 4 |
| parent | MCP Specification Tutorial |
Welcome to Chapter 4: Transport Model: stdio, Streamable HTTP, and Sessions. In this part of MCP Specification Tutorial: Designing Production-Grade MCP Clients and Servers From the Source of Truth, you will build an intuitive mental model first, then move into concrete implementation details and practical production tradeoffs.
Transport behavior drives most production incidents in MCP systems.
- choose between stdio and Streamable HTTP based on deployment context
- implement session headers and protocol-version headers correctly
- handle SSE polling and resumability without breaking message ordering
- apply required security controls for remote/local HTTP endpoints
| Transport | Best Fit | Core Risks |
|---|---|---|
stdio |
local subprocess servers | stdout contamination, process lifecycle leaks |
| Streamable HTTP | remote/shared servers and multi-client deployments | origin validation, session hijack, reconnection loss |
- validate
Originand reject invalid origin with403 - include and honor
MCP-Session-Idwhen server assigns stateful sessions - include
MCP-Protocol-Versionon follow-up HTTP requests - support both
application/jsonandtext/event-streamresponse paths - plan explicit behavior for resumability/redelivery and session expiration
You now have a transport operations model that is compatible with current session and security requirements.
Next: Chapter 5: Server Primitives: Tools, Resources, and Prompts
The ElicitRequest interface in schema/2025-06-18/schema.ts handles a key part of this chapter's functionality:
* @category `elicitation/create`
*/
export interface ElicitRequest extends Request {
method: "elicitation/create";
params: {
/**
* The message to present to the user.
*/
message: string;
/**
* A restricted subset of JSON Schema.
* Only top-level properties are allowed, without nesting.
*/
requestedSchema: {
type: "object";
properties: {
[key: string]: PrimitiveSchemaDefinition;
};
required?: string[];
};
};
}
/**
* Restricted schema definitions that only allow primitive types
* without nested objects or arrays.
*
* @category `elicitation/create`
*/
export type PrimitiveSchemaDefinition =
| StringSchema
| NumberSchemaThis interface is important because it defines how MCP Specification Tutorial: Designing Production-Grade MCP Clients and Servers From the Source of Truth implements the patterns covered in this chapter.
The StringSchema interface in schema/2025-06-18/schema.ts handles a key part of this chapter's functionality:
*/
export type PrimitiveSchemaDefinition =
| StringSchema
| NumberSchema
| BooleanSchema
| EnumSchema;
/**
* @category `elicitation/create`
*/
export interface StringSchema {
type: "string";
title?: string;
description?: string;
minLength?: number;
maxLength?: number;
format?: "email" | "uri" | "date" | "date-time";
}
/**
* @category `elicitation/create`
*/
export interface NumberSchema {
type: "number" | "integer";
title?: string;
description?: string;
minimum?: number;
maximum?: number;
}
/**
* @category `elicitation/create`This interface is important because it defines how MCP Specification Tutorial: Designing Production-Grade MCP Clients and Servers From the Source of Truth implements the patterns covered in this chapter.
The NumberSchema interface in schema/2025-06-18/schema.ts handles a key part of this chapter's functionality:
export type PrimitiveSchemaDefinition =
| StringSchema
| NumberSchema
| BooleanSchema
| EnumSchema;
/**
* @category `elicitation/create`
*/
export interface StringSchema {
type: "string";
title?: string;
description?: string;
minLength?: number;
maxLength?: number;
format?: "email" | "uri" | "date" | "date-time";
}
/**
* @category `elicitation/create`
*/
export interface NumberSchema {
type: "number" | "integer";
title?: string;
description?: string;
minimum?: number;
maximum?: number;
}
/**
* @category `elicitation/create`
*/This interface is important because it defines how MCP Specification Tutorial: Designing Production-Grade MCP Clients and Servers From the Source of Truth implements the patterns covered in this chapter.
The BooleanSchema interface in schema/2025-06-18/schema.ts handles a key part of this chapter's functionality:
| StringSchema
| NumberSchema
| BooleanSchema
| EnumSchema;
/**
* @category `elicitation/create`
*/
export interface StringSchema {
type: "string";
title?: string;
description?: string;
minLength?: number;
maxLength?: number;
format?: "email" | "uri" | "date" | "date-time";
}
/**
* @category `elicitation/create`
*/
export interface NumberSchema {
type: "number" | "integer";
title?: string;
description?: string;
minimum?: number;
maximum?: number;
}
/**
* @category `elicitation/create`
*/
export interface BooleanSchema {This interface is important because it defines how MCP Specification Tutorial: Designing Production-Grade MCP Clients and Servers From the Source of Truth implements the patterns covered in this chapter.
flowchart TD
A[ElicitRequest]
B[StringSchema]
C[NumberSchema]
D[BooleanSchema]
E[EnumSchema]
A --> B
B --> C
C --> D
D --> E