Read-only MCP contract
Read-only MCP contract — Build a minimal read-only MCP server. Host, client and server; Tools and resources serve different roles; Use the current SDK line. Practical assignment: Practice: Read-only MCP contract.
Demo edition. The materials are undergoing editorial review.
Topics covered
- Host, client and server
- Tools and resources serve different roles
- Use the current SDK line
Host, client and server
MCP defines communication between an AI application and servers exposing data or tools. The host manages the user and model, a client connects to a particular server, and that server advertises permitted capabilities. The protocol grants no automatic filesystem access and pays for no inference. Our server returns only two fictional operational notes held in memory. It reads no home directory, executes no shell and makes no network calls, keeping the entire boundary inspectable before adding storage.
Tools and resources serve different roles
The lookup_note tool takes noteId and returns a record; lab://policy is a fixed-URI resource read as context. A resource URI need not be a browser address or disk file. ReadOnlyHint describes intent rather than enforcing operating-system permissions. Implementation and process permissions provide that enforcement. Even read-only tools can disclose private text to the host, so reading needs an authorization boundary too. Our catalog contains only openly described educational records without actual credentials or personal data.
Use the current SDK line
Verified documentation describes MCP2026-07-28 and stable TypeScript SDK v2 with separate server and client packages. The old @modelcontextprotocol/sdk belongs to v1; do not mix its import paths with v2 examples. Use JavaScript ESM on supported Node with Zod4 and record resolved dependencies in package-lock. Merely installing the library does not establish modern negotiation for every startup method. The serveStdio factory and legacy direct connection behave differently, which later checks examine explicitly.
npm init -y
npm pkg set type=module
npm install --save-exact @modelcontextprotocol/server @modelcontextprotocol/client zod@4
npm install --save-dev --save-exact @modelcontextprotocol/inspector
Practical assignment
Practice: Read-only MCP contract
Continue to learning