MCP: Model Context ProtocolBeginnerModule 01 — Understanding the need for MCP

What does context mean in the Model Context Protocol?

Question 9 of 43 · Updated

On this page

Direct answer#

In the Model Context Protocol (MCP), context means the external information and capabilities that an AI application can make available to a model or use to support its task. Examples include the contents of a document, the current stock of a product, a database record, a reusable prompt or a tool that can obtain information or perform an action.

MCP gives compatible hosts a standardized way to access these capabilities. It does not automatically place everything a server exposes into the model's context window. The host decides what is discovered, retrieved, authorized, selected, transformed and supplied to the model. Some capabilities are used by deterministic application code and never become model input at all.

The distinction is important: MCP connects an application to useful external context and operations; context management determines which information the model actually receives and how it is used.

Learning continuity: Earlier roadmap lessons explained why AI applications need a common integration boundary, how traditional connectors work and why interoperability matters. This lesson introduces the meaning of context at that boundary. Later modules examine tools, resources, prompts, sampling, context budgets and security in depth.

Verification scope: Prepared using the authorized offline research and changelog exceptions. The MCP 2025-06-18 specification is a historical reference baseline, not a claim about the latest revision. Official links were not opened live. The included standard-library Python program was syntax-compiled and executed with Python 3.13.5; all ten context-selection checks passed. No live MCP server, SDK, model tokenizer or model inference was tested. Mermaid diagrams use standard fenced flowchart and sequence diagram syntax; the local Mermaid package was unavailable, so parser and frontend rendering verification remain incomplete.

1. Why a model needs context#

Imagine a customer asks the retailer's support assistant:

"Can I buy seven units of product A12, and how long do I have to return them?"

The model understands the language of the question. But the current inventory and the retailer's applicable return policy are business facts that can change independently of the model's training.

The application needs two pieces of external information:

  • Current sellable inventory for the authorized product and warehouse.
  • The return policy applicable to the customer's purchase.

A model may generate a plausible answer without either fact. Plausibility is not evidence. An application should obtain relevant authoritative information before answering and distinguish unavailable or stale information from verified current data.

If inventory reports seven units and the applicable policy permits returns within 30 days, the host can make these facts available for the model to explain. Those numbers are fictional examples, not actual commercial data.

MCP can supply a common access interface for the inventory and policy systems. The host still needs to decide whether those particular facts are appropriate for this request.

2. External context versus the model context window#

The term context is used at several layers in AI engineering. They should not be confused.

ConceptMeaningRetail example
Model parametersKnowledge and patterns encoded through trainingGeneral understanding of shopping and returns
Model context windowBounded sequence of input and generated tokens supported by the model and APICurrent question, instructions, history and selected facts
External contextInformation obtained outside the model's learned parametersInventory record and policy document
Available capabilitiesOperations or information interfaces the application can useStock tool and policy resource
Application memoryStored history, preferences or task state outside the current inferencePrevious order reference
Context managementSelection, preparation, budgeting and safe delivery of informationInclude current stock and the applicable policy excerpt, not the whole database

A model context window is not a database or permanent memory. Its limits vary with the model, tokenizer, API and serving configuration. MCP does not expand those limits or automatically persist conversation state.

External context may exist in a database, file, API or MCP resource without having been read by the host. A host may discover a tool description without having invoked the tool. It may retrieve a result but use that result in ordinary business logic rather than pass it to a language model.

Loading diagram…

The diagram is a logical view of information flow, not a wire-level MCP transcript. A host may perform multiple rounds of retrieval and model inference; the diagram highlights the boundary between accessible information and information actually supplied to the model.

3. Three important MCP primitives#

The historical MCP baseline describes tools, resources and prompts as distinct server capabilities. A server can expose one or more of these, depending on its implementation and negotiated features.

Tools: operations that can obtain information or act#

A stock tool can look up the current inventory for a SKU. A shipment tool could obtain the delivery status of an authorized order. Another tool could initiate an approved business operation with side effects.

Tools are commonly described as model-controlled because a host can allow a model to select an appropriate operation. This is an interaction-design distinction, not a permission grant. The host may also invoke a tool deterministically, and the server must enforce authorization at execution time.

The model might propose an argument such as:

JSON
{"sku":"A12"}

The application-level result might contain:

JSON
{"sku":"A12","available_units":7}

