From agentics-tutorials
Tutorial for integrating Model Context Protocol (MCP) servers with Claude Code. Covers stdio transport, tool/resource/prompt schemas, and packaging as a Claude Code plugin. Use when the user asks about MCP, custom tools, or extending Claude with external APIs.
How this skill is triggered — by the user, by Claude, or both
Slash command
/agentics-tutorials:mcp-integrationThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Build a Claude Code MCP server in 15 minutes.
Build a Claude Code MCP server in 15 minutes.
Three primitives:
fetch_page(path))agentics://about)A single server can expose any combination.
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
const server = new Server(
{ name: 'my-server', version: '0.1.0' },
{ capabilities: { tools: {} } },
);
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [{ name: 'hello', description: 'Say hi', inputSchema: { type: 'object' } }],
}));
server.setRequestHandler(CallToolRequestSchema, async req => ({
content: [{ type: 'text', text: `Hello from ${req.params.name}` }],
}));
await server.connect(new StdioServerTransport());
Create .mcp.json at the plugin root:
{
"mcpServers": {
"my-server": {
"command": "node",
"args": ["${CLAUDE_PLUGIN_ROOT}/server.js"]
}
}
}
Test it locally: claude --plugin-dir ./plugins/my-plugin
Drive the server with raw JSON-RPC over stdio:
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"t","version":"1"}}}' | node server.js
You should see an initialize response with serverInfo and capabilities.
stdio only: log to stderr, never stdout — stdout is the JSON-RPC channelinitialize, then notifications/initialized, then can call toolsinputSchema will be rejected by some clientsisError: return { isError: true, content: [...] } for tool errors instead of throwing — Claude can handle them gracefullyThe agentics-org, agentics-events, agentics-blog, and agentics-projects plugins in this marketplace are all working MCP servers with different patterns (web scraping, REST API, GitHub graph). Read their server.js files.
npx claudepluginhub agenticsorg/claude-plugin --plugin agentics-tutorialsCreates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.