MCP JSON-RPC Server

MCP JSON-RPC Server

A beginner-friendly MCP-inspired JSON-RPC server built with Node.js, offering basic client-server interaction through an 'initialize' capabilities handshake and an 'echo' function.

Category
Visit Server

README

MCP JSON-RPC Client and Server Example

smithery badge

This repository contains a simple, beginner-friendly example of an MCP-inspired JSON‑RPC client and server implemented in JavaScript. The project demonstrates a basic communication flow using Node.js's built‑in modules without any external dependencies.

Overview

  • Server (server.js):

    • Listens on TCP port 4000.
    • Implements two JSON‑RPC methods:
      • initialize: Returns a basic capabilities object (advertising an "echo" tool).
      • echo: Echoes back the parameters provided by the client.
  • Client (client.js):

    • Connects to the server on port 4000.
    • Sends an initialize request followed by an echo request.
    • Logs the responses received from the server.

Prerequisites

  • Node.js installed on your system (v10 or later is recommended).

Getting Started

Installing via Smithery

To install MCP JSON-RPC Client and Server Example for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @melvincarvalho/mcpjs --client claude

Manual Installation

  1. Clone the Repository:

    git clone https://github.com/sandy-mount/mcpjs.git
    cd mcp-jsonrpc-example
    
  2. Run the Server:

    Open a terminal window and run:

    node server.js
    

    You should see a message like:

    Server listening on port 4000
    
  3. Run the Client:

    Open another terminal window and run:

    node client.js
    

    The client will connect to the server, send the initialize and echo requests, and display the responses.

How It Works

  • The server listens for incoming TCP connections on port 4000. When it receives a JSON‑RPC message (each terminated by a newline), it processes the request:

    • For the initialize method, it returns a JSON‑RPC response with basic capabilities and server info.
    • For the echo method, it returns the parameters that were sent in the request.
    • If an unknown method is requested, it responds with a JSON‑RPC error.
  • The client connects to the server, sends a JSON‑RPC initialize request, waits a short time, and then sends an echo request. Responses from the server are printed to the console.

Files

  • server.js — The JSON‑RPC server implementation.
  • client.js — The JSON‑RPC client implementation.

Customization

You can extend this example by:

  • Adding more JSON‑RPC methods to the server.
  • Implementing additional error handling and logging.
  • Experimenting with different transport protocols or adding TLS support.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Feel free to open issues or submit pull requests with improvements or suggestions.


Happy coding!

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured