AI Hints
Home›MCP Tutorial›Cheat Sheets
MCP · Lesson 115 of 120

Cheat Sheet: Servers

The essentials.

⏱ 2 min read▶ Video at 1:42:03🎓 Free
Watch this lesson in the MCP courseWatch on YouTube ↗Full MCP course

Here's everything you need to build a server, on one page. Pause here whenever you need a reminder.

Cheat Sheet: Servers
From the video: Cheat Sheet: Servers
  • One page
  • Server essentials
  • Pause anytime

Server cheat sheet

Create a server with MCP server. Add tools, resources, and prompts with decorators. Raise tool error for clear errors. Use the context for elicitation and progress. And run it with standard IO, or streamable HTTP.

TaskCode
CreateMCPServer("name", instructions=...)
Tool@mcp.tool()
Resource@mcp.resource("policy://{name}")
Prompt@mcp.prompt()
Errorraise ToolError("...")
Ask / progressctx.input_responses, ctx.report_progress
Runmcp.run() or transport="streamable-http"

Server habits

Write clear docstrings, because the model reads them. Use type hints, because they become the schema. Log to standard error. And keep each tool small and focused.

keyvalue
Docstringsthe model reads them
Type hintsbecome the schema
Logsstderr
Toolssmall, focused

Summary

Decorators for tools, resources, and prompts, tool error for errors, and run for transports. Next, the client cheat sheet.

Key takeaways
  • @mcp.tool()
  • ToolError
  • mcp.run()
Next up: Cheat Sheet: Clients — the essentials