Getting started
Python
Want to teach an AI how to check the weather? You're in the right place. This guide walks you through building a simple tool using FastMCP, which makes it incredibly easy to create MCP (Model Context Protocol) servers that let your code talk directly to AI assistants.
We'll use Claude Desktop as an example AI client in this guide because it has built-in support for MCP — but the tool you build can work with any AI that understands MCP, like ChatGPT Desktop or Raycast AI, for example.
You'll need to use Hackatime to track your coding time. Hackatime works on all major code editors.
Set it up with the instructions here: https://hackatime.hackclub.com
In short, MCP (Model Context Protocol) servers allow AI to connect to real tools. Think of it as USB ports for AI apps.
Here's how it works:
We'll be writing this in Python. You can install Python from https://python.org/ (make sure to get Python 3.9 or higher).
Install FastMCP, which makes building MCP servers much easier:
I'm going to call my project mcp-weather-server
.
If python3
doesn't work on your system, try python
. On some systems, both commands point to the same Python installation.
Create a file called mcp_weather_server.py
(note the underscores - this avoids import conflicts). We'll build this step-by-step.
At the very top of your mcp_weather_server.py
file, add this line:
This tells the system how to run your script and makes it executable on all platforms.
Note: We use python3
instead of node
since this is a Python project. The shebang ensures your script runs with the correct Python interpreter.
With FastMCP, you can define your tool function and register it in one step using the @mcp.tool
decorator:
If you need to add additional fields, just expand the parameters of the function using Field()
. For example:
Add a main function and entry point to run your server:
That's it! Your complete FastMCP server is ready. Here's the full code:
MCP comes with a really cool inspector. To run it, simply enter the following command:
You'll get a URL in the console that you can open. Simply click the connect button on the bottom left!
FastMCP makes it incredibly easy to install your server in Claude Desktop. Just run this single command:
This command:
About the --with flag: This tells FastMCP to install the requests
library that your weather server needs. You can add multiple dependencies: --with requests --with pandas
Need environment variables? Add them with the --env
flag: --env API_KEY=your-key
Now restart Claude Desktop completely and try it out!
If all goes well, Claude should show the result returned by your tool. The FastMCP CLI handled all the configuration automatically!
To share your MCP server with the world, you'll need to publish it to PyPI (Python Package Index). Create a pyproject.toml
file:
Then publish it:
Once published, others can install it directly from PyPI:
This makes your tool easily installable by anyone!
Now that you've got the basics, try branching out. Your AI client can use any tool — as long as you define inputs and return something usable.
Here are some inspiration, but you should come up with something else!
To submit you must:
Your README should include installation instructions like:
If you need any help, reach out in the #toolsmith Slack channel!
Once you've built your MCP tool and tested it, you can submit it to earn your $10 in AI credits!
Submit Your Tool