MCP: Model Context ProtocolBeginnerModule 02 — MCP architecture and components

What is an MCP host, and what responsibilities does it have?

Question 13 of 43 · Updated

On this page

Direct answer#

An MCP host is the application that manages the user's interaction with external capabilities through the Model Context Protocol. It creates and manages MCP clients, decides which servers to connect to, integrates discovered capabilities into the application, controls what information is shared with a model or other destination, and coordinates user consent, policy and task execution.

A host may be an IDE assistant, desktop assistant, web-based support application, command-line application or automated workflow. It may use a large language model, but it does not need one for ordinary protocol operations. The host is not the same as the MCP client: a client manages protocol communication with a particular server, while the host manages the broader application experience and the collection of client connections.

The host is also not the same as the MCP server. The server exposes capabilities and implements their behavior, often through existing business systems. The host decides how those capabilities participate in the user's task; the server and downstream services independently enforce authorization and business invariants.

Learning continuity: This lesson opens Module 02 — MCP architecture and components. Module 01 established why MCP exists, when to adopt it and what it does not solve. Here we define the host as an architectural component. The next lessons focus separately on the client and server, followed by deeper treatment of client isolation (Q21) and consent, context and execution boundaries (Q22).

Verification scope: Prepared under the authorized offline research and changelog exceptions. The historical MCP 2025-06-18 specification is the reference baseline, not a claim about the latest revision. Official references were not live-verified. The included standard-library Python program was syntax-compiled and executed using Python 3.13.5; all 12 checks passed. The example uses fake clients, not real MCP sessions, and makes no network or model calls. Two Mermaid diagrams use standard fenced syntax and were structurally reviewed; a local Mermaid parser and live website rendering were not verified.

1. Understand the host through a practical example#

Consider a retailer's customer support assistant. A user asks whether product A12 is available and whether it can be returned.

The support application needs to understand the task, look up relevant information and present an answer. It may use an inventory MCP server to access current stock and a policy MCP server to read the applicable return policy.

The host is the support application itself, not the language model embedded within it. It owns the session with the user and the decisions about which configured services can be used for that user. It may delegate the actual message exchange to client objects or SDK components.

If the inventory lookup fails, the host can still answer the policy part of the question while clearly reporting that inventory is unavailable. If the user requests a purchase, the host must not assume that an earlier read-only lookup grants permission to perform a write.

Loading diagram…

This is a logical architecture diagram, not a network topology or a mandatory implementation structure. A host can implement these responsibilities in a single process or distribute them across trusted application services. In the historical session-oriented architecture, each client maintains a dedicated connection to one server; a host can create multiple clients. One server may serve multiple compatible clients, subject to its deployment and authorization model.

2. Distinguish the host, client, server and model#

ComponentPrimary responsibilityExample
HostCoordinates the application, policies, clients and user experienceCustomer support application
MCP clientHandles protocol communication with a particular serverInventory session/client object
MCP serverExposes and executes supported capabilitiesInventory MCP server
Downstream serviceOwns domain data and business rulesInventory API and database
Language modelInterprets language and may propose or summarize operationsModel used by the support host

These are logical roles, not necessarily separate executables. An SDK may provide a client object, while a framework provides a host's agent loop. The framework alone is not automatically the entire host; identity, UI, policy and application state may be implemented by the surrounding application.

The word host in MCP should not be confused with a web hosting provider, a DNS hostname or the machine running the server. In this context, host refers to the application responsible for integrating MCP into its workflow.

A model-generated tool call is a proposal. The host may translate it into a protocol request, subject to trusted routing and validation. The model does not become the MCP client merely by producing a tool name and arguments.

3. Responsibility one: manage client connections#

A host decides which server integrations are configured and allowed, creates the appropriate clients, and manages their lifetime. It may connect to a server on startup, on demand or within a bounded task scope.

A typical host-level lifecycle is:

  1. Resolve the server identity and configuration from a trusted registry.
  2. Establish the appropriate transport through a compatible client.
  3. Let the client perform initialization and negotiate supported features according to the applicable revision.
  4. Discover relevant capabilities and associate them with the originating connection.
  5. Allow approved operations during the task or session.
  6. Handle connection failure, configuration changes and shutdown; clean up connections and associated metadata.

The host owns the decision to open, reuse or close a client. The client owns the details of the protocol exchange. For example, the host should decide whether it is acceptable to reconnect to an unavailable read-only inventory server, while the client handles the supported connection mechanics.

Do not assume the protocol provides permanent sessions or that reconnection preserves arbitrary business state. The host must follow the revision and SDK actually in use. Long-running operations may have distinct business lifecycles, and closing a connection does not necessarily roll back a completed write.

For local stdio integrations, host configuration may specify an approved executable and arguments, while an SDK manages the subprocess streams. For remote services, the host configures the intended endpoint and appropriate credentials. Detailed transport and lifecycle mechanics are covered later.

