MCP · Lesson 115 of 120
Cheat Sheet: Servers
The essentials.
Here's everything you need to build a server, on one page. Pause here whenever you need a reminder.

- 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.
| Task | Code |
|---|---|
| Create | MCPServer("name", instructions=...) |
| Tool | @mcp.tool() |
| Resource | @mcp.resource("policy://{name}") |
| Prompt | @mcp.prompt() |
| Error | raise ToolError("...") |
| Ask / progress | ctx.input_responses, ctx.report_progress |
| Run | mcp.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.
| key | value |
|---|---|
| Docstrings | the model reads them |
| Type hints | become the schema |
| Logs | stderr |
| Tools | small, 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