What is a resource in MCP, and how does it differ from a tool?

4 minbeginnermcpresourcesfundamentals

Quick Answer

A resource is a piece of data a server exposes for the host application to read and attach as context — a file's contents, a database row, a log excerpt, a config value. Unlike tools, resources are application-controlled: the host decides what to fetch and when (often to enrich a prompt automatically, or to populate a picker UI the user browses), rather than the model deciding to invoke it mid-conversation. Every resource has a URI (e.g. file:///home/user/notes.md or a custom scheme like postgres://db/orders/42), a name, and optionally a MIME type. Resources are read via resources/read, which returns the content, not executed via tools/call — there are no "arguments" to a resource the way there are to a tool, since it's a lookup, not an action.

Detailed Answer

Resources answer a different question than tools do. A tool answers "what can the model do?" A resource answers "what data can be attached to context?"

A resource entry from resources/list

{
  "uri": "file:///home/user/project/README.md",
  "name": "README.md",
  "description": "Project readme",
  "mimeType": "text/markdown"
}

Reading it

// Request
{"jsonrpc": "2.0", "id": 3, "method": "resources/read", "params": {
  "uri": "file:///home/user/project/README.md"
}}

// Response
{"jsonrpc": "2.0", "id": 3, "result": {
  "contents": [{
    "uri": "file:///home/user/project/README.md",
    "mimeType": "text/markdown",
    "text": "# My Project\n\nThis project does..."
  }]
}}

Tools vs. resources at a glance

Nothing stops a server from offering both over the same underlying data — a filesystem server, for instance, can expose read_file/write_file as tools while also exposing recently opened files as resources:

ToolsResources
Who decides to use itThe model, mid-conversationThe host application, often ahead of time
Has "arguments"?Yes, an inputSchemaNo — just a URI to read
Side effectsCan perform actionsRead-only by design
Typical triggerModel reasons it needs to call somethingUser attaches a file, or host auto-includes recent context

Related Resources