4. Responsibility two: discover and present relevant capabilities#

A server may expose tools, resources and prompts depending on its supported features. The host uses its clients to obtain the relevant information and decide how to present it.

CapabilityTypical host behavior
ToolsSelect approved operations and make suitable descriptions available to a model or deterministic workflow
ResourcesRetrieve or present relevant URI-identified information
PromptsPresent reusable message templates for supported user workflows

In the historical specification, these are often described respectively as model-controlled, application-controlled and user-controlled interaction patterns. These descriptions are useful design guidance, not permissions or rigid rules that prevent a host from invoking a tool deterministically.

A host should not indiscriminately merge everything discovered from every server. It needs trusted server identity, permitted operations, relevant capability metadata and a way to route an invocation to the correct client. Two servers can advertise the same tool name without exposing the same operation. A host must preserve the association between server, operation and applicable identity.

Tool descriptions and annotations are supplied by the server and should not independently grant authority. The host reviews them against its own configuration and policy. Discovery does not mean authorization to execute.

The host may present a smaller subset of discovered tools to reduce model context overhead. It can refresh capability information when a supported notification indicates changes, or according to an appropriate invalidation strategy. It must not continue to expose a disabled or disconnected capability as if it were available.

Later lessons develop collision-resistant aliases, capability discovery caching and client isolation in detail.

5. Responsibility three: integrate models and orchestration#

A host may integrate a model through an inference API or a local runtime. In a model-driven workflow, it translates approved capability descriptions into the model provider's supported format, receives proposed calls and validates them before routing them through an MCP client.

In a deterministic workflow, ordinary code can select the operation and construct the arguments directly. Both approaches use the same general capability interface.

The host coordinates the task: it chooses the order of operations, handles failures, imposes call budgets, applies stopping conditions and decides when enough evidence has been collected. MCP does not define an entire agent loop.

Loading diagram…

The sequence is conceptual: the client's initialization, authentication and detailed MCP messages are omitted. A non-model-driven host can replace both LLM interactions with deterministic application logic. A server may independently enforce further authorization or request supported user input.

The host must inspect the actual business result rather than reporting a successful operation just because the model says it occurred. It should distinguish protocol failures, tool errors and valid business outcomes.

6. Responsibility four: manage external context#

A host decides what information should be supplied to a model, retained in application state or used by deterministic code.

For the retailer, it may include only the SKU, stock count, observation time and applicable policy excerpt. It should not send all warehouse records, access tokens or unrelated customer information to a model provider simply because a server returned them.

Host-side context management generally includes:

  • Selecting information relevant to the current task.
  • Preserving provenance, result status and freshness information.
  • Checking disclosure permissions for the intended destination.
  • Adapting data to the supported model input representation.
  • Enforcing appropriate context and output budgets.
  • Treating external text as untrusted data rather than privileged instructions.

MCP itself does not provide a universal context window or persistent model memory. The host may use separate retrieval, ranking, memory or summarization components. As explained in Q10, external information is not automatically placed in model context.

In deployments supporting sampling, the host may also mediate a server's request for model generation, subject to negotiated client capabilities and policy. It should control model access and disclosure; it should not expose its entire conversation history by default. Detailed sampling behavior is reserved for the sampling module.

The host is an important application-level enforcement point. It decides which server configurations can be used, which capabilities are available to the current task and which actions require trusted user confirmation.

A practical host keeps credentials outside model-visible prompts and arguments. It derives user identity and policy from trusted application context, not from the model's assertion that it represents a particular user or tenant. It prevents arbitrary server destinations, unauthorized operations and inappropriate sharing of information across integrations.

For sensitive actions, an approval interaction should describe the intended operation, relevant parameters and consequences. A declined or expired approval must not be interpreted as permission to proceed. For high-risk actions, approval needs to be bound to the exact operation, authenticated identity, relevant resource and validity period, with replay protection where appropriate.

The host is not the only security boundary. The server and downstream resource-owning service must independently check the actor's authority and business invariants. Even if a host's tool filter fails, the server should not allow unauthorized access. OAuth-based authorization in applicable HTTP deployments helps establish a standardized authorization mechanism; it does not define every business permission.

A useful distinction:

DecisionAppropriate enforcement
Which server may be connectedHost configuration and trust policy
Which tool may be offered to this taskHost capability policy
Whether user confirmation is neededHost interaction and execution policy
Whether the credential is valid for the resourceServer authorization boundary
Whether this actor may access the actual recordServer and downstream service
Whether the operation satisfies business constraintsAuthoritative business service

These are layered responsibilities. A specific deployment may distribute the checks differently, but it should not rely on the model as its sole authority.

8. Practical implementation: a small host coordinator#

