Skip to content

How to Integrate Custom Tools into Claude Code with MCP Server in 5 Minutes

Target Audience

  • Intermediate engineers looking to integrate custom tools with Claude Code

Key Points

  1. Launch an MCP server locally
  2. Call custom tools from Claude Code
  3. Integrate tools into existing workflows

Why This Matters Now

Since Claude Code 2.0, Model Context Protocol (MCP) support has standardized external tool integration. However, official documentation lacks concrete implementation steps, leaving many developers struggling with integration. This article presents a minimal working MCP server implementation.

Implementation Steps Overview

StepContentSuccess Metric
1Implement MCP serverServer starts successfully
2Add Claude configurationTool recognized
3Verify operationTool executes successfully

Step 1: Implement Minimal MCP Server

Implement a minimal MCP server in TypeScript. Using @modelcontextprotocol/sdk, you can build a working server in just 10 lines.

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: 'echo',
    description: 'Echo input text',
    inputSchema: { type: 'object', properties: { text: { type: 'string' } } }
  }]
}));

server.setRequestHandler('tools/call', async (request) => {
  const { name, arguments: args } = request.params;
  if (name === 'echo') return { content: [{ type: 'text', text: `Echo: ${args.text}` }] };
});

await server.connect(new StdioServerTransport());

Step 2: Update Claude Configuration

Register the MCP server in ~/.claude/claude_desktop_config.json. This configuration allows Claude Code to auto-start the server.

{
  "mcpServers": {
    "my-tool": {
      "command": "node",
      "args": ["/path/to/mcp-server.js"],
      "env": {}
    }
  }
}

Step 3: Verify Execution from Claude Code

After restarting Claude Code, the new tool becomes available. Type /tools in the prompt to see the echo tool listed.

# Verification command
echo "test" | claude code --tool echo

Common Pitfalls and Solutions

SymptomCauseImmediate Solution
Tool not displayedConfig file path errorUse absolute path
Server startup errorNode.js not installedInstall v20+
Connection timeoutPort conflictUse StdioTransport
Advanced Configuration Advanced MCP server features include streaming responses, async processing, and error handling. For production environments, consider adding: - Retry logic implementation - Logging mechanism - Authentication token validation