MCP Server TypeScript Starter について
MCP Server TypeScript Starterは、座標またはIPアドレスから位置を調べるTypeScript製のMCPサーバーです。IP検索にはIPInfo.ioを使い、ヘルスチェックツールも備えています。
主な機能
- 01座標による位置検索
- 02IPInfo.ioを使ったIP検索
- 03サービスのヘルスチェックツール
- 04TypeScriptサーバー構成
活用シーン
- 01緯度と経度から位置を検索
- 02IPアドレスに対応する位置を取得
- 03サービスの稼働状態を確認
MCP 対応
座標検索、IPによる位置検索、ヘルスチェックのツールをMCPクライアントに提供します。IP検索にはIPInfo.ioを使います。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
ツール
4掲載時のツール一覧 · 3 週間前に更新
| パラメーター | 型 | 必須 | 説明 |
|---|---|---|---|
| latitude | string | はい | 緯度座標 |
| longitude | string | はい | 経度座標 |
詳細
MCP Server TypeScript Starter
これは、位置情報サービスを提供する Model Context Protocol(MCP)サーバーの実装です。TypeScript を使用して、座標または IP アドレスから位置情報を検索する実用的な機能を備えた MCP サーバーを構築する方法を紹介します。
機能
- TypeScript の設定
- MCP サーバーの完全なセットアップ
- 位置情報サービスの実装
- 座標による位置情報の検索
- IP による位置情報の検索(IPInfo.io を使用)
- ヘルスチェックエンドポイント
- 型安全な開発環境
- 外部 API との連携
インストール
npm install mylocation-mcp
使用方法
- IPInfo.io の API トークンを記述した
.envファイルを作成します:
IPINFO_TOKEN=your_ipinfo_token_here
- コードにインポートして使用します:
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
コメント
Markdown 対応
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。