0Pricing
MCP Academy · Lesson

Set Log Levels at Runtime

Let clients turn verbosity up or down.

Set Log Levels at Runtime is a free MCP Academy lesson on CoddyKit — lesson 4 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.

Verbosity on Demand

Sometimes a user wants quiet logs, sometimes deep detail. MCP lets the client set a log level at runtime instead of restarting the server.

The setLevel Request

The client sends a logging/setLevel request naming the lowest level it wants. This is a request, so the server replies to confirm.

{"method": "logging/setLevel",
 "params": {"level": "warning"}}

Declare the Capability

A server only receives setLevel if it advertised the logging capability during the initialize handshake. FastMCP enables this for you.

A Floor, Not a List

The chosen level is a threshold. Setting it to warning means warning and everything more severe gets through; quieter messages are dropped.

How Filtering Works

After setLevel, the server compares each log's severity against the floor. Anything below the threshold is simply not sent to that client.

# floor = warning  -> info and debug are dropped

Turn the Dial Up

To debug a tricky run, a client can set the level to debug. Now every message, even the noisy traces, streams back for inspection.

{"method": "logging/setLevel",
 "params": {"level": "debug"}}

Turn the Dial Down

For a calm production view, set it to error. Only failures arrive, keeping the user's screen free of routine chatter.

{"method": "logging/setLevel",
 "params": {"level": "error"}}

Per-Session Setting

The level applies to that client's session. Changing it later just moves the floor; it does not need a fresh connection or reload.

A Sensible Default

Before any setLevel arrives, the server uses its own default floor, often info. Always log richly and let the client choose what to keep.

Why It Helps

Runtime levels mean you ship one build that is quiet by default yet ready to go verbose the moment a user reports a hard-to-find bug.

Pairs With Your Logs

This dial controls the same ctx.info and ctx.debug calls you write. The client picks the floor; your code just logs at honest levels.

await ctx.debug("seen only when floor is debug")

Quick Check

Reason about what a chosen log level actually filters.

Recap: Log Levels

You learned that logging/setLevel sets a runtime floor, how filtering drops quieter messages, and why this keeps one build flexible. Excellent!

Frequently asked questions

Is the “Set Log Levels at Runtime” lesson free?

Yes — the full text of “Set Log Levels at Runtime” 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 “Set Log Levels at Runtime”?

Let clients turn verbosity up or down. 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 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Set Log Levels at Runtime” 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. Send Progress for Long Tasks
  2. Handle Cancellation Requests
  3. Structured Logging to the Client
  4. Set Log Levels at Runtime
← Back to MCP Academy