An MCP resource is a server-provided data source that an MCP client or tool can inspect or access. Resources supply external data—such as files, web pages, configuration, or database records—for an LLM to process, while Tools perform actions and Prompts guide interactions. section 13.1.1 section 13.1.4
Registering resources in Python
Use the MCP resource decorator to expose data through URI-like identifiers. A text resource can validate a path, read the file, and return its contents; a configuration resource can return a static value; a PDF resource can extract text with PyMuPDF. Identifiers such as text://{file_path}, config://app, and pdf://{file_path} tell clients how to access each resource. section 13.2.6
Listing 13.2 Adding Resources to the MCP server
# server.py
# ==============================================
# resources, tools, and prompts to be added here
#==========
# Resources
#==========
@mcp.resource("text://{file_path}")
def get_file(file_path: str) -> str:
actual_path = os.path.abspath(file_path) #1
if not os.path.exists(actual_path):
raise FileNotFoundError(f"Error: File '{actual_path}' not found!")
with open(actual_path, "r", encoding="utf-8") as file:
return file.read()
@mcp.resource("config://app")
def get_config() -> str:
"""Static configuration data"""
return "Version 1.1"
@mcp.resource("pdf://{file_path}")
def get_pdf_data(file_path: str) -> str:
text = ""
actual_path = os.path.abspath(file_path)
if not os.path.exists(actual_path):
raise FileNotFoundError(f"Error: File '{actual_path}' not found!")
with fitz.open(actual_path) as doc:
for page in doc:
text += page.get_text() + "\n"
return text
Inspect the complete server listing to see path validation, file reading, static configuration, PDF extraction, and URI-based registration. section 13.2.6
Test resources with the MCP Inspector:
- Connect to the running server and select List Resources to inspect parameterless resources such as config://app. section 13.2.9
- Select List Templates for parameterized resources, enter a file path, and choose Read Resource to retrieve text or PDF content. section 13.2.9



