- MCP サーバーサンプル
Content
MCP サーバーサンプル
🔍 数値比較ツールを提供するModel Context Protocol(MCP)サーバーの実装サンプル
🚀 クイックスタート
-
依存関係インストール
bun install -
プロジェクトビルド
bun build
📋 必要要件
- Bun ランタイム(v1.0.0以上)
- MCP対応クライアント(例:Claude Desktop App、Cline、Cursor)
⚙️ サーバー設定
設定ファイルの編集
{
"mcpServers": {
"number-comparison": {
"command": "bun",
"args": ["run", "/absolute/path/to/server/src/index.ts"],
"disabled": false,
"autoApprove": []
}
}
}
📌 重要設定項目
| 設定項目 | 必須 | デフォルト値 | 説明 |
|---|---|---|---|
command | ✓ | - | サーバー実行コマンド |
args | ✓ | - | コマンド引数(絶対パス必須) |
disabled | - | false | サーバーの無効化 |
autoApprove | - | [] | 自動承認ツールリスト |
⚠️ 注意事項
- パス指定は必ず絶対パスを使用
- 設定変更後はクライアントの再起動が必要
autoApproveの使用は最小限に
📸 使用イメージ
よくあるAIが間違えてしまう計算問題を例に、ツールの使用前後の比較を示します。
ツール使用前

ツール使用後

🛠️ ツール使用例
<use_mcp_tool>
<server_name>number-comparison</server_name>
<tool_name>compare-numbers</tool_name>
<arguments>
{ "number1": 42, "number2": 24 }
</arguments>
</use_mcp_tool>
✅ 実行結果:
The larger number is: 42
🧩 カスタムツール追加
-
ツール実装ファイル作成
touch server/src/tools/new-tool.ts -
ツール登録(server/src/index.ts)
// ... 既存コード ... server.tool( "new-tool", { param1: z.string().describe("パラメータ説明"), param2: z.number().min(0) }, async ({ param1, param2 }) => { // 処理実装 return { content: [{ type: 'text', text: '結果' }] }; } ); // ... 既存コード ...
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Amap Maps高德地图官方 MCP Server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题;
Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
DeepChatYour AI Partner on Desktop
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Playwright McpPlaywright MCP server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
RedisA Model Context Protocol server that provides access to Redis databases. This server enables LLMs to interact with Redis key-value stores through a set of standardized tools.
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
CursorThe AI Code Editor
ChatWiseThe second fastest AI chatbot™
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
WindsurfThe new purpose-built IDE to harness magic
Tavily Mcp
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Serper MCP ServerA Serper MCP Server