From the course: Hands-On AI: Building AI Agents with Model Context Protocol (MCP) and Agent2Agent (A2A)

Resources, tools, and prompt templates

- [Instructor] What kind of content can be served using MCP? It can be resources, tools, and prompt templates. MCP is built as a general purpose interface for any kind of data and these three are the most popular ones used in the Gen AI world. Let's first discuss resources. Resources are read-only data that is exposed to the Gen AI application. Each resource has a unique URI through which the data can be accessed. The MCP server can both provide the URI as well as the data that is served by it. Resources can be of any kind. They can be files, records from a database, images, audio, video, or search results from a search engine. The important thing to note is that resources can only be read. They cannot be modified. The MCP client and the associated host application decides on how these resources will be used within the application. They can be used for decision making or generating answers to the user questions. The MCP server itself is not aware and does not care about the actual usage. How does a client know what resources are available? Each MCP server also provides a listing interface through which clients can get a list of resources available in that server. MCP servers also support dynamic update notifications. This means that if a resource is updated after it is fetched by the client, the server can notify the client after the change. Next comes tools. Tools are specifically used in the context of AI agents. Tools expose executable functionality to the MCP clients. These include create, retrieve, update, and delete operations. There can also be other capabilities like reviewing content, integrating with workflows, and alerting. Do note that the same data can either be served either as a resource or as a tool. A resource is read-only, whereas a tool can be used to change the data also. Tools enable AI agents to integrate with third-party applications using a standard protocol. Third-party applications will support their own MCP servers which the agents can use MCP to integrate with. Each MCP server will also provide a tool listing interface that can be used by the clients to discover tools provided by the server. This listing contains metadata about the tool's inputs, functions, and outputs. This can be used by a reasoning model to determine if and when to use these tools. Then comes prompt templates. Prompt templates typically are system prompts that have placeholders for the user query, context, and other information. Having reusable prompt templates for specific functions helps standardize interactions and promote reusability. Prompts served by MCP servers support metadata as well as placeholder variables. These variables can be replaced with actual values during serving. Again, MCP provides a prompt listing capability that allows clients to discover the prompt templates that are available for a given MCP server. MCP also supports dynamic prompts where prompts can be created using serving time based on the user inputs or system conditions.

Contents