MCP ExplorerExplorer

Mcp Websocket Typescript

@gugaioon 10 months ago
2 MIT
FreeCommunity
AI Systems
Implementation of a Web Socket Transport to MCP Typescript Official SDK

Overview

What is Mcp Websocket Typescript

mcp-websocket-typescript is an implementation of a WebSocket transport layer for the MCP (Message Control Protocol) TypeScript Official SDK, providing a solution for environments that require WebSocket connections.

Use cases

Use cases include integrating real-time features into web applications, enabling interactive user experiences, and supporting applications that require immediate data updates, such as gaming or financial trading platforms.

How to use

To use mcp-websocket-typescript, install the package via npm with ‘npm install mcp-websocket’. Then, import the necessary classes and create a WebSocket server transport, connecting it to the MCP server as shown in the example code.

Key features

Key features include support for WebSocket connections, which are essential for real-time communication in many production systems, as well as ease of integration with the existing MCP SDK.

Where to use

mcp-websocket-typescript can be used in applications that require real-time data transmission, such as chat applications, live notifications, and any system that benefits from low-latency communication.

Content

mcp-websocket

Transporte WebSocket para o SDK TypeScript do MCP (Message Control Protocol) da Anthropic.

O SDK oficial atualmente oferece apenas SSE (Server-Sent Events) como transporte no servidor.
Este projeto implementa suporte a WebSocket, útil para ambientes onde esse protocolo é necessário.


📦 Instalação

npm install mcp-websocket

Código de exemplo

import { McpServer } from "mcp-sdk"; // ou o caminho correto do SDK MCP
import { WebSocketServerTransport } from "mcp-websocket";

const mcpServer = new McpServer(serverInfo);
const transport = new WebSocketServerTransport(8080, "localhost");

mcpServer.connect(transport);

🧩 API

new WebSocketServerTransport(port: number, host?: string)

Cria um servidor WebSocket ouvindo na porta e host especificados.

💡 Motivação

A escolha por SSE no projeto oficial do MCP é baseada em escalabilidade.
No entanto, muitos sistemas em produção utilizam WebSocket e precisam desse tipo de conexão para comunicação em tempo real.

Este pacote oferece uma solução compatível enquanto o suporte oficial ainda está em discussão.

🤝 Contribuindo

Contribuições são bem-vindas!
Sinta-se à vontade para abrir issues, enviar PRs ou sugerir melhorias.

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers