
How to Build a Custom MCP Tool in Under 10 Min
Your AI agent can browse the web, read files, and call APIs. But what if you need it to query your database or call your internal service? That's where custom MCP tools come in. MCP (Model Context Protocol) lets you expose any Python function as a tool that AI agents can discover and call. Here's how to build one in under 10 minutes. Install FastMCP FastMCP is the fastest way to create MCP-compatible tools. Install it: pip install fastmcp The Code Create a file called my_tools.py : from fastmcp import FastMCP mcp = FastMCP ( name = " MyTools " ) # Sample data — swap this with your real database USERS = { " u001 " : { " name " : " Alice Chen " , " role " : " engineer " , " team " : " platform " }, " u002 " : { " name " : " Bob Park " , " role " : " designer " , " team " : " growth " }, " u003 " : { " name " : " Carol Silva " , " role " : " engineer " , " team " : " infra " }, } @mcp.tool def lookup_user ( user_id : str ) -> dict : """ Look up an employee by their user ID. Returns name,
Continue reading on Dev.to Tutorial
Opens in a new tab