These are example business payloads, not complete MCP request and result envelopes. Actual MCP results use the content and optional structured output representations of the supported specification. A tool description in model input tells the model what an operation can do; its actual result provides information about what happened. A description is not proof that a tool succeeded.

Resources: readable information#

An MCP resource represents data that a client can access using a URI and the appropriate resource capabilities. Examples include a product catalog entry, a document, a configuration file or a policy page.

A fictional resource URI could be inventory://products/A12 or policy://returns/retail. These are application-defined identifiers, not standardized MCP URI schemes. The client does not automatically know which content to include in its model request.

Resources are commonly described as application-controlled: the application selects and retrieves relevant information. A host may also provide a user interface to select resources. The resource content could be text or binary data represented as supported by the revision and implementation.

A resource need not be static or publicly accessible. Access to a resource still requires the appropriate identity and policy checks.

Prompts: reusable interaction templates#

An MCP prompt exposes a reusable set of messages or a parameterized interaction pattern. For example, an authorized employee might choose a product-availability response template with a SKU argument.

A prompt can help establish a consistent workflow, but it does not automatically establish the truth of the supplied information, execute a tool or override the host's trusted instructions. It should be selected and used under host policy.

Prompts are commonly described as user-controlled because hosts may present them as selectable templates. This describes typical interaction design, not an exclusive rule about who may retrieve or use them. Prompt contents and arguments remain subject to validation and trust boundaries.

PrimitiveMain purposeExample
ToolInvoke an operationLook up current stock
ResourceRead identified informationRetrieve the applicable return policy
PromptObtain reusable messages or workflow guidanceGenerate a consistent product-availability response

The detailed protocol methods, schemas and implementation techniques for each primitive belong to the dedicated roadmap modules. Here the purpose is to understand how each can contribute to a model's task.

4. How external information becomes useful context#

For the customer's inventory question, a possible host workflow is:

Loading diagram…

This is a conceptual application sequence. The host manages the MCP clients, and the individual client-server message exchange, authentication, discovery and lifecycle details are omitted for clarity. The host may select the policy resource through deterministic business logic instead of asking the model to select it.

Notice that the final model input contains selected evidence. It does not need to contain every policy document, every inventory record or every tool available from either server. The host should also preserve provenance so it can explain which service supplied the information and when it was observed.

If a tool returns an error or a resource is unavailable, the host must not substitute a fabricated value. It can report the limitation, request missing information or follow a safe fallback policy.

5. Context selection: more information is not necessarily better#

A large collection of external documents and tool results can exceed the useful input budget. Even when the model technically supports a long context window, including irrelevant material can increase cost, latency and distraction.

A practical selection pipeline first checks whether information is allowed, then ranks or selects it according to the task, and finally fits it into the available model input budget.

For a policy question, the host might retrieve an applicable policy excerpt rather than the entire employee handbook. For inventory, it might select the SKU, the count and the observation time instead of passing raw internal service logs.

A useful context item generally has:

  • A trusted source identity and a clear business meaning.
  • Relevance to the current task.
  • Appropriate access permission and disclosure classification.
  • A freshness or version indication where applicable.
  • A bounded size and a supported representation.

The model input budget also includes system and developer instructions, user messages, conversation history, tool metadata and results. For an API that counts generated output within its context limit, a simplified planning equation is:

available evidence tokens = context limit - instructions - history and user request - tool metadata - reserved output tokens - safety margin.

For example, with an illustrative 8,000-token total budget, 1,000 instruction tokens, 1,500 history/request tokens, 800 tool-metadata tokens, a 1,000-token output reserve and a 200-token margin, the remaining evidence budget is 3,500 tokens.

This is an illustrative budget, not a specific model's documented limit. APIs may apply different input/output limits and message-accounting rules. Use the provider's supported tokenizer or token accounting method and actual serialized request representation. Character counts, word counts and UTF-8 byte lengths are not interchangeable with model tokens.

A host should not simply truncate arbitrary JSON or cut a sensitive policy statement in half. Select complete meaningful items, summarize only when appropriate, preserve important qualifiers and report when required evidence cannot fit.

6. Freshness, provenance and conflicting evidence#

Context is valuable only if it is appropriate for the question. Inventory may change within seconds, while a published return policy may remain effective for weeks. There is no universal freshness period for every MCP result.

An application can record the source, observation time, effective date, version and permitted caching duration when those are known. Freshness rules are application-specific; MCP does not impose one universal time-to-live field on every resource or tool result.

