Microsoft Announces Type Server Protocol, Extension of Language Server Protocol
Microsoft has published the Type Server Protocol (TSP), a JSON-RPC[1] protocol for requesting Python analysis data from a type server. A type server maintains the type-analysis state for a workspace and answers requests for the protocol version, snapshots, Python search paths, import resolution, and type queries covering computed, declared, and expected types. TSP reuses Language Server Protocol[2] (LSP) data shapes and conventions such as Position and Range, represents URIs as strings the same way LSP does, and prefixes its methods with typeServer/; the authoritative definitions are typeServerProtocol.ts, tsp.json, and tsp.schema.json in the pylance-release repository. Compatibility between client and server is checked with semantic version strings: while the protocol is in the 0.x line, minor version changes may be breaking, and patch version changes remain backward compatible within the same minor line.
A client starts a type server and communicates with it over the main JSON-RPC connection using a transport the server supports, such as stdio[3] or Node IPC[4]; when stdio is used, stdout must be reserved for JSON-RPC protocol messages. In a typical session, the client and server initialize shared workspace state through the LSP initialize and initialized messages, the client verifies the version with typeServer/getSupportedProtocolVersion and obtains the first snapshot identifier with typeServer/getSnapshot, and it then sends type-query, import-resolution, or search-path requests that include the current snapshot. The server sends typeServer/snapshotChanged when prior type results are no longer valid, for example after opened-file changes, closed files, configuration changes, watched-file changes, dependency changes, or cache resets. A snapshot is a non-negative integer that identifies a point-in-time view of the analysis state; identifiers must not decrease during a session, and type handles, declarations, and symbols are valid only for the snapshot in which they were returned.
An optional multi-connection mode lets a client open extra read-only, TSP-only channels to the same server, for example for high-volume type queries or background workers that should not block the main connection; it is enabled only after both sides advertise the typeServerMultiConnection capability during LSP initialization and their supportedTransports lists share at least one transport, currently ipc. All state-changing traffic, including initialization, document synchronization, and the typeServer/connection control request, remains on the main connection.
Read the original github.comDiscussion on GeekNews
Sources
-
KRGeekNews KO
Type Server Protocol - Python 타입 분석 데이터를 조회하는 JSON-RPC 프로토콜
-
github.com
Type Server Protocol



