LESSON 5 of 5//Agentic CLI & MCP
Building your own MCP tools
You can build custom MCP servers that expose your own tools to AI agents. This lets you create domain-specific capabilities — querying your database, deploying code, managing infrastructure, or anything else you can script.
Creating a basic MCP serverzsh // interactive
# Scaffold a new MCP server project
➜~mkdir my-mcp-server && cd my-mcp-server
➜~npm init -y
➜~npm install @modelcontextprotocol/sdk zod
# Create the server entry point
➜~touch src/index.ts
Server code structurezsh // interactive
// src/index.ts — a minimal MCP server
import { McpServer } from '@modelcontextprotocol/sdk/server';
import { z } from 'zod';
const server = new McpServer({ name: 'my-tools' });
server.tool('deploy', { env: z.enum(['staging','prod']) },
async ({ env }) => {
// Your deployment logic here
return { content: [{ type: 'text', text: `Deployed to ${env}` }] };
}
);
Start simple
Begin with a single tool that wraps a CLI command you run frequently. Once that works, expand with more tools. MCP servers are just Node.js programs — anything you can code, you can expose as an AI tool.
PRACTICE//Try the commands from this lesson
INTERACTIVE_TERMINAL//sandbox
Practice terminal — try the commands from this lesson!
Type 'help' for available commands. Tab completion not available in simulator.
Try: