MCP_Server_Practice
0
The MCP Server Practice project is a FastAPI-based server that showcases the integration of AI tools for various functionalities such as math calculations, web search, audio generation, and weather data fetching. It is designed to demonstrate practical implementations using FastMCP and OpenAI technologies.
π§ MCP Server Practice
A modular FastAPI-based server powered by FastMCP, showcasing practical implementations of AI tools, math operations, web search, audio response generation, and external API integration.
π Core Functionalities
π§ Math Utilities
add(a, b)
: Returns the sum of two integers.multiply(a, b)
: Returns the product of two integers.
π€οΈ Weather API Integration
get_weather(city)
: Fetches live weather data for a specified city using the WeatherAPI.
π Web Search (via OpenAI Tools)
web_search(query)
: Performs a live web search using OpenAIβs web search tool and returns a concise result.
π Audio Response Generation
audio_query(text)
: Converts a text query into spoken audio (WAV format) using OpenAIβsgpt-4o
audio capabilities. Audio files are saved automatically to the/audio
folder.
πββοΈ Custom Resource Example
greeting://{name}
: Returns a personalized greeting string using the resource-based route.
π οΈ Built With
- FastMCP: A server interface for tool-based workflows.
- FastAPI: Web framework for high-performance APIs.
- OpenAI: Powering AI-based search, chat, and audio generation.
- WeatherAPI: External API for real-time weather updates.
- Python + dotenv: For scripting and secure environment variable handling.
π» How It Works
Each tool is defined using the @mcp.tool()
decorator, making it accessible as a callable interface for AI agents or CLI tools. The server runs with:
mcp.run(transport="stdio")