mcplisted
Install: claude install-skill kimny1143/claude-code-template
# mcp - MCP Server 作成
Model Context Protocol (MCP) サーバーの作成・管理。
---
## 概要
MCP は Claude Code にカスタムツールを追加するためのプロトコル。
**用途**:
- プロジェクト固有のツール提供
- 外部サービス連携
- 自動化タスク
---
## 基本構造
```javascript
// scripts/mcp/my-tool.js
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const server = new Server(
{ name: "my-tool", version: "1.0.0" },
{ capabilities: { tools: {} } }
);
// ツール一覧
server.setRequestHandler("tools/list", async () => ({
tools: [
{
name: "my_custom_tool",
description: "カスタムツールの説明",
inputSchema: {
type: "object",
properties: {
param1: { type: "string", description: "パラメータ1" },
},
required: ["param1"],
},
},
],
}));
// ツール実行
server.setRequestHandler("tools/call", async (request) => {
const { name, arguments: args } = request.params;
if (name === "my_custom_tool") {
const result = await doSomething(args.param1);
return { content: [{ type: "text", text: JSON.stringify(result) }] };
}
throw new Error(`Unknown tool: ${name}`);
});
// サーバー起動
const transport = new StdioServerTransport();
await server.connect(transport);
```
---
## 設定
### プロジェクトレベル (.mcp.json)
```json
{
"mcpServers": {
"my-tool": {
"command": "node",
"args": ["scripts/mcp/my-tool.js"]
}
}
}
```
### ユーザーレベル (~/.claude/settings.json)
```json
{
"mcpServers": {
"my-global-tool":