noopurtiwari01/python-based-mcp-server
If you are the rightful owner of python-based-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This project is a Python-based Model Context Protocol (MCP) server that provides tools for interacting with public APIs for weather and books.
get_forecast
Get daily weather forecast for a location.
get_location
Get location details for a city.
get_current_weather
Get current weather conditions for a location.
search_books
Search for books by title or author.
get_book_details
Get details for a book by its Open Library ID.
get_author_details
Get details for an author by their Open Library Author ID.
search_authors
Search for authors by name and get their Open Library Author IDs.
Python-Based MCP Project
Note: This project was developed on a macOS machine. The package manager uv was installed using Homebrew:
brew install uv
uv is a fast Python package manager and build tool, designed as a drop-in replacement for pip and virtualenv. It enables quick environment setup and dependency management.
This project provides a set of tools exposed via a FastMCP server, allowing you to interact with public APIs for weather and books (Open Library) using simple tool calls.
Quickstart with uv and Virtual Environments
-
Initialize the project and create a virtual environment:
uv init uv venv source .venv/bin/activate # or 'source .venv/bin/activate.fish' for fish shell
-
Install dependencies:
uv add "mcp[cli]" httpx
-
Run the MCP server in development mode:
mcp dev main.py
Project Structure
main.py
— Entry point. Registers and exposes all tools via FastMCP.weather_tools.py
— Contains weather-related tools using the Open-Meteo API.open_library_tools.py
— Contains book and author tools using the Open Library API.defaults.py
— Stores API base URLs and configuration.pyproject.toml
— Project dependencies and metadata.
Registered Tools
Weather Tools (weather_tools.py
)
- get_forecast(latitude: float, longitude: float): Get daily weather forecast for a location.
- get_location(city_name: str): Get location details (latitude, longitude, etc.) for a city.
- get_current_weather(latitude: float, longitude: float): Get current weather conditions for a location.
Open Library Tools (open_library_tools.py
)
- search_books(query: str, author: str = ""): Search for books by title or author.
- get_book_details(olid: str): Get details for a book by its Open Library ID (OLID).
- get_author_details(author_id: str): Get details for an author by their Open Library Author ID.
- search_authors(name: str): Search for authors by name and get their Open Library Author IDs.
Adding More Tools
To add more APIs, create a new file (e.g., news_tools.py
), define your tools, and register them in main.py
using the same pattern.
References
Author: Noopur License: MIT