0Pricing
MCP Academy · Lesson

Async Tools That Don't Block

Use async I/O to serve many calls at once.

Async Tools That Don't Block is a free MCP Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the MCP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

One Slow Tool, Everyone Waits

If a tool does slow work synchronously, it blocks the whole server, so every other call has to wait its turn. ⏳

Most Slowness Is Waiting

A tool that calls a database or API spends most of its time on I/O, just waiting for a reply rather than using the CPU.

Async Frees the Server

Marking a tool async lets the server handle other requests during that wait, instead of sitting idle on one call.

Define an async def Tool

Declare your handler with async def and FastMCP will await it, so the event loop can serve other work meanwhile.

@mcp.tool()
async def fetch(city: str) -> str:
    ...

await Your I/O Calls

Inside an async tool, use await on async libraries so each pause hands control back to the loop instead of freezing it.

data = await client.get(url)
return data.text

Use Async-Native Libraries

Reach for clients like httpx or asyncpg. They are built to await, unlike blocking libraries that stall the whole loop.

Never Block the Event Loop

A plain time.sleep or a heavy loop blocks every other request. In async code, blocking calls quietly freeze the server.

Offload Heavy CPU Work

For real CPU crunching, push it to a thread with asyncio.to_thread so the event loop stays free to serve calls.

result = await asyncio.to_thread(crunch, data)

Run Calls Concurrently

Need several fetches at once? asyncio.gather runs awaitables together, finishing far faster than awaiting each in turn.

a, b = await asyncio.gather(get(x), get(y))

Add a Timeout to Awaits

Wrap slow awaits in a timeout so one stuck upstream cannot tie up a request forever and starve the server.

Async Scales Concurrency

With async I/O, one process can juggle many in-flight calls at once, so your server stays responsive under real load.

Quick Check

Why does async I/O help a busy MCP server?

Recap: Don't Block

You made tools async, awaited I/O, offloaded CPU work, and ran calls together, so one slow tool no longer freezes the server. 🚀

Frequently asked questions

Is the “Async Tools That Don't Block” lesson free?

Yes — the full text of “Async Tools That Don't Block” is free to read here on the web, and the MCP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the MCP Academy course, upgrade to CoddyKit PRO.

What will I learn in “Async Tools That Don't Block”?

Use async I/O to serve many calls at once. You practise MCP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start MCP Academy?

No prior experience is required. MCP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Async Tools That Don't Block” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this MCP Academy lesson?

Yes. Every MCP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Async Tools That Don't Block
  2. Concurrency & Backpressure
  3. Trim Token-Heavy Results
  4. Scale Horizontally with Sessions
← Back to MCP Academy