Model Context Protocol TypeScript SDK: Build MCP Servers and Clients

Model Context Protocol TypeScript SDK: Build MCP Servers and Clients

Summary

The `modelcontextprotocol/typescript-sdk` is the official TypeScript SDK for interacting with Model Context Protocol (MCP) servers and clients. It provides a standardized way for applications to offer context to Large Language Models (LLMs), separating context provision from LLM interaction. Developers can use it to easily create MCP servers that expose resources, prompts, and tools, as well as build MCP clients to connect to any MCP server.

Repository Info

Updated on December 9, 2025
View on GitHub

Tags

Click on any tag to explore related repositories

Introduction

The modelcontextprotocol/typescript-sdk is the official TypeScript SDK for the Model Context Protocol (MCP). This protocol enables applications to provide context for Large Language Models (LLMs) in a standardized manner, decoupling context provision from LLM interaction. The SDK implements the full MCP specification, simplifying the creation of MCP servers that expose resources, prompts, and tools, as well as the development of MCP clients that can connect to any MCP server using standard transports like stdio and Streamable HTTP.

Installation

To get started with the Model Context Protocol TypeScript SDK, install it via npm:

npm install @modelcontextprotocol/sdk zod

Note that zod is a required peer dependency for schema validation, ensuring robust data handling within your applications. The SDK is compatible with Zod v3.25 or later.

Examples

The SDK ships with a comprehensive set of runnable examples under the src/examples directory, designed to help you quickly understand and implement its capabilities. A quick start guide demonstrates an end-to-end interaction, featuring an example Streamable HTTP server and an interactive client.

You can explore various scenarios, including different server types (stateful, stateless, JSON response mode), client interactions (interactive, parallel tool calls, OAuth), and advanced capabilities like form and URL elicitation, sampling, and tasks. These examples provide practical insights into building sophisticated LLM-powered applications.

Why Use It

The Model Context Protocol TypeScript SDK offers a robust solution for integrating LLMs into applications by standardizing context provision. It simplifies the development process with clear APIs for creating servers and clients, supporting various transports. Its rich feature set, including tools for LLM actions, resources for data exposure, reusable prompts, and advanced capabilities like sampling and elicitation, empowers developers to build sophisticated and interactive LLM-powered applications efficiently. This standardization ensures better interoperability and maintainability for your LLM integrations.

Links

For more in-depth information and to explore the Model Context Protocol further, refer to the official documentation: