{"id":14253,"library":"vscode-languageserver-protocol","title":"VSCode Language Server Protocol","description":"vscode-languageserver-protocol is the official TypeScript and JavaScript implementation of the Language Server Protocol (LSP), maintained by Microsoft. It provides the core data structures, types, and interfaces necessary for implementing language servers and clients that communicate via the LSP specification. The package is currently at stable version 3.17.5, with frequent `next` releases (like 3.17.6-next.17) indicating active development, often in sync with the broader `vscode-languageserver-node` monorepo which includes the `client` and `server` libraries. Its primary differentiator is being the canonical source for LSP definitions, ensuring strong type-safety and adherence to the protocol specification, which is crucial for interoperability between diverse editors and language tools. Unlike its companion packages (`vscode-languageserver` and `vscode-languageserver-client`), this package focuses solely on the protocol's message formats and type definitions, not on the communication transport layer.","status":"active","version":"3.17.5","language":"javascript","source_language":"en","source_url":"https://github.com/Microsoft/vscode-languageserver-node","tags":["javascript","typescript"],"install":[{"cmd":"npm install vscode-languageserver-protocol","lang":"bash","label":"npm"},{"cmd":"yarn add vscode-languageserver-protocol","lang":"bash","label":"yarn"},{"cmd":"pnpm add vscode-languageserver-protocol","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the underlying JSON-RPC message protocol for communication between client and server. The protocol package depends on its types.","package":"vscode-jsonrpc","optional":false}],"imports":[{"note":"Prefer ESM imports for type definitions in modern TypeScript/Node.js projects. CommonJS `require` is generally not recommended for this package's types.","wrong":"const InitializeParams = require('vscode-languageserver-protocol').InitializeParams;","symbol":"InitializeParams","correct":"import { InitializeParams } from 'vscode-languageserver-protocol';"},{"note":"All core protocol elements (like `RequestType`, `NotificationType`, `LSPAny`) are named exports, not default exports.","wrong":"import RequestType from 'vscode-languageserver-protocol';","symbol":"RequestType","correct":"import { RequestType } from 'vscode-languageserver-protocol';"},{"note":"Enums and basic types related to document synchronization and other core features are directly from the `vscode-languageserver-protocol` package, not the client or server runtimes.","wrong":"import { TextDocumentSyncKind } from 'vscode-languageserver/node';","symbol":"TextDocumentSyncKind","correct":"import { TextDocumentSyncKind } from 'vscode-languageserver-protocol';"},{"note":"While `vscode-languageserver-types` exists for basic types, `vscode-languageserver-protocol` provides the full, specified interfaces like `ServerCapabilities`.","wrong":"import type { ServerCapabilities } from 'vscode-languageserver-types';","symbol":"ServerCapabilities","correct":"import { ServerCapabilities } from 'vscode-languageserver-protocol';"}],"quickstart":{"code":"import {\n  InitializeParams,\n  TextDocumentSyncKind,\n  TextDocumentSyncOptions,\n  ServerCapabilities,\n  CompletionItemKind,\n  MarkupKind,\n  Connection,\n  InitializeRequest,\n  InitializeResult,\n  InitializeError,\n} from 'vscode-languageserver-protocol';\n\n// Define a custom initialization options interface\ninterface MyServerInitializationOptions {\n  enableCustomFeature: boolean;\n}\n\n// Example of how a server might define its capabilities,\n// leveraging the protocol types.\nconst serverCapabilities: ServerCapabilities = {\n  textDocumentSync: {\n    openClose: true,\n    change: TextDocumentSyncKind.Incremental,\n    willSave: true,\n    willSaveWaitUntil: true,\n    save: {\n      includeText: true,\n    },\n  } as TextDocumentSyncOptions,\n  completionProvider: {\n    resolveProvider: true,\n    triggerCharacters: ['.', ':'],\n    allCommitCharacters: ['\\n', '\\t'],\n    completionItem: {\n      labelDetailsSupport: true,\n    },\n    completionItemKinds: [\n      CompletionItemKind.Keyword,\n      CompletionItemKind.Variable,\n      CompletionItemKind.Function,\n    ],\n  },\n  hoverProvider: true,\n};\n\n// Types for a hypothetical server initialization logic\nfunction handleInitializeRequest(params: InitializeParams<MyServerInitializationOptions>): InitializeResult | InitializeError {\n    console.log(`Client requested initialization with custom feature enabled: ${params.initializationOptions?.enableCustomFeature}`);\n    if (params.processId === null) {\n        return {\n            jsonrpc: '2.0',\n            id: null,\n            error: {\n                code: -32602,\n                message: 'processId must not be null',\n            },\n        };\n    }\n    return {\n        capabilities: serverCapabilities,\n        serverInfo: {\n            name: 'MyLanguageServer',\n            version: '1.0.0',\n        },\n    };\n}\n\n// This connection object is typically provided by vscode-languageserver/node or browser\n// It's mocked here to show how protocol types fit in.\nconst mockConnection: Connection = {\n    sendRequest: (type, params) => Promise.resolve({ capabilities: {} }),\n    sendNotification: (type, params) => {},\n    onRequest: (type, handler) => {\n        if (type === InitializeRequest.type) {\n            // Simulate an incoming initialize request\n            handler({\n                processId: 123,\n                capabilities: {},\n                initializationOptions: { enableCustomFeature: true }\n            });\n        }\n    },\n    onNotification: (type, handler) => {},\n    listen: () => {},\n    dispose: () => {},\n} as Connection;\n\nmockConnection.onRequest(InitializeRequest.type, (params) => handleInitializeRequest(params));\n\nconsole.log('Protocol types defined and a mock handler registered for demonstration.');\n","lang":"typescript","description":"Demonstrates the definition of language server capabilities and the handling of an `InitializeRequest` using the types provided by `vscode-languageserver-protocol`, emphasizing its role as a type-only package for LSP definitions."},"warnings":[{"fix":"Monitor the `vscode-languageserver-node` GitHub repository for upcoming `4.x` protocol releases and consult their migration guides. Keep client and server implementations in sync with the protocol version.","message":"While `vscode-languageserver-protocol` is currently at `3.17.x` (LSP 3.17), the related `vscode-languageserver` (server implementation) and `vscode-languageserver-client` packages are actively developing towards `10.0.0-next` releases. This indicates significant breaking changes in the broader LSP ecosystem are anticipated, which may eventually lead to a `4.x` release of the protocol package itself with updated types and message structures, requiring careful migration. Previous major versions of the protocol have introduced breaking changes in message structures and interfaces (e.g., v2.x to v3.x).","severity":"breaking","affected_versions":">=3.17"},{"fix":"Always pair this protocol package with a corresponding client or server runtime package (e.g., `vscode-languageserver` for server-side logic or `vscode-languageclient` for VS Code extensions) to handle connection and message transport.","message":"This package provides only the TypeScript types and JavaScript interfaces for the Language Server Protocol messages. It does *not* include any runtime for establishing connections, sending messages, or running a language server/client. Developers must use `vscode-languageserver` (for Node.js servers) or `vscode-languageclient` (for VS Code extensions) for the actual communication runtime.","severity":"gotcha","affected_versions":">=3.0"},{"fix":"Ensure your `tsconfig.json` correctly configures `module` and `moduleResolution` (e.g., `\"module\": \"Node16\"`, `\"moduleResolution\": \"Node16\"`) to correctly resolve module paths, especially when working with newer Node.js versions or consuming pre-release client/server packages.","message":"The `vscode-languageserver-node` monorepo, which includes this package, has migrated to using `exports` property in `package.json` and targets `NodeJS 22.13.14` and `es2022` for recent `next` versions of client/server. This change might require adoption in `tsconfig.json` files around `module` and `moduleResolution` settings (e.g., `node16`).","severity":"gotcha","affected_versions":">=3.17.5"},{"fix":"For new projects, prefer ESM `import` statements. If migrating an existing CommonJS project, be aware that mixing CommonJS and ESM can introduce complexities, and a wrapper might be needed for VS Code extensions.","message":"Older versions or legacy setups might use CommonJS `require()` statements. While the package aims for broad compatibility, the ecosystem is moving towards ECMAScript Modules (ESM). Newer versions of the related `vscode-languageserver-node` packages (e.g., 10.x client/server) are built with ESM in mind.","severity":"deprecated","affected_versions":"All versions, especially >3.x"},{"fix":"Run `npm audit` regularly and apply suggested fixes. Prioritize updating `vscode-languageserver-protocol` and its related client/server packages to the latest stable or `next` versions that include security patches. Avoid `npm audit fix --force` unless you understand the potential breaking changes.","message":"The `npm audit` alerts related to transitive dependencies (e.g., `serialize-javascript`, `minimatch`, `qs`) are frequently addressed in `next` releases. It's crucial to regularly update your dependencies to the latest patch versions to benefit from security fixes, even if the core protocol itself isn't directly exploitable.","severity":"gotcha","affected_versions":"<3.17.6-next.17"}],"env_vars":null,"search_vec":"'3.17.5':54 '3.17.6':60 'activ':63 'adher':100 'broader':70 'canon':89 'client':40,79,127 'communic':42,144 'companion':118 'core':28 'crucial':107 'current':50 'data':29 'definit':93,140 'develop':64 'differenti':85 'divers':111 'editor':112 'ensur':94 'focus':130 'format':137 'frequent':56 'implement':15,36 'includ':77 'indic':62 'interfac':33 'interoper':109 'javascript':14,147 'languag':2,18,37,114 'languageserv':7,73,122,126 'layer':146 'librari':82 'like':59 'lsp':21,45,92 'maintain':22 'messag':136 'microsoft':24 'monorepo':75 'necessari':34 'next':57 'next.17':61 'node':74 'offici':11 'often':65 'packag':48,119,129 'primari':84 'protocol':4,8,20,103,134 'provid':26 'releas':58 'safeti':98 'server':3,19,38,81 'sole':131 'sourc':90 'specif':46,104 'stabl':52 'strong':95 'structur':30 'sync':67 'tool':115 'transport':145 'type':31,97,139 'type-safeti':96 'typescript':12,148 'unlik':116 'version':53 'via':43 'vscode':1,6,72,121,125 'vscode-languageserv':120 'vscode-languageserver-cli':124 'vscode-languageserver-nod':71 'vscode-languageserver-protocol':5","created_at":"2026-04-20T01:58:44.171874+00:00","updated_at":"2026-04-20T01:58:44.171874+00:00","problems":[{"fix":"Ensure correct named import syntax: `import { RequestType } from 'vscode-languageserver-protocol';`. Verify package version compatibility if you are defining custom request/notification types, as their structure has evolved.","cause":"Attempting to import a named export incorrectly or from a version that does not expose it.","error":"Cannot find name 'RequestType' / Module '\"vscode-languageserver-protocol\"' has no exported member 'RequestType'."},{"fix":"Always keep `vscode-languageserver-protocol`, `vscode-languageserver`, and `vscode-languageclient` packages synchronized to compatible major/minor versions to avoid runtime mismatches, as they are developed within the same monorepo.","cause":"Using types from `vscode-languageserver-protocol` but trying to use a `vscode-languageserver` or `vscode-languageclient` runtime that is significantly older or incompatible with the protocol version.","error":"TypeError: Cannot read properties of undefined (reading 'syncKind') or similar runtime errors when using types from this package with an old runtime."},{"fix":"Import `createConnection` from the appropriate package, typically `vscode-languageserver/node` for server implementations: `import { createConnection } from 'vscode-languageserver/node';`. The protocol package is for types only.","cause":"`createConnection` is part of the `vscode-languageserver/node` or `vscode-jsonrpc` package, not `vscode-languageserver-protocol`.","error":"Error: `createConnection` is not a function / Module 'vscode-languageserver-protocol' has no exported member 'createConnection'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"https://microsoft.github.io/language-server-protocol","github":"https://github.com/Microsoft/vscode-languageserver-node","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/vscode-languageserver-protocol","openapi_spec":null,"status_page":null,"smithery":null,"categories":["type-stubs"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}