moriokameda
MCP Servermoriokamedapublic

mcp server sample

MCPサーバーの使用サンプル

Repository Info

0
Stars
0
Forks
0
Watchers
0
Issues
JavaScript
Language
-
License

About This Server

MCPサーバーの使用サンプル

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

MCP サーバー

このリポジトリは Model Context Protocol (MCP) を使用した天気予報サーバーの実装例です。

プロジェクト概要

Model Context Protocol (MCP) は、大規模言語モデル (LLM) とツールを接続するためのプロトコルです。このプロジェクトでは、MCP SDK を使用して、National Weather Service (NWS) API に接続する天気予報ツールを提供するサーバーを実装しています。

このサーバーは、緯度と経度を入力として受け取り、その場所の天気予報を返します。

使用技術

  • TypeScript: 静的型付けを提供するJavaScriptのスーパーセット
  • Node.js: JavaScriptランタイム環境
  • MCP SDK: Model Context Protocol の実装を提供するSDK
  • National Weather Service API: 米国の天気予報データを提供するAPI

インストール方法

  1. リポジトリをクローンします:
git clone <repository-url>
cd mcp-server-quickstart
  1. 依存関係をインストールします:
npm install
  1. プロジェクトをビルドします:
npm run build

使い方

サーバーの実行

ビルド後、以下のコマンドでサーバーを実行できます:

./build/index.js

または、パッケージをインストールした場合:

my-mcp-server

MCP クライアントからの接続

このサーバーは標準入出力 (stdio) を使用して MCP クライアントと通信します。MCP 対応のクライアント(例:MCP 対応の LLM)からこのサーバーを呼び出すことができます。

利用可能なツール

このサーバーは以下のツールを提供しています:

  • get_forecast: 指定された緯度と経度の天気予報を取得します
    • 入力パラメータ:
      • latitude: 場所の緯度(数値)
      • longitude: 場所の経度(数値)
    • 出力: 指定された場所の天気予報テキスト

実装の詳細

サーバーの実装は主に以下の3つのステップで構成されています:

  1. サーバーインスタンスの初期化:

    const server = new Server(
        {
            name: "weather",
            version: "1.0.0",
        },
        {
            capabilities: {
                tools: {},
            },
        },
    );
    
  2. 利用可能なツールの一覧を返す:

    server.setRequestHandler(ListToolsRequestSchema, async () => {
        return {
            tools: [
                {
                    name: "get_forecast",
                    description: "Get weather forecast for a location",
                    inputSchema: {
                        // ...
                    },
                },
            ],
        };
    });
    
  3. ツールの実行:

    server.setRequestHandler(CallToolRequestSchema, async (request) => {
        // ツールの実行ロジック
    });
    

注意事項

  • このサーバーは米国の National Weather Service API を使用しているため、米国内の場所の天気予報のみ取得できます。
  • API の利用制限に注意してください。

ライセンス

このプロジェクトのライセンス情報については、LICENSE ファイルを参照してください。

Quick Start

1

Clone the repository

git clone https://github.com/moriokameda/mcp-server-sample
2

Install dependencies

cd mcp-server-sample
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownermoriokameda
Repomcp-server-sample
LanguageJavaScript
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation