This server provides weather information for specified cities.
Retrieve weather data for cities like Fukuoka, Tokyo, Osaka, Moscow, New York, and other cities recognized by the Open-Meteo API.
Uses the
get-weatherendpoint with a requiredcityparameter.Interaction occurs through the Model Context Protocol (MCP).
Can be tested using the MCP Inspector at
http://127.0.0.1:6274.
Used to make HTTP requests to the Open-Meteo API for fetching weather information for various cities
Provides version control functionality for the weather service project, allowing users to clone, commit, and push changes
Enables users to store, share, and collaborate on the weather service project through repositories, pull requests, and issue tracking
Serves as the runtime environment for the weather service, required to execute the MCP server
Used as the programming language for implementing the weather service with type safety
Provides schema validation for the weather data retrieved from the API
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Weather Servicewhat's the weather like in Tokyo today?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP 天気サービス
このリポジトリは、Model Context Protocol (MCP) を使用して天気情報を提供するシンプルなサービスです。複数の都市(福岡、東京、大阪、モスクワ、ニューヨークなど)の天気情報を取得できます。
このプロジェクトは MITライセンス の下で公開されています。
目次
Related MCP server: Weather Query MCP Server
前提条件
このプロジェクトを実行するには、以下のソフトウェアが必要です:
Node.js (バージョン 18 以上)
npm (通常は Node.js とともにインストールされます)
Git
インストール方法
Node.js と npm のインストール
Node.js 公式サイト からインストーラーをダウンロードしてインストールします。
インストールが完了したら、ターミナルで以下のコマンドを実行して確認します:
node -v
npm -vGit のインストール
Git 公式サイト からインストーラーをダウンロードしてインストールします。
インストールが完了したら、ターミナルで以下のコマンドを実行して確認します:
git --versionプロジェクトのセットアップ
新規プロジェクトの作成
新しいディレクトリを作成し、そのディレクトリに移動します:
mkdir my-weather-mcp
cd my-weather-mcpnpm プロジェクトを初期化します:
npm init -y必要なパッケージをインストールします:
npm install @modelcontextprotocol/sdk axios zod typescript @types/node https-proxy-agent
npm install --save-dev ts-nodeTypeScript の設定ファイルを作成します:
npx tsc --inittsconfig.jsonファイルを以下のように編集します:
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"outDir": "./build",
"strict": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}package.jsonファイルのスクリプトセクションを以下のように編集します:
"scripts": {
"build": "tsc && node -e \"import('fs').then(fs => fs.default.chmodSync('build/index.js', '755'))\"",
"start": "node build/index.js",
"inspect": "npx @modelcontextprotocol/inspector build/index.js",
"dev": "ts-node src/index.ts"
}プロジェクトのディレクトリ構造を作成します:
mkdir -p src test既存プロジェクトのクローン
既存のプロジェクトを使用する場合は、以下の手順でクローンします:
git clone https://github.com/terisuke/my-weather-mcp.git
cd my-weather-mcp
npm install使い方
ビルドと実行
プロジェクトをビルドして実行するには、以下のコマンドを使用します:
npm run build && npm run startインスペクターの使用
MCP インスペクターを使用して天気サービスをテストするには、以下のコマンドを実行します:
npm run build && npm run inspectインスペクターが起動すると、ブラウザで http://127.0.0.1:6274 にアクセスして、天気サービスとやり取りできます。
天気情報の取得
インスペクターを使用して、以下の都市の天気情報を取得できます:
福岡
東京
大阪
モスクワ
ニューヨーク
その他の都市も指定できますが、Open-Meteo API で認識される都市名である必要があります。
開発ガイド
ファイル構造
my-weather-mcp/
├── build/ # コンパイルされたJavaScriptファイル
├── src/ # TypeScriptソースコード
│ └── index.ts # メインのアプリケーションコード
├── test/ # テストファイル
├── package.json # プロジェクト設定
├── tsconfig.json # TypeScript設定
└── README.md # このファイルコードの修正
src/index.tsファイルを編集して、機能を追加または修正します。変更をテストするには、以下のコマンドを実行します:
npm run build && npm run inspect変更が正常に動作することを確認したら、変更をコミットします。
GitHubへのアップロード
初めてのGitHubリポジトリ作成
GitHub にアクセスし、アカウントを作成またはログインします。
右上の「+」ボタンをクリックし、「New repository」を選択します。
リポジトリ名(例:
my-weather-mcp)を入力し、必要に応じて説明を追加します。リポジトリを公開または非公開に設定し、「Create repository」をクリックします。
ローカルリポジトリの初期化とプッシュ
ローカルプロジェクトディレクトリで、Gitリポジトリを初期化します:
git init変更をステージングエリアに追加します:
git add .変更をコミットします:
git commit -m "初回コミット:MCP天気サービスの実装"リモートリポジトリを追加します(GitHubのリポジトリURLを使用):
git remote add origin https://github.com/ユーザー名/my-weather-mcp.git変更をリモートリポジトリにプッシュします:
git push -u origin main既存リポジトリへの変更のプッシュ
変更をステージングエリアに追加します:
git add .変更をコミットします:
git commit -m "変更内容の説明"変更をリモートリポジトリにプッシュします:
git pushプルリクエストの作成
GitHubのリポジトリページにアクセスします。
「Pull requests」タブをクリックし、「New pull request」ボタンをクリックします。
ベースブランチとコンペアブランチを選択します。
「Create pull request」ボタンをクリックします。
プルリクエストのタイトルと説明を入力し、「Create pull request」ボタンをクリックします。
トラブルシューティング
よくある問題と解決策
ERR_PACKAGE_PATH_NOT_EXPORTED エラー
このエラーは、@modelcontextprotocol/sdk パッケージのインポートパスが正しくない場合に発生します。以下のように修正してください:
// 誤ったインポート
import { McpServer } from "@modelcontextprotocol/sdk";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/transports";
// 正しいインポート
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";ネットワーク接続エラー
API呼び出し中にネットワークエラーが発生した場合、プロキシ設定を確認してください。環境変数 HTTP_PROXY または HTTPS_PROXY を設定することで、プロキシを使用できます:
export HTTP_PROXY=http://プロキシサーバー:ポート
export HTTPS_PROXY=https://プロキシサーバー:ポートその他の問題
問題が解決しない場合は、以下の情報を含むイシューを作成してください:
発生したエラーメッセージ
使用しているNode.jsとnpmのバージョン
実行したコマンド
期待される動作と実際の動作