MCP JSON-RPC Client and Server Example

@melvincarvalho/mcpjs

Demonstrate basic communication flow using JSON-RPC in JavaScript.

This project provides a simple, beginner-friendly example of an MCP-inspired JSON-RPC client and server implemented in JavaScript. The server listens on TCP port 4000 and implements two JSON-RPC methods: 'initialize' to return basic capabilities and 'echo' to echo back parameters provided by the client. The client connects to the server, sends requests, and logs the responses, showcasing a straightforward interaction model.

The server processes incoming JSON-RPC messages, handling requests for known methods and responding with appropriate JSON-RPC responses or errors for unknown methods. Users can extend the example by adding more methods, improving error handling, or experimenting with different transport protocols, making it a flexible starting point for learning about JSON-RPC and MCP integration.

This example is designed to be easy to understand and modify, making it suitable for developers looking to grasp the fundamentals of JSON-RPC communication in a Node.js environment.

Installation

Server Statistics

LicenseMIT
LocalNo
Published2/1/2025