Minideas

Idea 9 of 15 · MCP

Build your own MCP server

Write a server in Python with tools, resources and prompts, and see how Claude Code uses each.

server.py@mcp.tool()def get_order(order_id: int):"""Look up an order."""schemanamedescriptioninputMCP Inspectorrun get_order$ claude mcp add shop -- python server.py1231. write it · 2. test it · 3. connect it
1 / 4

Start with a tool

To offer your own service, write a server with the Python SDK: a decorator turns a function into a tool, and its name, docstring and type hints become the tool’s schema. Try each tool in the MCP Inspector, then connect it with claude mcp add.

server.py@mcp.resource("docs://handbook")def handbook():return read("handbook.md")Summarize @shop:docs://handbookClaude Code adds it to the conversation
2 / 4

Resources: data the app pulls in

A resource is read-only data with an address. In the server, @mcp.resource("docs://handbook") publishes what a function returns at that address. In Claude Code, type @ and pick it, @shop:docs://handbook, and it’s added to the conversation without a tool call.

server.py@mcp.prompt()def format(document):return f"Turn {document} into a report…"/shop:format/shop:summarizedocument: returns.mdthe user picks it and fills in the blanks
3 / 4

Prompts: ready-made instructions

A prompt is a tested instruction for a common job. In the server, @mcp.prompt() turns a function into one: its arguments are the blanks, its return value the instruction. In Claude Code it appears in the / menu as /shop:format; fill in the blanks for the same result every time.

MCP server: shoptoolsClaude callsactionsget_order(418)resourcesyou type @read-only data@shop:docs://handbookpromptsyou type /instructions/shop:format
4 / 4

Recap: tools, resources and prompts

So the shop server offers three kinds of things: tools, resources and prompts. They differ in who uses them in Claude Code: Claude calls tools itself; you add resources by typing @; and you run prompts from the / menu. Each carries the server’s name as a prefix.

Swipe the card, or use the arrow keys.

Go deeper

Each card stack gives you the idea. These open resources go into the detail.

Notes on the Claude Partner Network learning path on Anthropic Academy.