The Type Server Protocol (TSP) is a JSON-RPC protocol for querying Python type analysis data. A type server maintains type-analysis state for a workspace and responds to requests for protocol version, snapshots, Python search paths, import resolution, and type queries. It uses Language Server Protocol (LSP) data shapes and conventions, representing URIs as strings consistent with LSP standards.
TSP methods utilize the "type Server/" prefix. The protocol artifacts in this folder serve as authoritative definitions: "Type Script Interfaces and Request Types" defines interfaces, "tsp.json" is the machine-readable model, and "tsp.schema.json" provides the JSON schema. Versioning uses semantic strings; while in the 0.x line, minor version changes may be breaking, while patch changes maintain backward compatibility within the same minor line.
The protocol initializes through standard LSP messages, with clients verifying compatibility and obtaining snapshot identifiers. Multi-connection mode offers an optional performance feature allowing read-only channels for high-volume queries, though single-connection mode remains the requirement for protocol correctness. Capability negotiation occurs during the LSP initialize handshake, advertising supported transport kinds for extra TSP channels.
Source: Hacker News · Summarized by HeadlinesBriefing