Primitives

Resources: context by URI

Resources are read-only data a server exposes by URI, like files, schemas or records. Use a resource for context to read, and a tool when something has to run.

Define them in the server

server.pypython
history = []  # add() appends each result @mcp.resource("calc://history",              title="Recent results")def recent() -> str:    """The last calculations, newest first."""    return "\n".join(reversed(history)) @mcp.resource("calc://constants/{name}")def constant(name: str) -> str:    """A math constant, e.g. pi or e."""    return CONSTANTS[name]

 

 

← in resources/list

 

 

 

← what resources/read returns

 

← in resources/templates/list

 

 

 

Attach them in Claude Code

>

Handy for

  • Context to read: docs, schemas, tickets, logs
  • No side effects, nothing to approve
  • Changing data: clients can subscribe
Resources are application-controlled: the host, not the model, decides when they enter the conversation. In Claude Code you @-mention them, and the model can also list and read them with built-in tools.

10 / 28