MCP Academy · Lesson

Read a File from Disk

Turn a local file into a live MCP resource.

From Fixed to Live

Returning a hardcoded string is fine, but real servers expose actual files. You can read a file from disk and serve its contents live.

Read Inside the Handler

Your resource function simply opens the file and returns its text. Because it runs on each request, the client always gets the current content. 📂

All lessons in this course

  1. Resource URIs Explained
  2. Serve a Static Text Resource
  3. Read a File from Disk
  4. Set the Right MIME Type
← Back to MCP Academy