The following Python example models several host responsibilities without using an MCP SDK. FakeClient stands in for an already trusted client interface. The Host manages connection lifetimes, discovers approved operations, preserves server-specific routes, requests confirmation when configured, validates arguments and results, and enforces a small invocation budget.

The two stock tools are deliberately named identically but belong to different servers. The application uses a pair of server identity and tool name rather than relying on a bare tool name.

This example is intentionally synchronous and single-use per Host instance. The supplied configurations and approved Tool records are assumed to be trusted, internally consistent and scoped to the current actor. The confirmation callback is a test stand-in for an application-controlled approval interaction, not an LLM-controlled flag. No real authorization, credential handling, transport negotiation, SDK operations or network security are implemented.

Save as mcp_q16.py:

PYTHON
from contextlib import ExitStack from dataclasses import dataclass import json @dataclass(frozen=True) class Tool: server: str name: str approval_required: bool = False class FakeClient: def __init__(self, tools, fail=False): self.tools = tools self.fail = fail self.open = False self.calls = [] def __enter__(self): if self.fail: raise ConnectionError('Server unavailable') self.open = True return self def __exit__(self, *exc): self.open = False def discover(self): if not self.open: raise RuntimeError('Closed client') return self.tools def call(self, name, args): if not self.open: raise RuntimeError('Closed client') self.calls.append((name, args.copy())) return {'sku': args['sku'], 'available_units': 7} class Host: def __init__(self, clients, approved, max_calls=2): self.config = clients.copy() self.approved = approved.copy() self.max_calls = max_calls self.stack = ExitStack() self.clients = {} self.routes = {} self.calls = 0 def __enter__(self): try: for server, client in self.config.items(): self.clients[server] = self.stack.enter_context(client) for name in client.discover(): key = (server, name) if key in self.approved: self.routes[key] = self.approved[key] return self except BaseException: self.__exit__(None, None, None) raise def __exit__(self, *exc): self.routes.clear() self.clients.clear() return self.stack.__exit__(*exc) def invoke(self, key, args, confirm): tool = self.routes.get(key) if tool is None or self.calls >= self.max_calls: raise PermissionError('Unavailable tool or call budget exceeded') if (not isinstance(args, dict) or set(args) != {'sku'} or type(args['sku']) is not str or not 1 <= len(args['sku']) <= 16): raise ValueError('Invalid arguments') payload = args.copy() if tool.approval_required and not confirm(tool, payload.copy()): raise PermissionError('Approval declined') self.calls += 1 result = self.clients[tool.server].call(tool.name, payload) if (not isinstance(result, dict) or result.get('sku') != payload['sku'] or type(result.get('available_units')) is not int or result['available_units'] < 0): raise ValueError('Invalid result') return json.dumps({'source': tool.server, 'sku': result['sku'], 'available_units': result['available_units']}) def reject(fn, error): try: fn() except error: return raise AssertionError('Expected rejection') if __name__ == '__main__': a = FakeClient(['stock', 'unapproved']) b = FakeClient(['stock']) keys = {('inventory', 'stock'): Tool('inventory', 'stock'), ('partner', 'stock'): Tool('partner', 'stock', True)} yes = lambda tool, args: True no = lambda tool, args: False with Host({'inventory': a, 'partner': b}, keys) as host: assert set(host.routes) == set(keys) assert json.loads(host.invoke(('inventory', 'stock'), {'sku': 'A12'}, yes))['source'] == 'inventory' reject(lambda: host.invoke(('inventory', 'unapproved'), {'sku': 'A12'}, yes), PermissionError) reject(lambda: host.invoke(('partner', 'stock'), {'sku': 'A12'}, no), PermissionError) assert not b.calls reject(lambda: host.invoke(('partner', 'stock'), {'sku': True}, yes), ValueError) assert json.loads(host.invoke(('partner', 'stock'), {'sku': 'A12'}, yes))['source'] == 'partner' reject(lambda: host.invoke(('inventory', 'stock'), {'sku': 'A12'}, yes), PermissionError) assert not a.open and not b.open reject(lambda: host.invoke(('inventory', 'stock'), {'sku': 'A12'}, yes), PermissionError) reject(lambda: Host({'inventory': a, 'bad': FakeClient([], True)}, keys).__enter__(), ConnectionError) assert not a.open print('12 host coordination checks passed')

Run with Python 3.10 or later:

BASH
python -m py_compile mcp_q16.py python mcp_q16.py

Actual output on Python 3.13.5:

12 host coordination checks passed

The tests verify filtering of an unapproved operation, routing of two same-named tools to different clients, approval refusal and absence of a resulting call, invalid input rejection, execution budget exhaustion, closure of both clients, denial after closure and cleanup of the first connection when the second fails to open. The stored Python block is matched against the locally executed code using its MD5 checksum.

