Module 15 · MCP · Lesson 32 of 34
Building and securing MCP servers
What a small server looks like, how to design its tools, and the security rules that matter.
In this lesson · about 18 minutes
- Read a minimal MCP server
- Design a server's tools and resources well
- Apply the main security rules for MCP
Official SDKs exist for common languages. A minimal server in Python, using the SDK's high-level helper, looks roughly like this:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("bakery-orders")
@mcp.tool()
def get_order_status(order_id: str) -> str:
"""Look up one order by its number. Read-only."""
order = db.find_order(order_id)
if order is None:
return f"Order {order_id} not found. Ask the customer to check the number."
return f"Order {order_id}: {order.status}, due {order.due_date}"
@mcp.resource("bakery://policies/returns")
def returns_policy() -> str:
"""The current returns policy."""
return load_policy("returns")
if __name__ == "__main__":
mcp.run()
The function name, type hints and docstring become the tool's name, input schema and description: the same things you wrote by hand in Module 5. Check the SDK's current documentation before you build; details change.
Sorting drill
Good MCP server design?
Sort each choice.
- A tool get_invoice(invoice_id) that returns 6 key fields
- A tool run_sql(query) using the production admin account
- Exposing the returns policy as a resource
- Installing a random “super-tools” server found in a forum post
- Clear error messages the model can act on
- A send_email tool that runs with no confirmation step
0 of 6 sorted
Check your understanding0 of 2 correct
Plan the MCP servers for your project.
Consider these questions and write down your thoughts. What you write stays on this device.
Quiz score: 0 of 2
Written by Noviq Academy in its own words. The simulators are small teaching models that keep the real idea and leave out the scale; their numbers (prices, speeds, scores) are illustrative. Model names, prices and features change quickly, so check your provider's current documentation before you build. Read-aloud uses your device's built-in voices.