Skip to main content
Glama
adri14gl

MCP Weather and Currency Assistant

by adri14gl

MCP를 활용한 금융 및 날씨 어시스턴트

로컬 MCP 서버와 OpenAI Responses API를 결합한 명령줄 애플리케이션입니다. 이 어시스턴트는 자연어 쿼리를 이해하고, 서버에서 게시한 도구를 자동으로 발견하여 실행함으로써 현재 환율 및 기상 데이터를 조회합니다.

이 프로젝트는 FastMCP, ExchangeRate-API 및 Open-Meteo를 통합합니다. 또한 체인 호출을 지원합니다. 예를 들어, 도시 이름을 좌표로 변환한 후 현재 날씨나 예보를 조회할 수 있습니다.

기능

  • ISO 4217 코드를 사용한 통화 간 금액 변환

  • 기준 통화의 환율 조회

  • 도시 지오코딩

  • 현재 날씨 및 1~7일 예보 조회

  • 클라이언트의 MCP 도구 자동 발견

  • 스페인어 대화형 터미널 인터페이스

  • OpenAI 호출 시 일시적 오류에 대한 재시도 및 네트워크 오류 제어

Related MCP server: Weather MCP Server

아키텍처

Usuario
  |
  v
CLI (main_client.py)
  |
  v
Cliente OpenAI Responses <----> Servidor MCP local (FastMCP)
                                      |
                                      +--> ExchangeRate-API
                                      +--> Open-Meteo

서버는 기본적으로 HTTP 전송을 통해 http://127.0.0.1:8000/mcp/에 노출됩니다. 클라이언트는 해당 URL에 연결하여 제공되는 5가지 도구를 로드하고, 그 결과를 모델에 전달하여 최종 응답을 생성합니다.

MCP 도구

도구

설명

convert_currency

현재 환율을 사용하여 두 통화 간 금액을 변환합니다.

get_exchange_rates

기준 통화의 선택된 통화 목록에 대한 환율을 반환합니다.

geocode_city

도시의 좌표, 국가 및 시간대를 가져옵니다.

get_current_weather

현재 온도, 체감 온도, 습도, 바람 및 기상 상태를 조회합니다.

get_weather_forecast

향후 며칠 동안의 온도, 강수 확률 및 기상 상태를 반환합니다.

요구 사항

  • Python 3.10 이상

  • Responses API에 액세스할 수 있는 OpenAI API 키

  • OpenAI 및 외부 API 조회를 위한 인터넷 연결

  • ExchangeRate-API 키는 선택 사항입니다. 없으면 공개 엔드포인트를 사용합니다.

설치

저장소를 클론하고 가상 환경을 생성합니다:

git clone <URL_DEL_REPOSITORIO>
cd <NOMBRE_DEL_REPOSITORIO>
python -m venv .venv

가상 환경을 활성화합니다:

# Windows PowerShell
.venv\Scripts\Activate.ps1

# Windows (cmd)
.venv\Scripts\activate.bat

# macOS/Linux
source .venv/bin/activate

의존성을 설치합니다:

python -m pip install -r requirements.txt

설정

예제 설정 파일을 복사하고 자격 증명을 입력합니다. .env 파일은 로컬에 있으며 저장소에 포함되어서는 안 됩니다:

Copy-Item .env.example .env

macOS 또는 Linux에서:

cp .env.example .env

결과 파일에는 다음 변수가 포함되어야 합니다:

OPENAI_API_KEY=tu_clave_de_openai

# Opcional. Si se deja vacío se usa el endpoint abierto de ExchangeRate-API.
API_KEY_EXCHANGE=

# Opcionales.
MCP_HOST=127.0.0.1
MCP_PORT=8000
OPENAI_MODEL=gpt-4o-mini

OPENAI_API_KEY는 클라이언트 사용에 필요합니다. Open-Meteo는 자격 증명이 필요하지 않습니다. 애플리케이션은 외부 HTTP 호출에 10초 타임아웃을 사용합니다.

사용법

서버와 클라이언트는 별도의 터미널에서 실행됩니다. 먼저 서버를 시작합니다:

python main_server.py

다른 터미널에서 가상 환경을 활성화한 상태로 클라이언트를 시작합니다:

python main_client.py

테스트

단위 테스트는 OpenAI나 외부 API를 호출하지 않고 환율 로직, 일기 예보, WMO 코드 및 오류 처리를 다룹니다:

python -m pip install -r requirements-dev.txt
python -m pytest

그런 다음 다음과 같은 쿼리를 작성할 수 있습니다:

Convierte 100 USD a EUR
¿Cuál es el clima actual en Madrid?
Dame la previsión del tiempo para Nueva York durante 5 días
¿Qué coordenadas tiene Tokio?

CLI에서 사용 가능한 명령어:

명령어

동작

/ayuda

도구와 쿼리 예제를 표시합니다.

/monedas

일반적인 통화 코드를 표시합니다.

/salir

클라이언트를 종료합니다.

프로젝트 구조

.
├── .env.example          # Plantilla de configuración local
├── .gitignore            # Archivos excluidos del repositorio
├── client/
│   ├── cli_interface.py    # Interfaz interactiva de terminal
│   └── openai_client.py    # Orquestación OpenAI + MCP
├── config/
│   └── settings.py         # Variables de entorno y endpoints
├── server/
│   ├── api_clients.py      # Clientes HTTP para las APIs externas
│   ├── currency_tools.py   # Herramientas de divisas
│   ├── geocoding_tools.py  # Herramienta de geocodificación
│   ├── mcp_server.py       # Servidor FastMCP y registro de herramientas
│   └── weather_tools.py    # Herramientas meteorológicas
├── main_client.py          # Punto de entrada del cliente
├── main_server.py          # Punto de entrada del servidor
├── requirements.txt        # Dependencias de Python
└── README.md

외부 API

결과는 이러한 서비스의 가용성, 제한 및 이용 약관에 따라 달라집니다. OpenAI 사용은 계정 및 구성된 모델에 따라 비용이 발생할 수 있습니다.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A server that integrates the MCP library with OpenAI's API, allowing users to interact with various tools, such as the weather tool, through natural language queries.
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables users to get current weather conditions and forecasts for any city through OpenWeatherMap API integration. Designed as a sample MCP server for the Puch AI Hackathon with basic weather querying capabilities.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    A MCP server for querying real-time weather information for any city worldwide using the free Open-Meteo API, supporting CLI and integration with AI clients like Claude and Cursor.
    17 npm
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A proof-of-concept MCP server that provides weather information using the Open-Meteo API, with tools for greeting, getting weather by coordinates, and by location name.
    -