Module 3 of 10, lesson 4 of 5
Practice
Tools and MCP
Write the code
Runs in your browser, with no install, account or API key. The model is scripted, so the results are repeatable.
// registry: { name: { schema, run } }async function execute(block, registry) { const tool = registry[block.name]; const output = await tool.run(block.input); return { type: 'tool_result', tool_use_id: block.id, content: JSON.stringify(output) };}module.exports = { execute };
Repair the agentHarden the tool dispatcher
Open in the editorfunction makeRefundTool(pay) { return async function refund({ key, order, amount }) { const receipt = await pay({ order, amount }); return { status: 'refunded', receipt }; };}module.exports = { makeRefundTool };
Give the agent a skillMake refunds idempotent
Open in the editor// tools: { name: { description, inputSchema, run } }async function handle(request, tools) { // TODO: tools/list, tools/call, errors, notifications return null;}module.exports = { handle };
Give the agent a skillWrite a small MCP handler
Open in the editorRunning project
Running project: define three tools for the refund agent: read an order, check the policy, issue a refund. Write their JSON schemas and three useful error messages. Work out which one must be idempotent, and how.
Practice
- MCP labs KodeKloud
Practice environment that goes with the video above. - Build an MCP server Model Context Protocol
The official step-by-step tutorial. - Model Context Protocol Course Hugging Face
Free course with theory units and hands-on units, built with Anthropic. - MCP: Build Rich-Context AI Apps DeepLearning.AI
Short course on building MCP servers and clients.
Some of these need a free account or an API key, which may be paid.