Type Server Protocol (TSP) Overview

What is the Type Server Protocol?

The Type Server Protocol (TSP) is a specialized JSON-RPC protocol designed to facilitate communication between a type server and a client (such as an IDE). Unlike the Language Server Protocol (LSP), which is primarily intended for human-readable editor features like hover text and diagnostics, TSP provides structured, machine-readable type analysis data. This allows tools to programmatically consume type information—such as computed, declared, and expected types—without relying on fragile parsing of Markdown strings.

Why TSP Exists

Existing protocols like LSP are optimized for editor interaction rather than deep type-system integration. LSP's hover information is typically delivered as Markdown, which is excellent for display but difficult for automated refactoring tools, linters, or AI agents to parse reliably. TSP addresses this by returning structured, tagged type objects that represent the actual type graph, including classes, functions, unions, and modules. By standardizing this data, Microsoft aims to allow developers to swap out different type checkers (like Pylance or Pyrefly) while maintaining consistent behavior across various IDEs.

Core Architecture and Features

TSP functions as a companion to LSP, often running over the same connection. It introduces several key concepts to manage performance and state:

  • Snapshot-Based Analysis: A snapshot is a non-negative integer representing a point-in-time view of the workspace. Because type analysis is computationally expensive, results are bound to a specific snapshot. If a file changes, the server advances the snapshot, and the client must request updated information.
  • Multi-Connection Mode: To prevent high-volume type queries from blocking the main LSP connection, TSP supports optional secondary IPC channels. This allows for concurrent, read-only type queries while the main connection handles mutable workspace state and lifecycle events.
  • Capability Handshake: Clients and servers negotiate support for TSP features during the standard LSP initialization process, ensuring backward compatibility and graceful degradation if a server does not support the protocol.

Protocol Surface

TSP is intentionally lightweight, focusing on a small set of queries that provide deep insight into Python code:

  • typeServer/getComputedType: Returns the type inferred from code flow (e.g., after narrowing).
  • typeServer/getDeclaredType: Returns the type explicitly defined in the source code.
  • typeServer/getExpectedType: Returns the type required by the surrounding context.
  • typeServer/resolveImport: Provides resolution data for module imports.

Community Perspectives

The introduction of TSP has generated significant discussion regarding the fragmentation of the Python tooling ecosystem. While some developers appreciate the move toward structured data, others have raised concerns about the proliferation of Microsoft-led protocols.

"The real value of this protocol lies in moving from string-based information to structured data. LSP hover info is for humans; if a tool wants to use type info, it shouldn't have to guess the format. The key challenge is balancing the cost of computing full type graphs with the need for low-latency IDE responsiveness." — Hacker News user coindef

Critics have pointed out that the protocol is currently highly specific to Python's type system, leading to questions about whether it will remain a niche tool or evolve into a broader standard. Additionally, some maintainers of alternative Python tools, such as basedpyright, have expressed skepticism regarding the necessity of a separate protocol, while teams like Astral (the creators of Ruff) have indicated they intend to support it to ensure interoperability.

Sources

Related

  • Project
  • Project
  • Dispatch
  • Project
  • Project