mcp
1
总安装量
1
周安装量
#52083
全站排名
安装命令
npx skills add https://github.com/kimny1143/claude-code-template --skill mcp
Agent 安装分布
mcpjam
1
claude-code
1
replit
1
junie
1
windsurf
1
zencoder
1
Skill 文档
mcp – MCP Server 使
Model Context Protocol (MCP) ãµã¼ãã¼ã®ä½æã»ç®¡çã
æ¦è¦
MCP 㯠Claude Code ã«ã«ã¹ã¿ã ãã¼ã«ã追å ããããã®ãããã³ã«ã
ç¨é:
- ããã¸ã§ã¯ãåºæã®ãã¼ã«æä¾
- å¤é¨ãµã¼ãã¹é£æº
- èªååã¿ã¹ã¯
åºæ¬æ§é
// 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)
{
"mcpServers": {
"my-tool": {
"command": "node",
"args": ["scripts/mcp/my-tool.js"]
}
}
}
ã¦ã¼ã¶ã¼ã¬ãã« (~/.claude/settings.json)
{
"mcpServers": {
"my-global-tool": {
"command": "node",
"args": ["/path/to/tool.js"]
}
}
}
å®ç¨ä¾
ãã¹ãã©ã³ãã¼
server.setRequestHandler("tools/list", async () => ({
tools: [
{
name: "run_tests",
description: "ã¦ããããã¹ããå®è¡",
inputSchema: {
type: "object",
properties: {
pattern: { type: "string", description: "ãã¹ããã¿ã¼ã³" },
},
},
},
],
}));
server.setRequestHandler("tools/call", async (request) => {
if (request.params.name === "run_tests") {
const pattern = request.params.arguments?.pattern || "";
const result = await runTests(pattern);
return { content: [{ type: "text", text: result }] };
}
});
async function runTests(pattern) {
const { execSync } = await import("child_process");
try {
const output = execSync(`npm test -- ${pattern}`, { encoding: "utf-8" });
return output;
} catch (error) {
return error.stdout + error.stderr;
}
}
DB ã¯ã¨ãª
{
name: "query_database",
description: "ãã¼ã¿ãã¼ã¹ã«ã¯ã¨ãªãå®è¡",
inputSchema: {
type: "object",
properties: {
query: { type: "string", description: "SQL ã¯ã¨ãª" },
},
required: ["query"],
},
}
ã³ã³ããã¹ãç¯ç´
使ããªãMCPãµã¼ãã¼ãç¡å¹åãã¦ã³ã³ããã¹ããç¯ç´:
// .mcp.json
{
"mcpServers": {
"frequently-used": { "command": "node", "args": ["tool1.js"] }
},
"disabledMcpServers": [
"rarely-used-tool",
"heavy-context-tool"
]
}
ãããã°
# ç´æ¥å®è¡
node scripts/mcp/my-tool.js
# ãã°ç¢ºèª
DEBUG=mcp* node scripts/mcp/my-tool.js
# Claude Code ã§ç¢ºèª
# /mcp ã³ãã³ãã§æ¥ç¶ç¶æ
ã確èª
ãã¹ããã©ã¯ãã£ã¹
- ã¨ã©ã¼ãã³ããªã³ã°: 常㫠try-catch ã§å²ã
- ã¿ã¤ã ã¢ã¦ã: é·æéå¦çã¯é¿ããï¼30ç§ä»¥å ï¼
- 説æãæç¢ºã«: description ã¯ãã¼ã«é¸æã®å¤æææ
- inputSchema å¿ é : ãã©ã¡ã¼ã¿ã®åãæç¤º
- 10å以ä¸: ããã¸ã§ã¯ããããã®MCPæ°ãå¶é