Replies: 1 comment
-
|
This is a sharp question that hits a genuine ambiguity in the spec. Let me give you the answer based on how the protocol designers and major implementations interpret it. The short answerResources are expected to be logically read-only, but they are NOT required to be side-effect free. The distinction matters. What the spec actually saysThe MCP specification states that resources represent "read-only data" that the client can access. The word "read-only" describes the semantic contract — the client reads data, the data appears immutable from the client's perspective. It does not say "pure function" or "no side effects." This is intentionally looser than a pure functional requirement. Why the distinction matters for your use caseYour scenario — reading a resource that triggers enrichment/persistence — maps perfectly to the "logically read-only but not side-effect-free" category. Concrete example that is widely accepted: When the client reads this resource:
The key property that makes this acceptable: the client perceives it as a read. The client asks for data and gets data. The fact that the server cached/derived/enriched the data internally is an implementation detail, not a protocol violation. The boundary lineWhat crosses the line into "this should be a tool":
The rule of thumb: if the primary intent of the call is to change state, use a tool. If the primary intent is to read data and any state change is a secondary optimization (caching, logging, enrichment), a resource is fine. Why the spec leaves this openThe protocol intentionally does not mandate pure-functional resources because:
Your specific case: recommended approachYour enrichment workflow (read events → LLM analysis → persist insights) is acceptable as a resource if:
If you want to be extra safe, split it: a resource that reads cached insights, and a separate tool that triggers re-computation. But for most practical purposes, the combined resource pattern is fine. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Pre-submission Checklist
Question Category
Your Question
I have a question about the intended usage of
Resourcein MCP.From the protocol, resources appear to be client-initiated and read-oriented, but there is no explicit guidance on whether resource handlers are expected to be side-effect free.
In particular:
This would not be an authoritative state change, but rather post-processing or enrichment based on existing domain events. The authoritative mutation happens elsewhere; the resource materializes insights.
I understand tools are intended for LLM-initiated actions, which makes them a poor fit for client-initiated enrichment workflows.
Is this usage:
Clarification on whether resources are expected to be
logically read-onlyvsside-effect freewould be very helpful.Thanks.
Beta Was this translation helpful? Give feedback.
All reactions