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

Cheat Sheet: Clients

The essentials.

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

And here's the client side, on one page. Everything a host needs to use any server.

Cheat Sheet: Clients
From the video: Cheat Sheet: Clients
  • One page
  • Client essentials
  • Any server

Client cheat sheet

Connect with client, using a server object, standard IO parameters, or a URL. List and call tools. Read resources, and get prompts. Check is error on results. And pass callbacks for elicitation and progress.

TaskCode
Connectasync with Client(server or url) as c
Toolsc.list_tools(), c.call_tool(name, args)
Resourcesc.read_resource(uri)
Promptsc.get_prompt(name, args)
Errorsresult.is_error
Callbackselicitation_callback, progress_callback

Client habits

Use one client per server. Give the model only the tools it needs. Pass tool errors back to the model. And always let the user approve risky actions.

keyvalue
Serversone client each
Toolsonly what's needed
Errorsback to the model
Risky actionsuser approves

Summary

Connect, list, call, read, and check is error. Next, common mistakes.

Key takeaways
  • Client(...)
  • call_tool
  • is_error
Next up: Common Mistakes — and fixes