What is Mcp Server?
Mcp Server is a Multi-Functional Command Processor that provides an API for retrieving the current dollar exchange rate, weather forecasts for specified cities, and weekly news summaries.
How to use Mcp Server?
To use Mcp Server, clone the repository, set up a virtual environment, install dependencies, and run the server. You can then access the API endpoints to get the desired information.
Key features of Mcp Server?
- Dollar Exchange Rate: Retrieve the current exchange rate of the dollar to the ruble.
- Weather Forecast: Get the current weather in a specified city.
- News Summary: Access news articles from the past week.
Use cases of Mcp Server?
- Checking the latest dollar exchange rate for financial planning.
- Obtaining weather updates for travel or daily activities.
- Staying informed with the latest news summaries.
FAQ from Mcp Server?
- Can I use Mcp Server for any city?
Yes! You can request weather information for any city by specifying its name in the API call.
- Is Mcp Server free to use?
Yes! Mcp Server is open-source and free to use.
- What programming language is Mcp Server written in?
Mcp Server is written in Python.
MCP (Multi-Functional Command Processor) сервер предоставляет API для получения текущего курса доллара, прогноза погоды в заданном городе и сводки новостей за последнюю неделю.
Возможности
- Курс доллара: Получение текущего курса доллара к рублю.
- Прогноз погоды: Получение текущей погоды в указанном городе.
- Сводка новостей: Получение новостей за последнюю неделю.
Установка и запуск
Предварительные требования
- Python 3.7 или выше
- Установленный
pip
Установка
-
Клонируйте репозиторий:
git clone https://github.com/VenGr0/mcp-server.git cd mcp-server
-
Создайте виртуальное окружение и активируйте его:
python -m venv venv source venv/bin/activate # Для Linux/MacOS venv\Scripts\activate # Для Windows
-
Установите зависимости:
pip install -r requirements.txt
Запуск сервера
Запустите сервер:
python server.py
Сервер будет доступен по адресу http://127.0.0.1:5000
.
Запуск тестов
Для запуска тестов выполните:
pytest tests/test_server.py
Использование API
Получение курса доллара
Запрос:
GET /exchange_rate
Ответ:
{
"usd_rate": 75.50
}
Получение прогноза погоды
Запрос:
GET /weather?city=Moscow
Ответ:
{
"weather": "clear sky",
"temperature": 20
}
Получение сводки новостей
Запрос:
GET /news
Ответ:
{
"articles": [
{
"title": "Новость 1",
"description": "Описание новости 1",
"url": "https://example.com/news1"
},
{
"title": "Новость 2",
"description": "Описание новости 2",
"url": "https://example.com/news2"
}
]
}
Подключение клиента
Пример клиента на Python:
import requests
BASE_URL = 'http://127.0.0.1:5000'
def get_exchange_rate():
response = requests.get(f'{BASE_URL}/exchange_rate')
return response.json()
def get_weather(city):
response = requests.get(f'{BASE_URL}/weather?city={city}')
return response.json()
def get_news():
response = requests.get(f'{BASE_URL}/news')
return response.json()
if __name__ == '__main__':
print(get_exchange_rate())
print(get_weather('Moscow'))
print(get_news())