Skip to main content
Glama
akdrione

Weather MCP Server

by akdrione

날씨 MCP 서버

OpenAPI를 지원하는 날씨 데이터용 모델 컨텍스트 프로토콜(MCP) 서버입니다. 이 서버는 OpenWeatherMap API에서 날씨 정보를 제공하며 MCP를 통해 LLM 에이전트가 사용할 수 있습니다.

기능

  • LLM 에이전트 통합을 위한 MCP stdio 전송

  • OpenAPI 3.0 사양을 갖춘 HTTP REST API

  • 4가지 날씨 도구:

    1. 도시별 현재 날씨 가져오기

    2. 좌표별 현재 날씨 가져오기

    3. 날씨 예보 가져오기 (5일, 3시간 간격)

    4. 기온 범위 요약 가져오기

  • API 키 없이 테스트할 수 있는 모의 데이터 지원

  • 완전한 타입 안전성을 갖춘 TypeScript 구현

Related MCP server: mcp-openweather

설치

cd weather-mcp-server
npm install
npm run build

사용법

1. MCP 서버 (stdio 전송)

LLM 에이전트를 위해 MCP 서버를 실행합니다:

npm start

또는 개발 모드에서 실행:

npm run dev

2. OpenAPI를 포함한 HTTP 서버

REST API와 함께 HTTP 서버를 실행합니다:

npm run dev:http

서버는 http://localhost:3000에서 시작되며 다음을 제공합니다:

  • /health - 상태 확인 엔드포인트

  • /openapi - OpenAPI 사양

  • /api/v1/weather/current/{city} - 도시별 현재 날씨

  • /api/v1/weather/current/coordinates - 좌표별 현재 날씨

  • /api/v1/weather/forecast/{city} - 날씨 예보

3. 구성

OpenWeatherMap API 키를 설정합니다 (선택 사항 - 제공되지 않으면 모의 데이터가 사용됨):

export OPENWEATHER_API_KEY=your_api_key_here

또는 .env 파일을 생성합니다:

OPENWEATHER_API_KEY=your_api_key_here

MCP 도구

서버는 다음과 같은 MCP 도구를 제공합니다:

도구 이름

설명

매개변수

weather_get_current_by_city

도시별 현재 날씨 가져오기

city: string

weather_get_current_by_coords

좌표별 현재 날씨 가져오기

latitude: number, longitude: number

weather_get_forecast

날씨 예보 가져오기

city: string, days?: number (1-10, 기본값: 5)

weather_get_temperature_range

기온 범위 요약 가져오기

city: string

API 엔드포인트

HTTP REST API

모든 엔드포인트는 다음 구조의 JSON을 반환합니다:

{
  "success": true,
  "data": { ... }
}

1. 도시별 현재 날씨

GET /api/v1/weather/current/{city}

예시:

curl http://localhost:3000/api/v1/weather/current/London

2. 좌표별 현재 날씨

GET /api/v1/weather/current/coordinates?lat={latitude}&lon={longitude}

예시:

curl "http://localhost:3000/api/v1/weather/current/coordinates?lat=51.5074&lon=-0.1276"

3. 날씨 예보

GET /api/v1/weather/forecast/{city}?days={days}

예시:

curl "http://localhost:3000/api/v1/weather/forecast/New%20York?days=3"

테스트

테스트 모음을 실행합니다:

npm test

디버깅을 위해 MCP 인스펙터를 실행합니다:

npm run inspect

프로젝트 구조

weather-mcp-server/
├── src/
│   ├── index.ts              # MCP stdio server
│   ├── http-server.ts        # HTTP server with OpenAPI
│   ├── types/
│   │   └── weather.ts        # TypeScript types and Zod schemas
│   ├── utils/
│   │   └── weather-client.ts # OpenWeatherMap API client
│   └── tools/
│       └── weather-tools.ts  # MCP tool definitions
├── dist/                     # Compiled JavaScript
├── test/
│   └── test.js              # Test suite
├── package.json
├── tsconfig.json
└── README.md

의존성

  • @modelcontextprotocol/sdk - TypeScript용 MCP SDK

  • express - HTTP 서버 프레임워크

  • axios - API 호출용 HTTP 클라이언트

  • zod - 스키마 유효성 검사

  • typescript - TypeScript 컴파일러

라이선스

MIT

Related MCP Connectors

Related MCP Servers

  • F
    license
    B
    quality
    D
    maintenance
    Enables AI agents to retrieve real-time weather conditions and forecasts via OpenWeatherMap API. Supports interactive weather queries and travel planning through MCP tools, resources, and prompts.
    2
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    Wraps the OpenWeatherMap API to provide weather data through MCP, enabling AI agents to query current conditions, forecasts, and other weather information via natural language.
    5 npm
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides weather data from WeatherAPI.com through MCP, enabling AI agents to query current conditions and forecasts via natural language.
    5 npm
    MIT
  • F
    license
    B
    quality
    D
    maintenance
    Provides real-time weather information for cities worldwide using the OpenWeatherMap API, accessible through natural language queries via the MCP protocol.
    1
    -