0Pricing
MCP Academy · Lección

Probar, inspeccionar y reforzar

Valide con Inspector y restrinja el acceso.

Probar, inspeccionar y reforzar es una lección gratuita de MCP Academy en CoddyKit. Esta es la lección 3 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de MCP Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de MCP Academy incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

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. 🎯

Preguntas frecuentes

¿La lección «Probar, inspeccionar y reforzar» es gratis?

Sí — el texto completo de «Probar, inspeccionar y reforzar» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de MCP Academy, actualiza a CoddyKit PRO. El curso de MCP Academy incluye 4 lecciones en total.

¿Qué aprenderé en «Probar, inspeccionar y reforzar»?

Valide con Inspector y restrinja el acceso. Practicas MCP Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar MCP Academy?

No se requiere experiencia previa. MCP Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 3 de 4.

¿Cuánto tiempo toma la lección «Probar, inspeccionar y reforzar»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de MCP Academy?

Sí. Cada lección de MCP Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Delimitar el proyecto y las herramientas
  2. Implementar herramientas, recursos y prompts
  3. Probar, inspeccionar y reforzar
  4. Documentar y publicar el servidor
← Volver a MCP Academy