- Model: the AI (usually large language models or LLMs).
- Context: external or third‑party data and application state that you supply to the model so it can produce more relevant, contextualized responses.
- Protocol: the rules and message formats that govern how clients and servers talk to each other.

- Communication format: MCP standardizes client ↔ server messages using JSON-RPC. That enforces a consistent request/response shape, error handling, and method dispatching.
- Stateful connection: MCP assumes sessions are stateful. Clients and servers keep shared session state (roots, resources, ongoing contexts) rather than treating every request as isolated.
- Server responsibilities: MCP servers expose structured data, reusable prompts, and callable tools to clients.
- Resources: structured contextual data (documents, embeddings, or connectors to external data sources) that the server supplies to models or clients.
- Prompts: managed templates or prompt compositions the server can provide or reuse for consistent elicitation.
- Tools: integrations and callable actions (search, code execution, API invocations) available to the model or client during generation.
- Client responsibilities: MCP clients orchestrate model sampling, manage roots (conversation or context threads), and coordinate elicitation workflows.
- Sampling: invoking the model to produce text given a prompt and context, with configurable generation parameters.
- Roots: persisting root contexts or conversation threads that group related messages and state.
- Elicitation: composing prompts, selecting resources, and calling tools to derive targeted answers from the model.
Typical MCP session flow (simplified)
- Connection establishment
- Client opens a stateful JSON-RPC session to the MCP server.
- Server and client negotiate any required session metadata (capabilities, auth).
- Resource discovery
- Client queries available resources, prompt templates, and tools.
- Server returns metadata describing each resource/tool (types, access patterns).
- Root creation
- Client creates a root context (conversation thread) to group related interactions and state.
- Elicitation orchestration
- Client combines prompts, selected resources, and tool calls into an elicitation plan.
- Client requests sampling from the model via JSON-RPC methods, passing generation parameters and context.
- Tool invocation (optional)
- During elicitation, the model or client may invoke server-side tools (search, APIs, code runners).
- Tools return results back into the session context for reuse.
- Result delivery and state update
- Server returns model outputs (and any tool outputs) to the client.
- Session state (roots, resources, logs) is updated so future interactions can build on prior context.
- Session lifecycle
- Clients may continue to sample, update resources, or close the session per lifecycle rules in the spec.
- Keep prompts and resources modular: servers that expose composable prompt templates and typed resources make clients simpler to implement.
- Treat the connection as stateful: rely on roots and resources to persist context rather than repeatedly resending large payloads.
- Use JSON-RPC strictly: following the spec’s method names, parameters, and error codes ensures cross-implementation compatibility.
If you plan to implement or integrate with MCP, read the full Model Context Protocol specification. It contains detailed JSON-RPC method definitions, required lifecycle behaviors for stateful sessions, and authentication/capability guidance.
- Model Context Protocol — Specification: https://modelcontextprotocol.io/introduction
- For related patterns and best practices, search for “stateful LLM orchestration”, “prompt templates”, and “LLM tool integration”.