Introduction
Model Context Protocol (MCP) servers provide a structured interface between Large Language Models (LLMs) and external systems. Instead of allowing models direct access to databases, APIs, or internal logic, MCP defines a standardized way to expose capabilities safely and transparently.
In Python-based MCP implementations (such as FastMCP), these capabilities are registered using decorators. While they may appear as simple syntactic sugar, decorators represent fundamental architectural primitives in MCP:
Tools — Executable actions
Prompts — Reusable instructions
Resources — Readable data
Understanding these decorators is essential when building production-grade AI systems that are secure, scalable, and maintainable.
This article explores their purpose, behavior, and usage in detail.
MCP Architecture Overview
At a high level, an MCP server exposes structured interfaces to an LLM:
LLM Client
Tools (execute logic
Prompts (instruction templates)
Resources (data access)
Decorators register Python functions into these categories so they can be discovered and invoked through the MCP protocol.
Decorators in MCP Servers
Decorators in MCP servers are used to attach metadata to functions, enabling automatic registration with the server runtime.
Example base setup:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Example Server")Functions decorated with MCP annotations become part of the server interface.
Tool Decorator (@mcp.tool)
Purpose
Expose a function that performs an action or computation which the LLM can invoke.
Typical Use Cases
Database queries
API calls
Calculations
Workflow execution
System automation
Example
@mcp.tool()
def calculate_bonus(salary: float, rating: int) -> float:
return salary * (0.1 + rating * 0.02)Behavior
Registered in the tool registry
Automatically converted to schema
Discoverable by MCP clients
Executed when invoked
Architectural Role
Tools extend the LLM’s capability beyond language generation by enabling:
Deterministic execution
Access-controlled operations
Integration with enterprise systems
Key Characteristics
| Property | Value |
|---|---|
| Execution | Yes |
| Deterministic | Yes |
| Side Effects | Possible |
| Security Enforcement | High |
Prompt Decorator (@mcp.prompt)
Purpose
Define reusable prompt templates available to clients or orchestrators.
Typical Use Cases
Summarization templates
Standard reasoning instructions
Task-specific guidance
Controlled prompting pipelines
Example
@mcp.prompt()
def summarize_policy(text: str):
return f"""
Summarize the following HR policy:
{text}
"""Behavior
Registered as prompt resource
Callable by clients
Encourages consistent prompting
Architectural Role
Prompts enable:
Centralized instruction management
Reusability
Standardized LLM behavior
They act as instruction assets, separate from execution or data retrieval.
Key Characteristics
| Property | Value |
|---|---|
| Execution | No |
| Generates Text | Yes |
| Side Effects | None |
| Purpose | Guidance |

Join the conversation! Your thoughts help the community grow.