Skip to content
Back to log

The difference between tools, resources and prompts in MCP

Chainabit's Chao · · 7 min read

In short

In MCP, a tool is a callable operation, a resource is context data, and a prompt is a structured message template. Compare the control models and protocol requests for all three.

The Model Context Protocol (MCP) defines three structures offered by a server: tools, resources, and prompts. A tool is an operation that a language model can call. A resource is data that provides context to the model. A prompt is a template containing structured messages and instructions for interacting with a language model.

This distinction also appears in protocol requests. A client sends tools/call to call a tool, resources/read to retrieve resource content, and prompts/get to retrieve a specific prompt. Each structure also has a separate request that lists available items.

Control models

The MCP specification defines a model-controlled interaction model for tools. The language model can discover and automatically call tools based on the context and the user's prompts. The specification does not require applications to use a particular interface format.

Resources are designed to be application-driven. The host application determines how to incorporate context according to its own needs. The specification gives explicit selection from a list or tree view, and searching and filtering resources, as examples. Automatic inclusion of context is also among the options described.

Prompts are designed to be user-controlled. The server offers them to the client so that the user can explicitly select them. Commands initiated by the user in the interface are among the usage examples given in the specification. MCP does not require a particular interface format for prompts either.

Tool: Callable operation

According to the MCP specification, a server can offer tools that language models can call. These allow models to interact with external systems. Querying databases, calling APIs, and performing calculations are among the examples in the specification.

Each tool is identified by a name. The inputSchema in its definition specifies the expected parameters as JSON Schema. The optional title provides a human-readable name for display. The description explains its function. A tool can also include an optional outputSchema to specify the output structure.

The client sends tools/list to retrieve the list of available tools. This operation supports pagination. A tool call uses tools/call; the request carries the tool name and the arguments in arguments. A server that supports tools must declare the tools capability.

The listChanged property in the tools capability indicates whether the server will send a notification when the list of available tools changes. According to the MCP specification, a server that declares this capability should send a notifications/tools/list_changed notification when the list changes.

A tool result can carry structured or unstructured content. An unstructured result is returned in the content field and can contain multiple content items of different types. The specification lists text, image, audio, resource link, and embedded resource types. Structured content is returned as a JSON object in the structuredContent field.

If a tool provides an outputSchema, the server's structured results must conform to that schema. The MCP specification also specifies that the client should validate the structured result against the schema. A tool that returns structured content is expected to also return the serialized JSON content in a TextContent block for backward compatibility.

A tool can return a resource link to provide additional context or data. The link contains a URI that the client can read or subscribe to for changes. However, resource links returned by a tool are not guaranteed to appear in the result of resources/list.

There are two mechanisms for tool errors. Cases such as an unknown tool or invalid arguments can be reported as protocol errors. Errors that occur during tool execution can be reported with isError: true in the result. The specification gives API errors and invalid input data as examples of the second group.

Resource: Data for context

The MCP specification defines resources as a way for a server to share context data with a client. Files, database schemas, and application-specific information are examples of this data. Each resource is identified by a unique URI.

A resource definition contains uri and name. The optional title provides a human-readable name for display. description, mimeType, and size in bytes are also optional fields. Resource content can be text or binary data; the specification examples show these with the text and blob fields, respectively.

Turn this insight into action.

Use the mobile app to continue with guided workflows.

The client retrieves the list of available resources with resources/list. Listing supports pagination. To retrieve the content of a resource, it sends resources/read and specifies the resource's URI in the request. In the server's response, the content appears in the contents field.

Resource templates allow the server to offer parameterized resources using URI templates. The client can list these templates with resources/templates/list. According to the specification, template arguments can be autocompleted through the completion API; the template listing operation also supports pagination.

A server that supports resources must declare the resources capability. The subscribe and listChanged properties in this capability are optional. The server can support both, only one, or neither.

subscribe indicates whether the client can subscribe to be notified of changes to individual resources. listChanged indicates whether the server will send a notification when the list of available resources changes. The client uses a resources/subscribe request containing a URI to subscribe to a specific resource. The change notification method is shown as notifications/resources/updated.

Resources, resource templates, and content blocks can include optional annotations. audience can indicate whether the content is intended for user, assistant, or both. priority expresses the importance of the resource; lastModified carries the time it was last modified. The client can use this information for filtering, prioritizing content to include in context, or sorting.

The MCP specification defines file:// and git:// as examples of URI schemes. file:// identifies resources that behave like a file system; they do not have to correspond to a physical file system. Applications can also use custom URI schemes. These custom schemes must comply with RFC3986.

Prompt: Structured message template

According to the MCP specification, prompts are prompt templates that the server offers to the client. These templates provide structured messages and instructions for interacting with a language model. The client can retrieve the list of available prompts, request the content of a prompt, and provide arguments to customize it.

In a prompt definition, name is the unique identifier for the prompt. The optional title carries a human-readable name for display, description carries the description, and arguments carries the list of arguments for customization. A server that supports prompts must declare the prompts capability at initialization.

The client requests the list of available prompts with prompts/list. This listing supports pagination. It uses prompts/get to retrieve a specific prompt. In the specification example, the request carries the prompt's name field and arguments object; the response contains the description and messages fields. Prompt arguments can be autocompleted through the completion API.

The listChanged property in the prompts capability indicates whether the server will send a notification when the list of available prompts changes. A server that declares this capability should send a notifications/prompts/list_changed notification when the list changes.

The role field of a message in a prompt specifies the speaker as user or assistant. The message's content field can contain text, image, audio, or embedded resource content. Content types also support optional annotations for audience, priority, and modification time.

Image and audio data in a prompt message must be encoded in base64 and include a valid MIME type. An embedded resource allows a resource on the server side to appear directly in the message. Such a resource can contain text or binary data. It must include a valid resource URI, an appropriate MIME type, and either text content or base64-encoded blob data.

Boundaries and security

The MCP specification specifies a trust boundary for tool annotations: The client should not consider them trustworthy unless they come from trusted servers. The specification also states, as a security expectation, that a human should be able to deny tool calls.

On the resource side, the server must validate all resource URIs. Binary data must also be encoded appropriately. On the prompt side, applications must carefully validate all prompt inputs and outputs to prevent injection attacks or unauthorized access to resources.

Error responses also differ by structure. The specification specifies the -32002 code for a resource that cannot be found and the -32602 code for an invalid prompt name or missing required prompt arguments. The server is expected to return standard JSON-RPC errors in these cases.

Ready to start?

Download the app and continue from your phone.

End of Entry