For example:

EvidenceIllustrative freshness policy
Available stockFetch near decision time; reject excessively stale observations
Return policyVerify effective date and applicable region/product
Order statusRe-fetch when a user requests the current state
Historical sales reportRetain its reporting period; do not describe it as current live data

A stale observation does not necessarily become false at a precise boundary; it becomes insufficient for a task that requires newer evidence. A host should distinguish observation time from effective business time and from cache retrieval time.

Conflicting evidence needs explicit handling. If one inventory source reports seven units and another reports three, the host cannot assume the larger number is correct. It should check source authority, warehouse identity, measurement semantics and timestamps, and report unresolved disagreement when needed.

For a purchase decision, even a fresh stock lookup may become outdated before the order is placed. A transaction must enforce availability again at the authoritative execution boundary.

7. Privacy and trust boundaries#

External context may include private documents, customer identifiers, internal policies or sensitive tool results. Access by a host does not automatically authorize sending that information to every model provider or other connected server.

Apply data minimization: retrieve the information needed, enforce source and resource authorization, redact fields that are not necessary, and ensure the destination is approved. Preserve separate user and tenant identities. Avoid putting credentials in prompts, tool results, model-visible logs or reusable caches.

Treat external content as data rather than trusted control instructions. A policy document that contains text asking the assistant to ignore its instructions or send customer records to another service does not gain authority merely because it was retrieved through MCP. Host policy and execution-time authorization must remain outside the model.

A resource's URI, a tool annotation or a server's own claim that information is shareable is not an independent authorization decision. The host and server must use trusted policy and identity context. Context filtering also does not replace downstream authorization or a comprehensive prompt-injection defense.

8. Locally tested Python exercise: selecting bounded external context#

This standard-library example models a small host-side context-selection policy. It uses fictional records already retrieved from trusted application adapters. Its goal is to demonstrate source allowlisting, tenant checks, freshness, disclosure filtering, prioritization, duplicate suppression and a bounded serialized payload.

It is not an MCP SDK, a complete security boundary, a semantic retriever or a model tokenizer. Fact metadata must be supplied by trusted application logic after appropriate authentication, resource authorization and data classification. The shareable flag in this example represents a prior policy decision, not a server-controlled permission. The byte budget is an explicit transport/payload budget, not a model-token budget.

Save as mcp_q10_context.py.

PYTHON
from dataclasses import dataclass, replace import json @dataclass(frozen=True) class Fact: source: str tenant: str key: str value: str observed_at: int ttl: int priority: int shareable: bool = True def select_context(facts, tenant, approved_sources, now, byte_budget): if type(byte_budget) is not int or byte_budget < 2: raise ValueError('Budget must fit an empty JSON array') selected, seen = [], set() eligible = [f for f in facts if f.tenant == tenant and f.source in approved_sources and f.shareable and f.ttl > 0 and 0 <= now - f.observed_at < f.ttl] for f in sorted(eligible, key=lambda f: (-f.priority, -f.observed_at, f.source, f.key)): if (f.source, f.key) in seen: continue seen.add((f.source, f.key)) item = {'source': f.source, 'key': f.key, 'value': f.value, 'observed_at': f.observed_at} trial = json.dumps(selected + [item], ensure_ascii=False, separators=(',', ':')) if len(trial.encode('utf-8')) <= byte_budget: selected.append(item) return json.dumps(selected, ensure_ascii=False, separators=(',', ':')) if __name__ == '__main__': now = 1000 stock = Fact('inventory', 'A', 'A12', '7 units', 990, 60, 10) policy = Fact('policy', 'A', 'returns', '30 days', 900, 500, 5) allowed = {'inventory', 'policy'} def choose(facts, budget=1000): return json.loads(select_context(facts, 'A', allowed, now, budget)) assert [x['key'] for x in choose([policy, stock])] == ['A12', 'returns'] assert choose([replace(stock, tenant='B')]) == [] assert choose([replace(stock, source='unknown')]) == [] assert choose([replace(stock, shareable=False)]) == [] assert choose([replace(stock, observed_at=940)]) == [] assert choose([replace(stock, observed_at=1001)]) == [] assert choose([stock, replace(stock, observed_at=980, value='5 units')])[0]['value'] == '7 units' assert len(choose([stock, stock])) == 1 assert choose([stock], 2) == [] raw = select_context([replace(stock, value='₹7')], 'A', allowed, now, 1000) assert '₹7' in raw and len(raw.encode('utf-8')) > len(raw) print('10 context-selection checks passed')

