GPT-Talk

Model Context Protocol: how MCP works and how to build on it

What MCP is, how it standardizes tool calling for LLMs, and how to build an MCP server that exposes your data or APIs to ChatGPT, Claude, and Cursor.

TL;DR
The Model Context Protocol (MCP) is an open standard, originally proposed by Anthropic, that lets LLMs call any tool or data source through a single contract. This guide covers the architecture, transports, and how to build an MCP server for your own product.
MCP is an open standard for LLM tool calling. Clients (ChatGPT, Claude, Cursor) talk to servers over JSON-RPC and consume three primitives: tools, resources, and prompts.

How to

  1. Install the SDK and scaffold the project

    Run npm i @modelcontextprotocol/sdk. Create src/server.ts and src/index.ts; set type=module and bin in package.json.

  2. Declare the three primitives: tools / resources / prompts

    Tools are callables with input schemas; resources are structured data sources (files, DB, API); prompts are reusable templates. Return them from ListTools / ListResources / ListPrompts.

  3. Pick a transport: stdio / Streamable HTTP / SSE

    Local subprocesses: stdio. Cloud-hosted: Streamable HTTP. Legacy clients: SSE. For local testing stdio is enough.

  4. Write a minimal tool and self-test it

    For example server.setRequestHandler(CallToolRequestSchema, ...) for an echo tool. Verify ListTools + CallTool with MCP Inspector or the SDK's test client.

  5. Wire up ChatGPT / Claude / Cursor and add OAuth

    Register OAuth 2.0 metadata on the server, hook up your own auth backend. Document the per-host integration steps in the README. Before launch, run a prompt-injection mitigation checklist.

Model Context Protocol: how MCP works and how to build on it

MCP is an open standard for LLM tool calling. Clients (ChatGPT, Claude, Cursor) talk to servers over JSON-RPC and consume three primitives: tools, resources, and prompts.

1. Overview

The Model Context Protocol (MCP) is an open standard, originally proposed by Anthropic, that lets LLMs call any tool or data source through a single contract. This guide covers the architecture, transports, and how to build an MCP server for your own product.

2. Key points

  • Three roles: Hosts (the chat product), Clients (the SDK), Servers (your service)
  • Transports: stdio for local subprocesses, Streamable HTTP for cloud, SSE for older servers
  • Tools are callables with an input schema; Resources are structured data sources; Prompts are reusable templates
  • A minimal TypeScript MCP server is usually 50–200 lines using @modelcontextprotocol/sdk
  • Before shipping: OAuth auth, rate limits, allowlist of sensitive tools to avoid prompt-injection abuse

3. How it works

The sections below unpack each point. Skim alongside the OpenAI documentation for full context.

4. Practical steps

  1. Define 'done' up front — what does success look like?
  2. Pick the right model using the comparison above.
  3. Run the minimal example end to end; record parameters and the model version.
  4. Integrate into your existing code.
  5. Monitor logs and failure modes; review weekly.

5. Common errors and fixes

  • 401: invalid or expired API key — rotate it.
  • 429: rate limit hit — enable exponential backoff retries.
  • 400: bad request — verify the model name and messages shape.
  • Poor quality output: try a different model, add few-shot examples, trim the prompt.

6. Next steps

Once you are comfortable here, continue with:

  • ChatGPT Complete Guide (2026): From Beginner to Expert
  • Prompt Engineering Core Patterns: 8 Templates That 2x GPT Output
  • OpenAI API Beginner: Your First GPT-5.6 Call

Key points

  • Three roles: Hosts (the chat product), Clients (the SDK), Servers (your service)
  • Transports: stdio for local subprocesses, Streamable HTTP for cloud, SSE for older servers
  • Tools are callables with an input schema; Resources are structured data sources; Prompts are reusable templates
  • A minimal TypeScript MCP server is usually 50–200 lines using @modelcontextprotocol/sdk
  • Before shipping: OAuth auth, rate limits, allowlist of sensitive tools to avoid prompt-injection abuse

Frequently asked questions

Anthropic introduced MCP in late 2024 as an open-source protocol, but it is vendor-neutral by design — the spec and SDKs live in the modelcontextprotocol GitHub organization and ChatGPT, Claude, Cursor, and others all consume MCP servers. Think of it as a USB-C connector for LLM tool calling rather than a single-vendor API.

Official references

Subscribe to GPTMap Weekly

One email every Monday: curated OpenAI updates, deep dives, and best practices. No ads, unsubscribe anytime.

GPTMap EditorialPublished 2026-07-12Updated 2026-07-14 2 min read
Test environment (EEAT)
Last tested: 2026-07-14
Model used: gpt-5.6