claude-ia-mcp-tools
APIクライアント → ビジネスロジック → MCPツール
通常のアプリケーションコードとMCPツールの両方からAPIクライアントとビジネスロジックを再利用する方法を示す、小さなPythonの例です。
構成
src/example/
├── api/
│ └── api_client.py
├── business/
│ └── service.py
├── mcp/
│ └── server.py
└── main.pyこの例では、以下の5つのオペレーションを公開しています。
get_userlist_userscreate_userupdate_userdelete_user
MCP層は意図的に薄く設計されており、MCP入力を検証してビジネスサービスに委譲します。ビジネスサービスはHTTP処理をAPIクライアントに委譲します。
Related MCP server: JSONPlaceholder MCP Server
インストール
python -m venv .venv
# Windows:
.venv\Scripts\activate
# Linux/macOS:
source .venv/bin/activate
pip install -r requirements.txtMCPサーバーを起動する
python -m src.example.mcp.serverまたは、MCPクライアントを設定して起動する:
python -m src.example.mcp.serverMCPサーバーを使用する
ターミナル経由
{"jsonrpc":"2.0","method":"tools/list","id":1}または Claude
{
"mcpServers": {
"example-users": {
"command": "python",
"args": ["-m", "src.example.mcp.server"]
}
}
}重要
これは自己完結型のアーキテクチャ例です。APIクライアントは、公開デモAPIとして https://jsonplaceholder.typicode.com を使用しています。
実際のAPIでは、ApiClient の実装を置き換え、ビジネス/MCPのインターフェースを基本的に変更しないでください。
テストワークフローの実行
This server cannot be deployed
Maintenance
Related MCP Connectors
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
Build multi-tenant apps over MCP. Schemas, CRUD, deploys — access control enforced server-side.
Governed MCP gateway: one endpoint for your tools, with credential custody and audit log.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceWraps the JSONPlaceholder fake REST API to enable testing and prototyping with CRUD operations on posts, comments, and other resources via MCP.590 npmMIT
- FlicenseNot gradedqualityDmaintenanceEnables interaction with the JSONPlaceholder REST API for managing posts, comments, and users through MCP tools.-
- FlicenseNot gradedqualityDmaintenanceA minimal demo MCP server exposing user management tools (list, get, create, update, delete users) over both stdio and HTTP/SSE transports, wrapping an Express REST API to illustrate local vs remote MCP connectivity.-
- AlicenseNot gradedqualityCmaintenanceEnables retrieving user and post data through MCP tools, with Zod-based request validation and OpenAPI/Swagger UI support.MIT