AIToday
Large Language ModelsAI Coding AssistantsZenn AI/MLPublished: Oct 10, 2026, 10:00 JST

Build an MCP server for Claude Code in 30 分

Build an MCP server for Claude Code in 30 分

The guide walks through creating a TypeScript MCP server with @modelcontextprotocol/sdk, registering a single "list_todos" tool, testing it with the official MCP Inspector, and adding it to Claude Code with the claude mcp add command. It flags one common trap: a single console.log line on a stdio server gets mixed into the protocol's own messages, so the client hits a parse error and goes silent.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, in your inbox every morning.

Context & Analysis

The piece is written from firsthand experience: the author had already built an MCP server for internal API integration and connected it to Claude Code, and describes the first thing that tripped them up as not implementation difficulty but the quiet failure caused by writing one console.log line. That failure mode follows from how a stdio server works — the process's stdout is the JSON-RPC channel itself, so anything else written there corrupts the conversation. The recommended logging escape hatch is console.error, which goes to stderr instead.

The recommended first tool is deliberately small: list_todos, which scans a directory for TODO and FIXME comments in .ts, .tsx, .js and .py files and returns them with file paths and line numbers. The author argues this kind of modest tool still matters, because it adds information a team already cares about into what the LLM can reach.

Beyond the stdout trap, the guide lists a few more practical snags. A loose inputSchema (the tool's argument definitions, written with the Zod library) makes the client's argument generation unstable, so the schema should be strict. The entry point passed to claude mcp add is safest as an absolute path, so the server does not depend on the directory Claude Code was launched from. And shutting down Claude Code without stopping the server can leave the child process lingering, which is why the author suggests checking with ps aux | grep tsx during development. The closing advice is to start with a minimal one-tool server and connect it via claude mcp add before expanding.

FAQ
Why would I build my own MCP server instead of using an existing one?
Off-the-shelf MCP servers mostly cover general services like Slack and GitHub. Internal APIs, your own scripts, and custom aggregation logic have to be wrapped in a server you write yourself.
What is the most common mistake when writing an MCP server?
Using console.log for debugging. On a stdio server, stdout carries the JSON-RPC traffic, so that output corrupts the protocol messages and the client goes silent with a parse error. The guide says to log to console.error (stderr) instead.
How do you check the server works before connecting it to Claude Code?
The guide runs the official MCP Inspector against the server. It opens a browser where you can inspect a tool's schema and call it to see the returned value.

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleUkraine drones knock out Yandex AI data center