0Pricing
MCP Academy · Lesson

Test, Inspect & Harden

Validate with Inspector and lock down access.

Test, Inspect & Harden is a free MCP Academy lesson on CoddyKit — lesson 3 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.

From Working to Trustworthy

Your server runs, but is it ready for real use? Now you test, inspect, and harden it so it behaves under pressure and bad input. 🛡️

Smoke Test First

Start with a quick smoke test: does the server boot and list its tools without errors? Catching a broken start early saves hours of confusion.

Open the Inspector

Launch the MCP Inspector with the dev command. It gives you a visual panel to click through every tool, resource, and prompt by hand.

# In your project folder:
# uv run mcp dev server.py

Click Each Tool

In the Inspector, call each tool with sample inputs. Seeing the live result confirms the wiring works before any AI client ever connects.

Read a Resource

Try fetching a resource by its uri in the Inspector. If the right note comes back, your path variable and read logic are doing their job.

Test the Bad Path

Feed each tool obviously bad input: empty strings, huge numbers, missing fields. A solid server answers with a clear error, never a crash.

Return Errors, Not Stack Traces

Wrap risky work and raise a clean message. The model can read a friendly error and recover, but a raw traceback only confuses it.

@mcp.tool()
def get_note(note_id: int) -> str:
    if note_id < 1:
        raise ValueError("note_id must be a positive integer")
    return read(note_id)

Validate Before Acting

Check arguments at the top of each tool. Rejecting bad values early keeps your backend safe and your error messages specific and useful.

Apply Least Privilege

Give each tool only the access it truly needs. Least privilege means a search tool can read but never delete, shrinking the blast radius.

Guard Destructive Actions

For anything irreversible, demand a clear flag or confirmation. A guard on delete stops a hasty model call from wiping real data. ⚠️

@mcp.tool()
def delete_note(note_id: int, confirm: bool = False) -> str:
    if not confirm:
        return "Set confirm=True to delete."
    remove(note_id)
    return "Deleted."

Add Automated Tests

Write a few pytest cases that call your functions directly. Automated checks let you change code later and instantly know nothing broke.

Quick Check

Let us confirm the hardening idea.

Recap

You tested with the Inspector, validated inputs, applied least privilege, and guarded destructive actions. Your server is now ready for the real world. 🎯

Frequently asked questions

Is the “Test, Inspect & Harden” lesson free?

Yes — the full text of “Test, Inspect & Harden” 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 “Test, Inspect & Harden”?

Validate with Inspector and lock down access. 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 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Test, Inspect & Harden” 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. Scope the Project & Tools
  2. Implement Tools, Resources & Prompts
  3. Test, Inspect & Harden
  4. Document & Publish the Server
← Back to MCP Academy