mcpField
M
MCP Server TypeScript Starter

MCP Server TypeScript Starter

ローカル
github.com/yhwancha開発ツール082 週間前に更新

MCP Server TypeScript Starter について

MCP Server TypeScript Starterは、座標またはIPアドレスから位置を調べるTypeScript製のMCPサーバーです。IP検索にはIPInfo.ioを使い、ヘルスチェックツールも備えています。

主な機能

  1. 01座標による位置検索
  2. 02IPInfo.ioを使ったIP検索
  3. 03サービスのヘルスチェックツール
  4. 04TypeScriptサーバー構成

活用シーン

  1. 01緯度と経度から位置を検索
  2. 02IPアドレスに対応する位置を取得
  3. 03サービスの稼働状態を確認

MCP 対応

座標検索、IPによる位置検索、ヘルスチェックのツールをMCPクライアントに提供します。IP検索にはIPInfo.ioを使います。

設定

ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。

mcp.json · 共通設定
{
"mcpServers": {
"mylocation": {
"command": "npx",
"args": [
"-y",
"mylocation-mcp-server"
],
"env": {
"IPINFO_TOKEN": "<IPINFO_TOKEN>"
}
}
}
}
起動コマンドnpx -y mylocation-mcp-server
設定が必要な環境変数
IPINFO_TOKENシークレット

ローカルサーバーにはマシン上の実行環境(Node.js 18 以上など)が必要です。設定ファイルの場所はクライアントごとに異なります。

パッケージ
npmmylocation-mcp-server

ツール

4

掲載時のツール一覧 · 3 週間前に更新

パラメーター型必須説明
latitudestringはい緯度座標
longitudestringはい経度座標

詳細

MCP Server TypeScript Starter

これは、位置情報サービスを提供する Model Context Protocol(MCP)サーバーの実装です。TypeScript を使用して、座標または IP アドレスから位置情報を検索する実用的な機能を備えた MCP サーバーを構築する方法を紹介します。

機能

  • TypeScript の設定
  • MCP サーバーの完全なセットアップ
  • 位置情報サービスの実装
    • 座標による位置情報の検索
    • IP による位置情報の検索(IPInfo.io を使用)
    • ヘルスチェックエンドポイント
  • 型安全な開発環境
  • 外部 API との連携

インストール

npm install mylocation-mcp

使用方法

  1. IPInfo.io の API トークンを記述した .env ファイルを作成します:
IPINFO_TOKEN=your_ipinfo_token_here
  1. コードにインポートして使用します:
import { McpServer } from 'mylocation-mcp';

開発

パッケージを変更または改善に協力する場合は、次の手順に従ってください:

# Clone the repository
git clone https://github.com/yhwancha/mylocation-mcp.git
cd mylocation-mcp

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env
# Edit .env and add your IPInfo.io API token

# Build the project
npm run build

プロジェクト構成

.
├── src/
│   └── index.ts    # Main server implementation with location tools
├── build/           # Compiled JavaScript files
├── package.json    # Project dependencies and scripts
├── tsconfig.json   # TypeScript configuration
├── .env.example    # Environment variables template
└── README.md      # Documentation

実装済みツール

1. get-location-by-coordinates
server.tool(
  "get-location-by-coordinates",
  "Get location information from provided coordinates",
  {
    latitude: z.string().describe("Latitude coordinate (-90 to 90)"),
    longitude: z.string().describe("Longitude coordinate (-180 to 180)")
  },
  async ({ latitude, longitude }) => {
    // Implementation details...
  }
);
2. get-location-by-ip
server.tool(
  "get-location-by-ip",
  "Get location information from IP address",
  {
    ipAddress: z.string().describe("IP address to lookup")
  },
  async ({ ipAddress }) => {
    // Implementation details...
  }
);
3. health
server.tool(
  "health",
  "Check the health status of the service",
  {},
  async () => {
    // Implementation details...
  }
);

MCP サーバーの設定

この MCP サーバーをプロジェクトで使用するには、次の設定を追加してください:

{
    "mcpServers": {
        "location-service": {
            "command": "npx",
            "args": [
              "-y",
              "mylocation-mcp-server"
            ],
            "env": {
              "IPINFO_TOKEN": <IPINFO_TOKEN>
            }
        }
    }
}

レスポンス形式

すべてのツールは、次の形式でレスポンスを返します:

{
  "content": [
    {
      "type": "text",
      "text": "JSON string containing the response data"
    }
  ]
}

レスポンスデータは、次の構造に従います:

{
  "status": "success|error",
  "source": "user_provided|ip_based",
  "data": {
    // Location data when successful
  },
  "error": "Error message when failed"
}

依存関係

  • @modelcontextprotocol/sdk:MCP サーバーの実装
  • zod:スキーマ検証
  • axios:IPInfo API 用の HTTP クライアント
  • dotenv:環境変数の管理
  • TypeScript 開発ツール

ライセンス

MIT

コメント

MCP は初めてですか?

プロトコルの概要から最初のサーバーの導入まで、よくある疑問にまとめて答えます。

AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。