Skip to main content
Glama
pudileena20-ops

MCP Learning

README.md
# MCP Learning

A simple Python MCP (Model Context Protocol) server built with **FastMCP**, created while learning how MCP servers work.

## What this project does

This server exposes two tools that can be called through an MCP client (like the MCP Inspector):

- **`get_weather(city)`** — returns a sample weather response for a given city
- **`add_numbers(a, b)`** — returns the sum of two numbers

## Tech used

- Python
- [FastMCP](https://github.com/modelcontextprotocol/python-sdk) (`mcp.server.fastmcp`)
- [MCP Inspector](https://github.com/modelcontextprotocol/inspector) for testing

## How to run

1. Install dependencies:
   ```
   pip install "mcp[cli]"
   ```

2. Run the server directly:
   ```
   py server.py
   ```

3. Or launch it through the Inspector (recommended for testing):
   ```
   npx @modelcontextprotocol/inspector py server.py
   ```

4. In the Inspector UI, click **Connect**, go to the **Tools** tab, click **List Tools**, and try out `get_weather` or `add_numbers`.

## What I learned

- Setting up a basic MCP server using FastMCP
- Fixing a Windows PATH issue (`python` not recognized → use `py` instead)
- Connecting a Node.js-based Inspector to a Python server as a subprocess
- Debugging simple typos in tool decorators (`@mcp.tool()`)

## Next steps

- Add more tools
- Explore MCP resources and prompts
- Connect this server to a real MCP client