Build

A First MCP Server — My Code Runs Inside the Chat Window

By makemind · Jul 2, 2026

My code executes inside the chat window

Type "save what we just discussed to my notes" into a Claude Desktop chat. Instead of inventing an answer, the model calls a tool named noteadd, and a moment later the result "saved" is quoted in its reply. In the next conversation, ask "what notes do I have?" and notelist runs and returns exactly what was saved.

What executed noteadd and notelist is a few-dozen-line server running on my laptop. Nothing was uploaded to a plugin store or deployed anywhere. One local file was started with dart run, and one line of path was registered in Claude Desktop's config.

This article builds that server from scratch. By the end, the capture above reproduces on your screen.


Why a server — an adapter, not a demo

"Doing something with an LLM" usually brings prompts to mind. But the moment the model has to read my data or execute my function, prompts do not reach. Every time, we have bolted on integration code that differs per client.

MCP (Model Context Protocol) unifies that connection into one contract. A server exposes what it has as named tools, and the model calls those tools in a standard way. A server built once attaches the same way to Claude Desktop or to any other MCP client.

So what the server in this article really is, is not "a demo that reports the temperature" but a one-line adapter joining my functions and data to an LLM by a standard. The function chosen as the example is a persistent notebook. Notes that outlive the conversation, handled by four tools.

ToolWhat it does
note_addSaves a note (it persists across conversations).
note_listShows saved notes, newest first (tag filter available).
note_searchFinds notes whose body contains a string (case-insensitive).
note_deleteDeletes a note by id.

The model chooses which of the four to call from the context of the conversation. All we do is define what the four mean.


Where this server sits

Placing what we build inside the whole picture first makes clear how far the code we are writing is responsible.

[ LLM ]
   │
[ MCP client ]   ← Claude Desktop (and the mcp_client of the next article)
   │  JSON-RPC over stdio
   ▼
[ MCP server ]  ← what this article builds
   │            · start the server (stdio)
   │            · register 4 tools (name · input schema · handler)
   ▼
[ notes.json ]  ← persistent storage

The scope of this article is the dotted box — server plus tool definitions plus storage. On the client side (Claude Desktop) we register and use what already exists. Building a client ourselves belongs to the next article.


This content requires Developer or above

Sign in and upgrade your plan to continue reading.

View Plans
Twitter