The quickest way to understand the Model Context Protocol is to build a server. It is a small program that tells an AI client what it can do and then does it when asked. The code is short. What decides whether your team can rely on it comes after the first successful call.
This walk-through builds one tool, connects it to a client, and then covers the three jobs IT adds before agents depend on it. If you want the definition first, start with what an MCP server is.
What you are building
One tool, get_open_tickets: given a customer ID, it returns that customer’s open support tickets. An agent that is asked “what is open for Acme?” finds the tool, calls it with the ID, and reads the result.
An MCP server has three parts: a name and version so clients can identify it, one or more tools described by a name, a plain-language description and an input schema, and a transport that carries the messages. The description matters more than it looks. It is how the agent decides when to use the tool.
Build it with the TypeScript SDK
Install the official SDK and a schema library:
npm install @modelcontextprotocol/sdk zod
Then write the server. This one returns canned data, which is enough to see the whole loop work:
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: "support-tickets", version: "0.1.0" });
server.registerTool(
"get_open_tickets",
{
description: "List the open support tickets for one customer.",
inputSchema: { customerId: z.string().describe("The customer's ID") },
},
async ({ customerId }) => {
const tickets = [{ id: "T-1042", status: "open", subject: "Login fails" }];
return {
content: [{ type: "text", text: JSON.stringify({ customerId, tickets }) }],
};
},
);
await server.connect(new StdioServerTransport());
Save it as server.mjs (it uses ES modules and top-level await) and run it with node server.mjs. Swap the canned list for a call to your ticketing system and you have a real tool. The Python SDK follows the same shape: a name, a description, typed inputs and a function.
Connect it to a client
A client needs to know how to start your server. In Claude Desktop, Cursor and most other clients, that is an entry in a config file that gives a command and its arguments. Point it at node with the path to server.mjs, restart the client, and the tool appears. Ask a question that needs it and watch the call go through.
Stdio runs the server on your own machine, which suits a first test. To share it with a team, you serve it over HTTP instead, and that is where the real work starts.
Then do the three jobs IT adds
A server that works on your laptop is a prototype. Before agents across a team rely on it, three things have to be true.
1. It has an owner. Someone is named, answers for what the tool does, and decides when it changes or retires. Tools change under agents: rename one input and every agent that used it fails. The MCP server lifecycle post covers owners, versions and retirement dates.
2. Access follows the person. Most first servers hold one token, usually the builder’s own, so every caller gets the builder’s access. The agent should act with the permissions of the person it works for, and the tool should expose the actions the job needs, not the whole API. A tool that reads invoices should not be able to delete them.
3. Every call is logged. Someone in security will ask which agent called which tool, for whom, and with what result. If the answer is in a terminal on one machine, you cannot give it. The MCP security checklist lists what a server should record and enforce.
Each job is small on the first server. Repeat it for the second, third and tenth server, each with its own credentials, hosting and logs, and it becomes the real cost. Governing the MCP servers you already run covers what to do when there are already a dozen.
Or skip the server code
If the tools you want are actions in systems you already connect, you do not need to write a server at all. With Agent Gateway for MCP, any of the 12,000+ apps, databases, APIs, and services Tray connects to becomes a governed MCP tool. So does any API with an OpenAPI spec: the CDK builds a connector from the spec, and Agent Gateway exposes it as a tool.
Most companies can give agents MCP access only to the few apps that ship their own server. Here, every tool comes with scoped operations, held credentials and a log of every call, so the three jobs above are part of how the tool is published rather than work you repeat for each server. To see how the pieces fit, read MCP vs API next.