Search⌘ K
AI Features

Adding Resource Feature to the MCP Application

Explore how to add and use static resources within an MCP application to provide your AI agent with contextual information. Learn to create resource files, register them on the MCP server, and fetch them from the client. This lesson equips you to implement data-driven features that enhance modularity and usability in intelligent assistants.

While tools enable the assistant to perform actions and prompts shape its reasoning, there are scenarios where we need a structured mechanism to provide contextual information, such as lists, reference data, or background details, within the model’s workflow. This is where resources are essential.

In MCP, resources are passive data objects that the client explicitly loads and utilizes. For example, the assistant might use a file containing suggested Wikipedia topics to recommend areas for further exploration. Unlike tools and prompts, resources do not execute logic or generate dynamic outputs. Instead, they are retrieved by the client and used as static data.

In this lesson, we define a file-based resource on the server and demonstrate how to modify the client to fetch and use it interactively.

What are the resources in MCP?

Resources in MCP are named, structured data objects exposed by the server but retrieved and used entirely by the client. They’re useful when the assistant needs reference information that doesn’t change frequently and doesn’t require computation, like recommended topics, glossary terms, or API keys.

Unlike tools (which execute functions) or prompts (which generate templates), resources contain no logic or instructions. Instead, the client retrieves them using session.read_resource() and determines how to use them—whether feeding them into the LLM, displaying them to the user, or integrating them into UI elements.

MCP resources workflow
MCP resources workflow

Resources are typically used to:

  • Provide contextual background (e.g., a list of predefined topics).

  • Inject static configuration or preferences.

  • Support client-side filtering, choices, or menus.

Let’s implement a simple resource that loads topic suggestions from a local file.

Creating the resource file

...