# vscode-ws-jsonrpc

> VSCode JSON RPC over WebSocket

Latest version **3.5.0** (published 2025-08-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install vscode-ws-jsonrpc
pnpm add vscode-ws-jsonrpc
yarn add vscode-ws-jsonrpc
bun add vscode-ws-jsonrpc
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 3.5.0 |
| Published | 2025-08-11 |
| First published | 2017-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20.10.0 |
| Dependencies | 1 |
| Unpacked size | 58.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1366 |
| Author | TypeFox GmbH |
| Maintainers | typefox-team, kaisalmen, spoenemann |

## Links

- npm: https://www.npmjs.com/package/vscode-ws-jsonrpc
- Repository: https://github.com/TypeFox/monaco-languageclient
- Homepage: https://github.com/TypeFox/monaco-languageclient/blob/main/packages/vscode-ws-jsonrpc/README.md
- Issues: https://github.com/TypeFox/monaco-languageclient/issues
- npm.io page: https://npm.io/package/vscode-ws-jsonrpc

## Dependencies (1)

- [vscode-jsonrpc](https://npm.io/package/vscode-jsonrpc.md) ~8.2.1

## Recent versions

- 3.5.0 (latest) — 2025-08-11
- 4.0.0-next.1 (next) — 2026-07-16
- 1.0.1-dev.0 (dev) — 2022-06-22
- 0.1.1 (es6) — 2019-08-08
- 4.0.0-next.0 — 2026-07-13
- 3.5.0-next.0 — 2025-08-08
- 3.4.0 — 2024-12-18
- 3.4.0-next.14 — 2024-12-18
- 3.4.0-next.13 — 2024-12-18
- 3.4.0-next.12 — 2024-12-18
- 3.3.2 — 2024-06-04
- 3.3.1 — 2024-04-10
- 3.3.0 — 2024-03-18
- 3.3.0-next.6 — 2024-03-18
- 3.3.0-next.5 — 2024-03-15
- … 33 more at https://npm.io/package/vscode-ws-jsonrpc/versions

## README

# VSCode WebSocket JSON RPC

NPM module to implement communication between a jsonrpc client and server over WebSocket.

## CHANGELOG

All changes are noted in the [CHANGELOG](https://github.com/TypeFox/monaco-languageclient/blob/main/packages/vscode-ws-jsonrpc/CHANGELOG.md).

## Getting Started

This is npm package is part of the <https://github.com/TypeFox/monaco-languageclient> mono repo. Please follow the main repositories [instructions]](<https://github.com/TypeFox/monaco-languageclient#getting-started>) to get started with local development.

## Usage

### Client side connection handling

```ts
import { MessageConnection, NotificationType } from 'vscode-jsonrpc';
import { listen } from 'vscode-ws-jsonrpc';

const webSocket = new WebSocket('ws://www.example.com/socketserver');
listen({
    webSocket,
    onConnection: (connection: MessageConnection) => {
        const notification = new rpc.NotificationType<string, void>('testNotification');
        connection.listen();
        connection.sendNotification(notification, 'Hello World');
    }
});
```

### Server side connection handling

```ts
import { createWebSocketConnection, ConsoleLogger, IWebSocket } from 'vscode-ws-jsonrpc';
import { NotificationType } from 'vscode-languageserver';

const socket: IWebSocket; // open the web socket
const logger = new ConsoleLogger();
const connection = createWebSocketConnection(socket, logger);
const notification = new NotificationType<string, void>('testNotification');
connection.onNotification(notification, (param: string) => {
  console.log(param); // This prints Hello World
});

connection.listen();
```

### Server side connection forwarding

```ts
import { IWebSocket, WebSocketMessageReader, WebSocketMessageWriter } from 'vscode-ws-jsonrpc';
import { createConnection, createServerProcess, forward } from 'vscode-ws-jsonrpc/server';
import { Message } from 'vscode-languageserver';

const socket: IWebSocket; // open the web socket
const reader = new WebSocketMessageReader(socket);
const writer = new WebSocketMessageWriter(socket);
const socketConnection = createConnection(reader, writer, () => socket.dispose())
const serverConnection = createServerProcess('Example', 'node', ['example.js']);
forward(socketConnection, serverConnection, message => {
    if (Message.isNotification(message)) {
        if (message.method === 'testNotification') {
            // handle the test notification
        }
    }
    return message;
});
```

## Examples

For a detailed list of examples please look at [this section](<https://github.com/TypeFox/monaco-languageclient#examples-overview>) in the main repository.

## License

[MIT](https://github.com/TypeFox/monaco-languageclient/blob/main/packages/vscode-ws-jsonrpc/LICENSE)

---
_Source: https://npm.io/package/vscode-ws-jsonrpc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
