Serve a Static Text Resource
Expose a fixed document for the model to read.
Serve a Static Text Resource is a free MCP Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the MCP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
A Fixed Document
The simplest resource is a static one: a fixed string your server returns every time. Great for help text, policies, or config notes.
One Function, One URI
You expose it by writing a Python function and tagging it with a resource URI. When a client reads that URI, your function runs and returns text.
The Decorator
The resource decorator registers the function under its URI. The string you pass becomes the address clients use to fetch the content.
@mcp.resource("info://welcome")
def welcome():
return "Welcome to the server!"Return Plain Text
For a text resource, just return a Python string. The SDK wraps it into the proper MCP read response so the client receives clean content.
Name and Describe It
Give the resource a clear description so the model knows when to read it. A docstring on the function is used as that description.
@mcp.resource("info://welcome")
def welcome():
"Greeting shown to new users."
return "Hello there!"Static Means No Inputs
A static resource takes no parameters; it always yields the same body. If you need to vary output, that is a job for templates, covered later.
Build Text in Code
The return value can be assembled in Python before sending. The result is still static to the client, since the same call gives the same text.
@mcp.resource("config://limits")
def limits():
return "max_items=100\ntimeout=30"Why Resources, Not Tools
Use a resource when the model only needs to read context. Tools are for actions; reading reference text is exactly what resources are for.
The Model Pulls It In
Many hosts let the user attach a resource to a chat, dropping its content into context. The model then reasons over that text alongside the prompt.
Keep It Lightweight
Static resources load fast since there is no work to do. Reserve them for small, stable text so you do not flood the model with tokens.
Test Your Resource
Run the server and use a client to list and read the URI. Seeing your exact string come back confirms the resource is wired correctly.
Quick Check
Choosing the right primitive for fixed text.
Recap
A static resource is a function under a URI that returns fixed text. Add a docstring description and keep the body small. 📄
Frequently asked questions
Is the “Serve a Static Text Resource” lesson free?
Yes — the full text of “Serve a Static Text Resource” is free to read here on the web, and the MCP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the MCP Academy course, upgrade to CoddyKit PRO.
What will I learn in “Serve a Static Text Resource”?
Expose a fixed document for the model to read. You practise MCP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start MCP Academy?
No prior experience is required. MCP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Serve a Static Text Resource” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this MCP Academy lesson?
Yes. Every MCP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Resource URIs Explained
- Serve a Static Text Resource
- Read a File from Disk
- Set the Right MIME Type