MCP client

Also known as: Model Context Protocol client

On this page 7

An MCP client is the component inside an AI application that maintains a dedicated connection to one MCP server under the Model Context Protocol, negotiating capabilities and exchanging JSON-RPC messages on behalf of the application. In the field of AI agents within artificial intelligence, the Model Context Protocol client is the piece that lets a language model discover and call external tools, read resources and use prompt templates that a server exposes, without custom integration code for each service.

The client never stands alone. It lives inside a host application, such as a desktop assistant, an IDE or an agent framework, and the host typically runs one client per connected server. The client handles protocol mechanics, while the host decides what the model sees and what the user must approve.

How an MCP client fits the host and server model

The Model Context Protocol defines three roles: host, client and server. The host is the user-facing application that owns the model and the conversation. Each MCP client is a stateful session object created by the host, and each MCP server is a separate program or service that offers capabilities such as database queries, file access or issue tracking.

The relationship between client and server is strictly one to one. A host that connects to a file system server, a Git server and a ticketing server therefore runs three clients, which keeps security boundaries and failures isolated: one server cannot read another server’s messages through the shared client.

The following table separates the responsibilities of the three roles.

RoleMain responsibilityTypical example
HostRuns the model, manages consent and aggregates contextDesktop assistant or coding IDE
MCP clientHolds one session with one server and routes messagesConnection object inside the host
MCP serverExposes tools, resources and promptsLocal file server or remote SaaS connector
Roles in the Model Context Protocol architecture

The MCP client session lifecycle

Every MCP client session follows a defined lifecycle of initialization, operation and shutdown. Messages use JSON-RPC 2.0, with requests that expect responses and notifications that do not.

During initialization the client sends an initialize request containing its protocol version, its capabilities and client information. The server answers with its own version and capabilities, and the client confirms with an initialized notification. Capability negotiation at this stage decides which features both sides may use for the rest of the session.

PhaseClient actionPurpose
InitializationSends initialize, then initializedAgree on version and capabilities
DiscoveryCalls tools/list, resources/list, prompts/listLearn what the server offers
OperationSends tools/call or resources/read requestsExecute actions and fetch context
Change handlingProcesses list-changed notificationsRefresh tools or resources that changed
ShutdownCloses the transportEnd the session cleanly
Phases of a client session

The client also handles transport selection. Local servers usually run as subprocesses over standard input and output (stdio), while remote servers use Streamable HTTP, which replaced the earlier HTTP with server-sent events transport. For remote servers the specification relies on OAuth 2.1-based authorization, with the client obtaining and presenting access tokens.

Capabilities an MCP client consumes and offers

An MCP client both consumes server primitives and offers client features back to the server. The server side provides tools, resources and prompts; the client side can provide sampling, roots and elicitation when it declares them during initialization.

PrimitiveDirectionWho controls itWhat it does
ToolsServer to clientModel, with host approvalExecutable functions with JSON Schema inputs
ResourcesServer to clientApplicationReadable data such as files or records
PromptsServer to clientUserReusable prompt templates with arguments
SamplingClient to serverHost and userLets a server request a model completion
RootsClient to serverHostTells a server which directories or URIs are in scope
ElicitationClient to serverUserLets a server ask the user for structured input
Primitives on each side of the connection

Sampling is significant because it allows a server to use a model without holding its own API keys, while the host keeps control over which model runs and whether the user reviews the request.

An MCP client is a protocol endpoint, not an agent. It does not plan, reason or choose tools; the model and the host do that. Confusing the client with the agent loop or with the tool calling feature of a model API is a frequent misunderstanding.

ConceptWhat it isRelation to the MCP client
Tool callingModel API feature for emitting structured callsThe host maps those calls to client tools/call requests
MCP serverProvider of capabilitiesThe single peer of each client
Agent loopCycle of reasoning, acting and observingUses clients to act on external systems
Agent frameworkLibrary for building agentsOften embeds an MCP client implementation
Agent2Agent protocolProtocol for agents talking to agentsAddresses peer agents, not tool servers
How the MCP client differs from neighboring concepts

Security responsibilities and common mistakes

Because a client connects a model to real systems, security largely rests on the host and its clients. The specification expects explicit user consent for tool invocations and data access, and it treats tool descriptions from servers as untrusted unless the server itself is trusted.

  • Auto-approving every tool call removes the human check that guards against destructive or data-leaking actions.
  • Trusting tool descriptions blindly exposes the model to prompt injection hidden in server metadata.
  • Connecting too many servers floods the context window with tool definitions and degrades tool selection.
  • Ignoring list-changed notifications leaves the model calling tools that no longer exist or have changed schemas.
  • Storing OAuth tokens insecurely turns a client compromise into access to every connected service.

Well-built hosts show which server provides each tool, scope roots narrowly and keep a log of calls, which also supports agent observability and later review.

In everyday language

Think of an AI assistant as a person who needs to use many different services, such as a calendar, a file cabinet and a ticket system. An MCP client is like a dedicated phone line to one of those services. The assistant has one line per service, and each line follows the same calling rules.

Because every line speaks the same language, a new service can be plugged in without rebuilding the assistant. The phone line does not decide what to say; the assistant does. The line simply carries requests and answers reliably and keeps each conversation separate.

Seen in the real world

A developer works in a coding editor that acts as an MCP host. The editor connects to three servers: a local file system server over stdio, a Git server over stdio and a remote issue tracker over Streamable HTTP. The editor creates three MCP clients, one for each server, and each performs its own initialization and tool discovery.

The developer asks the assistant to fix the bug described in a specific ticket. The model requests the ticket, so the host routes a tools/call through the issue tracker client, which presents an OAuth access token obtained earlier. The model then reads the affected source files through the file system client and proposes a change.

Before the Git client creates a branch and commits, the host shows an approval prompt naming the tool and its server. The developer approves, and the whole task completes without any custom integration code between the editor and the three services.