While Claude Skills offer incredible flexibility for agent-driven workflows, sometimes you need absolute, programmatic control over a task. This is where MCP (Model Context Protocol) Tools excel. MCP Tools are a powerful alternative to Skills, designed for when you need a well-defined, unambiguous API for the AI to call.
This lesson demonstrates how to build a custom compress MCP tool from scratch. You'll learn how to convert a standard CLI script into a tool with a strict input schema using Zod, providing clear instructions for the AI on how to format arguments. We'll then contrast this with the more abstract, natural-language approach of a Skill to help you understand the ideal use case for each.
Workflow demonstrated in this lesson:
- Convert a Script to a Tool: Refactor a standalone TypeScript script into a function that can be used within an MCP tool.
- Define a Strict Schema: Use the
mcpezlibrary and Zod to define a tool's name, description, and a precise input schema. - Guide the AI: Add detailed descriptions to your schema fields to ensure the AI provides correctly formatted arguments.
- Register the MCP Server: Use the
claude mcp addcommand to make your new tool available to the agent within your project. - See it in Action: Watch as Claude correctly interprets a natural language request, matches it to your tool, and calls it with the exact arguments you defined.
Key benefits:
- Programmatic Precision: Gain absolute control over tool inputs and execution with strongly-typed schemas.
- Clear Separation of Concerns: Keep complex logic inside your code and provide the AI with a simple, clear API to call.
- Improved Reliability: Reduce ambiguity and hallucinations by giving the agent a strict contract to follow.
- Make Informed Decisions: Understand the fundamental trade-offs between the rigid control of MCP Tools and the flexible reasoning of Skills.
Summary
This lesson clarifies the distinction between Claude Code's programmatic MCP Tools and its natural language-based Skills. MCP Tools are ideal for single-purpose, precise automations where you need absolute control. They are defined in code with a strict input schema (using Zod) that acts as a rigid API for the AI to call. Skills, in contrast, are defined in Markdown and provide a more abstract context, giving the agent greater flexibility to reason about and execute complex, multi-step plans. The video demonstrates this by building a compress MCP tool, showing how to define its schema and descriptions to guide the AI in generating the correct arguments. This makes MCP Tools the right choice for well-defined, repeatable tasks, while Skills are better for workflows that require more dynamic, agent-driven problem-solving.
Prompts
Terminal Commands
Code Snippets
The core of the lesson is the MCP tool definition in index.ts. It uses the tool function from mcpez to define the tool's name, description, Zod schema for inputs, and the callback function that executes the logic.