The ExitStack is a Python standard-library mechanism for managing multiple context managers. It ensures that successfully entered contexts are closed even if a later setup step fails. In an asynchronous production host, the analogous ownership pattern may use asynchronous context managers and the SDK's documented session lifetime rules.

Notice how the fake client exposes basic operations while the host handles application decisions. The fake client has no model integration and does not know which operations require approval. The host does not implement message serialization or transport details.

This deliberately small program fails the entire host startup if any configured client fails. Some applications instead allow partial availability and report the missing integration; that is a product and reliability decision. The example also counts actual invocation attempts, including any attempt whose response turns out to be invalid. It does not bound rejected proposals or overall task duration.

For production, independently enforce resource permissions, validate approved route records and discovered schemas, authenticate and authorize clients, use trusted user-bound approvals, enforce deadlines and concurrency-safe budgets, handle dynamic discovery changes and check result size and content. The test suite does not exercise malformed server results despite the validation branch, nor does it prove cross-tenant isolation, resistance to prompt injection or actual MCP compatibility. Do not deploy this fixture as a security boundary.

9. Different types of hosts in practice#

Host exampleWhat it coordinates
IDE assistantWorkspace context, code tools, developer consent and permitted file operations
Desktop assistantConfigured local or remote services, user interaction and selected context
Web support assistantAuthenticated customer session, account-specific tools and relevant evidence
Enterprise operations applicationWorkflow state, permissions, approvals, audit and service coordination
CLI or automated jobExplicit operations, deterministic arguments, controlled scheduling and results

These are examples of host categories, not assertions about the features of a particular product or current release. A product may have a host application that supports only a subset of MCP capabilities. Its suitability depends on the actual version and supported features.

A host can combine native application operations, ordinary APIs and MCP-backed tools. Adopting MCP does not require replacing every integration or using an agent framework.

10. Host failure handling and operational ownership#

A host needs a clear response when a server becomes unavailable, a client disconnects, a capability changes, a user declines consent or the model proposes an invalid operation.

For read-only information, the application can report unavailable or stale evidence and proceed only if the remaining facts are sufficient. For a side-effecting tool, an interrupted response can leave the business outcome uncertain. The host should not blindly retry an uncertain write; it should use the authoritative operation status and applicable idempotency mechanisms.

Useful host-level operational signals include connection startup failures, discovery failures, invocation attempts, policy denials, approval outcomes, timeouts, invalid results, task duration and model usage. Correlate these with server-side and business-service telemetry without logging sensitive content unnecessarily.

The host should expose only currently usable operations, clean up resources on shutdown and manage changes in user identity or permissions. If connection reuse is implemented, ensure that it does not cause identity or session state to leak between users. Dedicated roadmap lessons address isolation and reliability in depth.

11. A host design checklist#

Before calling an application an MCP host, identify who owns these responsibilities:

Design areaQuestion to answer
Client lifecycleWho creates, owns and closes each connection?
Server trustHow are approved server identities and configurations established?
Capability handlingHow are supported features discovered, selected and routed?
Model integrationHow are model-facing tool proposals converted and validated?
ConsentHow does the user approve or decline a sensitive operation?
ContextWhat information may be shared, with which destination, and under what budget?
Business resultsHow does the host distinguish success, denial, error and uncertainty?
ReliabilityWhat happens on unavailable connections, exhausted budgets or interrupted writes?
TestingCan host policy and workflow behavior be verified separately from model behavior and transport?

This is an application architecture checklist, not a normative list of required protocol methods. A minimal deterministic host may have no model adapter or graphical user interface; an enterprise assistant may require many more components.

Interview-ready answer#

An MCP host is the application responsible for coordinating MCP clients, external capabilities and the user's workflow. It selects trusted server integrations, creates and manages client lifetimes, discovers and filters capabilities, integrates them with an optional model or deterministic workflow, and controls consent, context sharing, routing and execution policy. The client handles the protocol communication with a server, while the server exposes and executes capabilities and independently enforces resource authorization and business rules. The host does not replace the model, the protocol client or the downstream business service; it connects them into a controlled application experience.

Next lesson: Q17 examines the MCP client itself, including how it communicates with a server and how its protocol responsibilities differ from the host's application responsibilities.

References

  1. 1.
  2. 2.
    MCP architecturemodelcontextprotocol.io
  3. 3.
    MCP lifecyclemodelcontextprotocol.io
  4. 4.
    MCP toolsmodelcontextprotocol.io
  5. 5.
    MCP authorizationmodelcontextprotocol.io
  6. 6.
    MCP samplingmodelcontextprotocol.io
  7. 7.
  8. 8.

Related questions

Explore other topics:Forward Deployed EngineeringAI AgentsLarge Language ModelsRetrieval-Augmented Generation