The TSP architecture separates mutable workspace state on the main channel from optional read‑only IPC channels for high‑volume queries.
*Microsoft's Type Server Protocol (TSP) defines a JSON‑RPC interface for Python analysis in Pylance. The spec adds multi‑connection IPC mode and strict version handshakes, shaping how editors query type data.*
Microsoft has published the definitive specification for its Type Server Protocol (TSP), the JSON‑RPC interface that powers Python type analysis in the Pylance language server. The 271‑line document lays out every request, response shape and versioning rule that client editors must follow to query type information, import resolution and workspace snapshots. By reusing Language Server Protocol data structures such as Position and Range, TSP promises seamless integration with existing LSP tooling while carving out its own namespace under the typeServer/ prefix. The release also introduces a multi‑connection mode, allowing high‑volume read‑only queries to run on separate IPC channels without stalling the main JSON‑RPC stream. For developers building IDE extensions or custom analysis pipelines, the spec is now the single source of truth for compatibility checks and transport negotiation. The protocol defines a strict semantic‑version handshake, where clients call typeServer/getSupportedProtocolVersion and abort if the returned string falls outside the expected 0.x line. It also enumerates the exact sequence of initialization, snapshot acquisition and type‑query calls that a compliant client must follow.
TSP is a JSON‑RPC protocol designed to expose Python type‑analysis data from a dedicated type server. The server holds the type‑analysis state for an entire workspace and answers requests for protocol version, snapshots, Python search paths, import resolution and three categories of type queries: computed, declared and expected types. All method names are prefixed with typeServer/. The protocol mirrors Language Server Protocol shapes where useful, reusing Position, Range and URI string formats. Clients interact with the server over a single JSON‑RPC channel, typically stdio or Node IPC, and may supplement that with optional read‑only channels. The specification lives in three artifacts: typeServerProtocol.ts, tsp.json and tsp.schema.json, which together define the TypeScript interfaces, the machine‑readable model and its JSON schema.
TSP tracks compatibility with semantic version strings. While the protocol remains in the 0.x line, any minor version bump may introduce breaking changes; patch releases stay backward compatible within the same minor line. The initial release, 0.1.0, defined the core request set. Version 0.2.0 added new request types and fields. Version 0.3.0 switched to more complex type shapes. Version 0.4.0 introduced a Type union and stub‑based payloads. Finally, 0.4.1 added multi‑connection negotiation and the typeServer/connection control request. Clients must query typeServer/getSupportedProtocolVersion at startup and verify that the returned semver string aligns with the version they expect, otherwise they must abort the session.
A client launches the type server and establishes the main JSON‑RPC connection using a transport the server supports, such as stdio or Node IPC. When stdio is chosen, stdout is reserved exclusively for JSON‑RPC messages. The client then performs a standard LSP initialize and initialized exchange to share workspace and document state. After that, the client calls typeServer/getSupportedProtocolVersion to confirm compatibility, followed by typeServer/getSnapshot to receive the first snapshot identifier. Subsequent type‑query, import‑resolution or search‑path requests must include this snapshot. If earlier results become stale, the server emits typeServer/snapshotChanged. The main connection retains ownership of mutable workspace state, document synchronization and connection control, while any extra channels remain read‑only.
Multi‑connection mode is an optional performance feature that lets a client open additional local channels for read‑only TSP requests while the main connection continues to manage mutable state. The client advertises its support under capabilities.experimental.typeServerMultiConnection, listing supportedTransports such as ipc. The server mirrors this capability in its initialize response. If both sides list at least one common transport, the session may switch to multi‑connection mode; otherwise it stays single‑connection and the client must not send typeServer/connection. To open an extra channel, the client sends a typeServer/connection request on the main link with a JSON payload specifying type "open", kind "ipc" and an args array containing the IPC endpoint. The server validates, connects, and returns success:true or false with a short message.
TSP is a JSON‑RPC protocol that lets a type server provide Python analysis data such as type queries, import resolution, search paths and snapshots, using LSP‑style data shapes and methods prefixed with typeServer/.
Multi‑connection mode lets a client open extra read‑only IPC channels after both sides advertise the typeServerMultiConnection capability; the client sends a typeServer/connection request with kind "ipc" and the server validates and returns success:true if it opens the channel.
The specification currently supports the built‑in transport kind "ipc" for extra connections; the main connection may use stdio or Node IPC.
The TSP specification cements Microsoft’s approach to Python type analysis as a rigorously versioned, extensible service. By exposing a clear multi‑connection pathway, it gives IDEs and tooling pipelines the ability to scale read‑only queries without compromising the stability of the primary workspace channel. As editors adopt the protocol, any deviation from the defined handshake or transport negotiation will result in immediate incompatibility, forcing rapid alignment. The next iteration will likely extend transport options beyond ipc, but for now the spec sets a hard baseline that developers must follow to stay in sync with Pylance’s evolving analysis engine.
Sources: [GitHub - microsoft/pylance-release type-server-protocol.md]