MCP Servers Explained: How to Connect AI Agents to Any Business Tool
Model Context Protocol(MCP)は、ファンクションコール以降のAIツールチェーンで最大の変革です。AIアプリケーションを構築するなら、MCPを理解する必要があります — それがAIエージェントが現実世界とどのように相互作用するかを決定します。
私は、2つのMCPサーバーを構築し、それらの間に30のツールを統合しました。以下が私の学びです。
MCPはどんな問題を解決するのか?
MCP以前は、AIエージェントをビジネスツールに接続することは、以下を意味していました:
- カスタムAPI統合コードを作成する
- 特定のAIモデル向けのツールスキーマを定義する
- 認証、レート制限、エラーハンドリングを処理する
- 新しいツールごと、そして新しいAIモデルごとに繰り返す
MCPはこれを標準化します。1つのMCPサーバーを構築すれば、任意のAIクライアント(Claude、Cursor、Windsurf、カスタムエージェント)もあなたのツールを利用できます。
AIのUSBのようなものだと考えてください — 1つのコネクターで普遍的な互換性を実現します。
60秒で分かるアーキテクチャ
AI Client (Claude/Cursor) ←→ MCP Protocol ←→ Your MCP Server ←→ Business API
あなたのMCPサーバーはツール(AIが呼び出せる関数)、リソース(AIが読み取れるデータ)、およびプロンプト(事前構築された会話テンプレート)を公開します。
実際のMCPサーバーを構築する
以下は私のShopify MCPサーバーの構成です(16ツール):
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
const server = new Server({
name: 'shopify-store-mcp',
version: '1.0.0'
}, {
capabilities: {
tools: {}
}
});
// Define tools
server.setRequestHandler('tools/list', async () => ({
tools: [
{
name: 'get_products',
description: 'List products from the Shopify store with optional filters',
inputSchema: {
type: 'object',
properties: {
limit: { type: 'number', description: 'Max products to return (default 10)' },
status: { type: 'string', enum: ['active', 'draft', 'archived'] }
}
}
},
// ... 15 more tools
]
}));
// Handle tool calls
server.setRequestHandler('tools/call', async (request) => {
const { name, arguments: args } = request.params;
switch (name) {
case 'get_products':
const products = await shopifyClient.get('products', args);
return { content: [{ type: 'text', text: JSON.stringify(products) }] };
// ... handle other tools
}
});
// Start server
const transport = new StdioServerTransport();
await server.connect(transport);
私の2つのMCPサーバー
ShopifyストアのMCP(16ツール)
- 製品: 一覧、取得、作成、更新、削除
- 注文: 一覧、取得、作成、発送、キャンセル
- 在庫: 在庫レベルの取得、数量の調整
- 顧客: 一覧、取得、作成、検索
- 分析: 注文統計、売上の要約を取得
Google Sheets MCP(14ツール)
- スプレッドシート: 作成、一覧、取得
- データ: 範囲の読み取り、範囲の書き込み、行の追加、範囲のクリア
- シート: 追加、削除、名前の変更
- フォーマット: 列幅の設定、セルの結合
- 検索: 複数のシートから値を検索
良いMCPサーバーを作る要素
1. 明確なツール説明
AIエージェントは、ツールの説明を読んでいつ使用すべきかを判断します。具体的に記述しましょう:
// Bad
"description": "Gets data"
// Good
"description": "List products from the Shopify store. Returns product title, price, inventory quantity, and status. Supports filtering by status (active/draft/archived) and pagination with limit parameter."
2. 防御的エラーハンドリング
AIエージェントは予期せぬ入力を渡してくることがあります。すべてを対処しましょう:
case 'update_product':
if (!args.productId) {
return { content: [{ type: 'text', text: 'Error: productId is required' }] };
}
try {
const result = await shopifyClient.put(`products/${args.productId}`, args);
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
} catch (err) {
return { content: [{ type: 'text', text: `Error: ${err.message}` }] };
}
3. 妥当なデフォルト
明らかなデフォルト値を持つパラメーターを必須にしない:
properties: {
limit: { type: 'number', description: 'Max results (default: 10)', default: 10 },
sortBy: { type: 'string', description: 'Sort field (default: created_at)', default: 'created_at' }
}
マネタイズ
MCPサーバーには複数の収益経路があります:
| チャネル | モデル | 可能性 |
|---|---|---|
| npm (free) | リード獲得 | 信頼性 + GitHubスター |
| MCPize | 1回あたり呼び出し(85%シェア) | 月額$100〜$10,000 |
| Cursorマーケットプレイス | 無料(露出) | ユーザー獲得 |
| フリーランス | カスタムMCP開発 | $500-$5,000/プロジェクト |
| Fiverr/Upwork | MCPギグ | $95-$500/ギグ |
市場は早期段階です。MCPのダウンロードは月次で85%増加していますが、収益化されているサーバーは5%未満です。早期参入者には機会の時期があります。
はじめに
- クライアントが使用するビジネスツールを選択する(CRM、会計、プロジェクト管理)
@modelcontextprotocol/sdknpmパッケージを使用する- 最も一般的な操作をカバーする3〜5つのツールから始める
- Claude DesktopまたはCursorでテストする
- npmに公開し、MCPディレクトリに提出する
MCPエコシステムは急速に成長しています。現在有用なサーバーを構築している開発者は、市場が成熟したときに配布を掌握することになるでしょう。
私はMCPサーバーとAI自動化システムを構築しています。GitHubの [Shopify MCP Server][GITHUB_LINK] および [Google Sheets MCP Server][GITHUB_LINK_2] をご覧ください。