Topic hub
Build and Test an MCP Server
What This Collection Covers
Building an MCP server is a small amount of code and a large amount of design. The protocol handles transport and messaging. Everything that determines whether the server is useful sits in the choices made before writing it: what a tool is allowed to do, what its input schema permits, what a result looks like and how you will prove it still works after a change.
This collection follows one server from an empty directory to a published listing. The running example is a read-only catalog lookup: a product identifier goes in, a price and an availability count come out. Read only, because it keeps the security discussion honest. A server that cannot write is easier to reason about, and the same structure extends to writes once the access model is settled.
The Order to Read It In
- A read-only server in Python establishes the smallest working server and a verified client result.
- A server in TypeScript repeats the exercise for a team directory and adds a missing-record case.
- Wrapping an existing API moves from a fixture to a real system, including pagination.
- Designing an input schema turns a vague parameter list into a contract the model can follow.
- Returning structured content separates the typed result from the sentence shown to a person.
The testing articles come next, then release and publication. Reading them out of order works, but the examples build on the same catalog, so the sequence is faster.
Four Decisions Before the First Line
Read or write. Decide now. A read-only server can ship with a narrow scope and no approval step. A writing server needs an idempotency key and, usually, a recorded decision before the action executes. Retrofitting that distinction later touches every tool, every test and every client.
One tool or many. A single tool with a mode parameter is harder for a model to use than three tools with clear names. Start with the smallest number of tools that covers distinct intents, and add one only when a request cannot be served without it.
What the result is for. A result a person will read and a result a program will parse are different shapes. Decide which one you are returning, and read structured output for the case where you need both.
Where it runs. A local process over standard input suits one machine. A shared endpoint over HTTP suits a team. The tool surface should be identical either way, and if it is not, the transport is hiding a design problem.
What Done Looks Like
A server is finished when a client that has never seen it can complete a task without being told how. The handshake succeeds, the tool list is discoverable, the description explains when to use the tool, the schema refuses bad input with a named field, and a valid call returns the expected record.
It is also finished when a second person can run the test suite and get the same answer. Contract tests belong in the deliverable, not in a later improvement, because the first change after launch is the one that breaks a client.
Where This Fits on the Site
The server is one layer of a larger arrangement. MCP and integrations describes how a governed layer sits between agents and business systems, and what an MCP layer is explains the boundary in more detail. Building the server is the part you control directly.
How to Review a Server You Did Not Build
Half the servers a team runs were written by someone else, often by a vendor. The same four decisions apply in reverse order.
- Read the tool list first. If two tools would be chosen interchangeably by a careful reader, the surface is not ready.
- Read the schemas. A tool that accepts a free text query for everything is either a search tool or an unfinished one.
- Check the scopes. A read-only server that requests write access is a finding, not a detail.
- Ask for one trace. A server that cannot show a completed call cannot be reviewed, only trusted.
- Find the owner. A server with no named owner is one nobody will upgrade, and the collection's later articles assume someone is responsible for releases.
Most reviews end with one of two outcomes: the server is fine and the descriptions need work, or the boundary is wrong and no amount of description will fix it.
Next step
Start with the Python tutorial, or contact us if you would rather have a first server reviewed before it reaches a client.
FAQ
Question: Do I need to implement the protocol myself?
No. Use an SDK for the language you are working in and pin its version. Implementing the message layer by hand is a learning exercise, not a production decision, and the specification changes often enough that a hand written implementation becomes a maintenance cost.
Question: Which language should I choose?
The one your team already deploys and debugs. A Python server suits data teams, a TypeScript server suits product teams, and both behave identically at the protocol level. Choose for maintenance rather than for the tutorial you happen to be reading.
Question: How long should a first server take?
A read-only server with one tool, a fixture and three tests is a day of focused work for someone who knows the language. The days that follow are usually spent on descriptions, scopes and error behavior, which is where the quality actually lives.