Skip to content

MCP Resources (Server)

An MCP Resource is a URI-addressable, read-only, text or binary payload of data at the MCP server that a model is allowed to see. The resource content is tagged with a MIME-type to describe the content type.

Internally, a resource is a data abstraction backed by static or dynamic content in storage and discovery. Examples of resources are user-profile data, a database schema, business configuration, business knowledge documents etc.

Resource vs Resource template - Difference only in exposure

Resources may be exposed as MCP server capability in either of two ways:

  • Resource: has fixed URI, e.g. worksheet://acct/2026/1351
  • Resource Template: has URI template, e.g. workorder://shopfloor/2026/{id}

The MCP read-resource call contains a full URI that automatically maps to either a matching resource or a matching resource template.

Here are resource and resource template examples:

(ns hello-mcp-clj.resource
  (:require
   [plumcp.core.api.entity-support :as es]
   [plumcp.core.util :as u]))


(defn get-fire-safety-instructions []
  ;; Simulate loading fire safety instructions from storage
  "Fire safety instructions")


(defn ^{:mcp-type :resource
        :mcp-name "fire_safety_instructions"
        :mime-type "text/plain"} fire-safety
  "Fire safety instructions for the shopfloor"
  [{:keys [^{:doc "text://fire/safety"} uri]}]
  (es/make-text-resource-result
   uri
   (get-fire-safety-instructions)))


(defn get-consumable-info [id]
  ;; Simulate load consumable info from database
  {:part-no "ABC123"
   :description "Disinfectant wipe"
   :batch-no "56/2024"
   :life-upto "2025/06"})


(defn ^{:mcp-type :resource-template
        :mcp-name "consumable_info"
        :mime-type "application/json"} consumable-info
  "Consumable info as JSON"
  [{:keys [^{:doc "info://consumable/{id}"} uri
           ^{:doc "URI params"} params]}]
  (->> (get-consumable-info (:id params))
       u/json-write
       (es/make-text-resource-result uri)))

Client call

See Resources (Client) for the client call.

Resource Var definition

As you can see in the highlighted code example above, var annotations convey the resource metadata:

  • :mcp-name (optional) The MCP resource name - same as function name if unspecified
  • :mcp-type :resource indicates that this is an MCP resource
  • :mcp-type :resource-template indicates this is an MCP resource template
  • The function docstring acts as the resource description
  • An MCP primitive var is always an arity-1 function. The argument is a map of specified, annotated keyword args. In the example above - uri (and params for resource templates) are resource arguments with specified :doc (URI or URI-template for uri, docstring for params) annotations.
  • The function is called when MCP read-resource method is invoked. The function body is supposed to return a read-resource result, which is done above by the plumcp.core.api.entity-support/make-text-resource-result function.

Resources can be put to good use by offloading business and contextual knowledge base, and other data as resources. This helps make AI Agents lightweight where they depend on MCP servers to do this heavy lifting.