<!-- llms-explorer concept facts · https://llms-explorer.com/tree/mcp-server-development/ · pack 2026-09-08 · ~2061 tokens -->

# MCP Server Development

> MCP uses JSON-RPC 2.0 with a three-layer model: Host (AI application) → Client (stateful session manager) → Server (exposes tools, resources, prompts).

Parent: [AI & LLM Engineering](https://llms-explorer.com/tree/ai-llm-engineering/) · 9 facets · 31 facts · page: https://llms-explorer.com/tree/mcp-server-development/

## Architecture

- MCP uses JSON-RPC 2.0 with a three-layer model: Host (AI application) → Client (stateful session manager) → Server (exposes tools, resources, prompts). — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#architecture`

## stdio

- Communication via stdin/stdout of a child process — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#stdio`
- Zero network overhead, inherently single-client — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#stdio`
- Default for local developer tools and desktop integrations — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#stdio`

## Streamable HTTP (introduced March 2026, replaces deprecated SSE)

- POST for client→server requests — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#streamable-http-introduced-march-2026-replaces-deprecated-sse`
- GET for SSE notifications (server→client) — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#streamable-http-introduced-march-2026-replaces-deprecated-sse`
- DELETE to terminate sessions — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#streamable-http-introduced-march-2026-replaces-deprecated-sse`

## Security: OAuth 2.1 + PKCE

- Mandatory for public remote MCP servers since November 2025. — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#security-oauth-21-pkce`
  - Resource indicators (RFC 8707): bind tokens to one server - blocks cross-server replay — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#security-oauth-21-pkce`
  - Refresh rotation: for public clients, rotate refresh tokens on each use — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#security-oauth-21-pkce`
  - NEVER forward client tokens to backend services — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#security-oauth-21-pkce`

## Best practices checklist

- [ ] Zod/Pydantic input validation - never trust raw LLM arguments — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#best-practices-checklist`
- [ ] Health checks for production deployments — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#best-practices-checklist`
- [ ] OAuth 2.1 + PKCE for any public-facing remote server — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#best-practices-checklist`
- [ ] Streamable HTTP (not deprecated SSE) for all new remote servers — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#best-practices-checklist`
- [ ] Structured logging and telemetry for production observability — source: `https://llms-explorer.com/sources/mdb-context-hub/mcp-servers/#best-practices-checklist`

## Where this helps

- Deciding which MCP transport to use for a new server — stdio for local developer tools and desktop integrations, Streamable HTTP for a remote, multi-client server. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*
- Securing a public-facing remote MCP server, where OAuth 2.1 + PKCE has been mandatory since November 2025 and resource-indicator binding (RFC 8707) is needed to block cross-server token replay. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*
- Migrating an existing SSE-based remote MCP server to the current Streamable HTTP transport introduced in March 2026. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*
- Reviewing a new MCP server before shipping it, using the pack's best-practices checklist — input validation, health checks, OAuth, structured logging — as a concrete gate. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*

## Project ideas

- Build a local stdio-based MCP server for a personal developer tool, taking advantage of its zero network overhead and single-client simplicity. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*
- Build a remote MCP server on Streamable HTTP with POST for requests, GET for SSE notifications, and DELETE for session termination, replacing an older SSE-only implementation. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*
- Wire OAuth 2.1 + PKCE into a public remote MCP server, including resource-indicator token binding and refresh-token rotation for public clients. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*
- Add Zod or Pydantic input validation on every tool so the server never trusts raw LLM-generated arguments directly. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*

## Antipatterns

- Forwarding a client's OAuth token to a backend service instead of minting a scoped token for that service — the pack's security guidance explicitly forbids forwarding client tokens downstream. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*
- Building a new remote MCP server on the deprecated SSE transport instead of Streamable HTTP, which replaced it as of March 2026. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*
- Skipping resource-indicator binding (RFC 8707) on tokens, which leaves a public server exposed to cross-server token replay. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*
- Trusting raw LLM tool-call arguments without schema validation, on the assumption that a well-behaved client won't send malformed input. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*

## Known issues

- This pack's content is a compressed checklist rather than a full protocol reference — it names the requirements (OAuth 2.1 + PKCE, Streamable HTTP, structured logging) without walking through implementation, so building a compliant server still requires the fuller MCP spec. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*
- Refresh-token rotation is specified here for public clients only; confidential clients follow a different rotation posture that this pack doesn't spell out. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*
- stdio's zero-network-overhead simplicity comes at the cost of being inherently single-client — it's the wrong transport the moment more than one client needs to talk to the same server instance. — [source](https://llms-explorer.com/tree/mcp-server-development/) *(AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.)*