Run:

BASH
python -m py_compile mcp_q10_context.py python mcp_q10_context.py

Actual output on Python 3.13.5:

10 context-selection checks passed

The ten assertions check ordering by priority, tenant isolation in the supplied fixtures, source filtering, disclosure filtering, expiry at the freshness boundary, future timestamps, selection of the newer equally prioritized duplicate, duplicate suppression, an empty result under a two-byte budget and the difference between UTF-8 bytes and Unicode character counts.

The selection algorithm prefers higher priority, then more recent observation time. It selects at most one fact per source/key pair. If the preferred version of a fact does not fit, it does not substitute a lower-ranked duplicate. This is a deliberate policy choice for the exercise, not a universal context-selection algorithm. It does not resolve disagreements between different sources or between equal-priority records with identical timestamps; production systems should specify deterministic conflict resolution.

The serialized JSON array includes its delimiters and field names in the byte budget. The implementation greedily considers complete items rather than truncating them. A small budget may omit important evidence; an application should check that all required facts are present before claiming a complete answer.

For N candidate facts, filtering is O(N) and sorting is O(N log N). Re-serializing the growing selected list for each candidate can introduce quadratic work in the number of selected records, so this example is intended for small bounded inputs. A production system should cap input sizes, validate metadata types, account for serialization efficiently, enforce model-specific token limits and attach explicit evidence coverage information. The tests do not establish actual multi-tenant security, network behavior or prompt-injection resistance.

9. MCP versus context engineering and RAG#

MCP, context engineering and retrieval-augmented generation are complementary concepts.

ApproachPrimary responsibility
MCPStandardized communication and access to supported external capabilities
Context engineeringDesigning the information, instructions, tools and state supplied to a model for a task
RAGRetrieving relevant knowledge and augmenting generation with that evidence
Memory systemPersisting and retrieving application state or information across requests

A host can use RAG without MCP by calling its search service directly. It can expose retrieval behind an MCP tool or resource interface to make that capability reusable by compatible hosts. It still needs retrieval quality, filtering, ranking, access controls and grounding evaluation.

Similarly, a memory service can provide information through MCP, but MCP is not itself a persistent conversation memory store. It does not automatically remember user preferences or synchronize every application's conversation state.

Model input management remains the host's responsibility. More specialized mechanisms, including sampling and resource subscriptions where supported, have their own rules and do not imply unrestricted sharing of all host context. The applicable specification and host policy determine what can be exchanged.

10. Common beginner misconceptions#

Does connecting an MCP server automatically give the LLM access to all its data? No. Discovery and authorized retrieval are separate from selecting what is actually supplied to a model.

Does MCP increase the model's context window? No. The model and serving API determine input and generation limits. MCP provides access to external capabilities.

Is a tool the same thing as context? A tool is a callable capability. Its description may be included in model context, and its result can supply information or confirm a business operation. The operation itself is distinct from the information the model receives.

Is external context always trustworthy or current? No. Validate provenance, permission, freshness, semantics and result structure. Treat retrieved text as untrusted data.

Does every MCP operation need an LLM? No. An application can consume supported capabilities through ordinary code. A later lesson explores that distinction in detail.

Interview-ready answer#

Context in MCP refers to the external information and capabilities an AI application can access to support a task, such as documents, database-backed records, reusable prompts and tool results. MCP standardizes how compatible clients communicate with servers that expose these capabilities, but it does not automatically insert every result into the model's context window. The host selects relevant and authorized information, checks freshness and provenance, manages token budgets and privacy, and decides what should be supplied to the model or consumed by deterministic application code. MCP is therefore an external capability interface, while context engineering, RAG and memory management address separate application responsibilities.

Next lesson: Now that the difference between external context and model input is clear, the next roadmap question examines the broader problems MCP does not solve and which responsibilities remain with application developers.

References

  1. 1.
  2. 2.
    MCP resourcesmodelcontextprotocol.io
  3. 3.
    MCP toolsmodelcontextprotocol.io
  4. 4.
    MCP promptsmodelcontextprotocol.io
  5. 5.
    MCP authorizationmodelcontextprotocol.io
  6. 6.
  7. 7.
  8. 8.

Related questions

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