MCP(Model Context Protocol)は、Claude — そして任意のMCP対応AI — があなたのAPIと直接通信できるようにする標準です。以下は、10分でAPIをClaude対応にする方法です。
MCPが実際にやっていること
MCPなしの場合:Claudeは、あなたのAPIに関するテキストを読み取り、curlコマンドを提案できます。
MCPありの場合:Claudeは、あなたのAPIを呼び出すことができ、レスポンスを読み取り、そして行動を取れます。
自動化ワークフローにおける違いは非常に大きいです。
最小のMCPサーバ
# mcp_server.py
from mcp.server import Server
from mcp.server.stdio import stdio_server
from mcp.types import Tool, TextContent
import requests
server = Server("my-api-mcp")
@server.list_tools()
async def list_tools():
return [
Tool(
name="calculate_ai_cost",
description="AI API呼び出しのコストを計算する",
inputSchema={
"type": "object",
"properties": {
"model": {"type": "string"},
"input_tokens": {"type": "integer"},
"output_tokens": {"type": "integer"}
},
"required": ["model", "input_tokens", "output_tokens"]
}
)
]
@server.call_tool()
async def call_tool(name: str, arguments: dict):
if name == "calculate_ai_cost":
resp = requests.get("https://api.lazy-mac.com/ai-spend/calculate", params=arguments)
return [TextContent(type="text", text=str(resp.json()))]
async def main():
async with stdio_server() as (read, write):
await server.run(read, write, server.create_initialization_options())
if __name__ == "__main__":
import asyncio
asyncio.run(main())
Claude Desktopに接続する
~/Library/Application Support/Claude/claude_desktop_config.jsonに追加します:
{
"mcpServers": {
"my-api": {
"command": "python3",
"args": ["/path/to/mcp_server.py"]
}
}
}
Claude Desktopを再起動してください。これでこう言えます:「入力500トークン、出力200トークンのそれぞれについて、GPT-4o呼び出し10,000回のコストを計算して」 — そしてClaudeがそのまま実行します。
なぜこれが売上にとって重要なのか
MCP対応APIは、SmitheryやMCPizeのようなディレクトリに掲載されています。これはRapidAPIやGumroadに加わる、追加の発見のための露出です。
MCPizeには24のAPIを登録しています。追加のコードはゼロ—エンドポイントURLを登録するだけです。




