ai

A tool call is just a schema

A tool call is just a schema

Anthropic published the Model Context Protocol at the end of November, and for the first few months I filed it under "another plugin format". Every assistant vendor has one and they last about as long as the vendor's interest does. March changed my mind. The spec picked up a proper HTTP transport and an OAuth story, OpenAI said its Agents SDK would speak it, and Cursor and Windsurf already did. Once the people who compete with the protocol's author adopt it, I can't keep calling it a plugin format.

So last weekend I wrote a server. Nothing ambitious. This site has a folder of markdown posts with front matter, and I wanted to ask Claude Desktop questions about them (which posts mention Kafka, what did I write in 2022, is there a tag I've only used once). It's a retrieval problem small enough to fit in a weekend, and I would notice if the answers were wrong.

The protocol took an hour

The TypeScript SDK is @modelcontextprotocol/sdk, and the server is one file. You declare tools with a name, a description and a zod schema for the arguments, hand it a transport, and that's it:

import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
import { z } from 'zod'

const server = new McpServer({ name: 'deyanpeev-posts', version: '0.1.0' })

server.tool(
  'list_posts',
  'List every post with its date, label and tags. Newest first.',
  { tag: z.string().optional().describe('Only posts carrying this tag') },
  async ({ tag }) => ({
    content: [{ type: 'text', text: JSON.stringify(listPosts(tag)) }],
  })
)

server.tool(
  'read_post',
  'Return the full markdown of one post by its slug.',
  { slug: z.string() },
  async ({ slug }) => ({ content: [{ type: 'text', text: readPost(slug) }] })
)

await server.connect(new StdioServerTransport())

Point claude_desktop_config.json at node server.mjs, restart the app, and the tools appear. I used stdio because the client and server were on the same laptop. The new streamable HTTP transport is for when they aren't, and I didn't need it. Underneath it's JSON-RPC 2.0 with three verbs I cared about (initialize, tools/list, tools/call), and if you've ever written a language server it is familiar to the point of déjà vu. The spec says the resemblance is deliberate.

There was no clever part. The listing function is fs.readdirSync plus gray-matter, the same two calls the site itself makes at build time. An hour in, it worked, and then I sat with it for the rest of the weekend.

The description is the API

A tool is a name, a JSON schema, and a paragraph of prose. The model never sees your implementation. It sees the paragraph, and it decides whether to call you based on that paragraph alone. So the description is the interface, the same way a type signature is the interface for a function, and thinking of it as documentation for the tool undersells it.

My first list_posts description was "Lists posts." Claude called it when I asked about posts, and didn't call it when I asked "what have I written about Redis?", because nothing told it that the listing carried tags and labels and would have answered the question. Once the description said what came back and how it was ordered, the model used it correctly, and it used it first, before it went to read_post on individual files.

I've spent years writing OpenAPI descriptions that no human ever read. A model reads all of it, and takes it literally.

Deciding what to expose

The rest of the weekend went here. With a folder of files and a protocol that makes exposing things trivial, the temptation is to expose everything. List, read, search, and why not write_post and delete_post too. It's a personal site. What's the harm.

I didn't, and the reasons turned into a checklist I expect to reuse.

Read and write are different products. A read-only server can be handed to any client with no further thought. The moment there's a write tool, every question about prompt injection becomes live. A post I'm reading contains text that looks like an instruction, and the model has a tool that acts on instructions. The March spec added annotations (readOnlyHint, destructiveHint) so that a client can treat the two kinds differently, and I set readOnlyHint: true on both of mine. But an annotation is only a hint. The stronger guarantee is that the tool does not exist.

Expose operations, not the filesystem. I nearly wrote a generic read_file that took a path. It would have been shorter than read_post. It would also have been a path-traversal bug with extra steps, and it would've made the model's job harder, because "read a file" carries no information about what's in the file. read_post(slug) says what you get. So the narrow tool is safer and it's also better, and I'm not used to getting both.

Every tool costs context. Each tool's schema and description is sent to the model on every turn. Two tools is nothing. Twenty is a page of text the model reads before it reads your question, and it makes the choice between them worse. I ended up with two tools and no search_posts, because listing with a tag filter plus reading covered every question I had asked.

Very little of this is MCP

I keep coming back to how little of this is about MCP. Swap the transport and the framing and you're left with the questions you'd ask about any API you hand to a party you don't fully control. What can it read, what can it change, does the contract say what it does, how much of it does the caller have to hold in its head at once. The protocol made the plumbing easy enough that I had the rest of the weekend left over for them.

The server lives in a scratch folder, not in the site's repository, and I'm not sure it'll graduate. The checklist will. Next time someone proposes giving a model a tool, my first question is going to be whether it only reads, and if it writes, what the reason is.

Deyan Peev

Founding Engineer in Sofia, Bulgaria. Currently at 1club.

© 2026 Deyan Peev