Skip to content

Agentic Workflows — Mastery3 / 8

Build Your First Custom MCP Server

Off-the-shelf servers cover GitHub and Postgres. The high-leverage one is the server only you can write — the bridge to your own system.

Build Your First Custom MCP Server

The public MCP servers cover the obvious systems. The one that changes your day is the server only you can write: the bridge to your internal API, your deploy tooling, your data warehouse.

The smallest useful server

An MCP server is a process that speaks the protocol over a transport and exposes tools. The minimum: declare a tool, describe its inputs, return a result.

// server.ts — exposes one tool over stdio
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
const server = new McpServer({ name: 'ops-tools', version: '1.0.0' })

server.tool('deploy_status', { service: 'string' }, async ({ service }) => {
  const res = await fetch(`https://internal.api/status/${service}`)
  return { content: [{ type: 'text', text: await res.text() }] }
})

server.connect() // stdio

Connect it:

claude mcp add ops-tools -- node ./server.ts

Design rules that keep it safe

  • One tool, one job. A deploy_status tool beats a vague ops tool. Clear names help the agent pick correctly.
  • Describe inputs precisely. The schema is the agent's instruction manual — vague schemas cause wrong calls.
  • Read before write. Ship read-only tools first; add mutating tools only once you trust the loop, and keep them obviously named.

Returning good output

Tools return text the agent reads. Return structured, concise output (JSON or a tight summary), not a wall of logs. The agent reasons over what you return; noise in means noise out.

With a server of your own, the agent reaches your world. Next we make sure it always behaves in that world — with hooks.

Share this article

#MCP #DevTools #AgenticAI

LinkedInX / TwitterBlueskyThreadsRedditHacker NewsWhatsAppEmail

Series — Agentic Workflows — Mastery

  1. Part 01The Agentic Workflow MindsetMost developers treat AI like a smarter autocomplete. The ones who pull ahead treat it like a teammate that acts. Here is the mental model.
  2. Part 02MCP Servers 101 — Give Your Agent Real ToolsThe Model Context Protocol is how your agent stops guessing and starts querying your database, your issues, your browser. Here is the mental model and the first connection.
  3. Part 03Build Your First Custom MCP Serveryou are hereOff-the-shelf servers cover GitHub and Postgres. The high-leverage one is the server only you can write — the bridge to your own system.
  4. Part 04Hooks — Make the Agent Obey Your RulesA prompt asks the model to remember. A hook makes it happen — deterministically, every time, outside the model's control.
  5. Part 05Custom Slash Commands as Team WorkflowsA custom slash command is a reusable prompt you commit to the repo — so the whole team runs the same high-quality instruction instead of re-typing it.
  6. Part 06Subagents — Delegating Work That ScalesOne giant context gets slow and vague. Subagents let the main agent hand focused work to specialists with their own context and tools — and run them in parallel.
  7. Part 07The Daily-Driver Setup — Settings, Permissions, Status LineThe difference between fighting the agent and flowing with it is twenty minutes of configuration you do once. Here is the setup.
  8. Part 08Multi-Tool Pipelines — Ticket to Reviewed BranchThe payoff: chain MCP, hooks, commands and subagents into one flow that takes a ticket to a reviewed branch — with you in the loop only where it counts.

Keep learning

PDF — lifetime

MCP

Connect Claude Code to your tools and data via the Model Context Protocol.

See the PDF →

Course

The Claude Mastery course

12 modules · 5 languages · certificate · 3-day free trial.

See plans →
LinkedInX / TwitterBlueskyThreads