Get the FREE Ultimate OpenClaw Setup Guide →

mcp-client

A simple MCP example with client and server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio logesh-kumar-mcp-client-server node server.js

How to use

This MCP server provides a simple Weather information service built with a basic server-client pair. The server exposes city resources for New York, London, and Tokyo, and a tool called get-weather to fetch a weather forecast for a given city over a specified number of days. A weather-advice prompt is also available to generate travel recommendations based on current weather conditions. The client demonstrates how to connect, list and read resources, invoke the weather forecast tool, and request weather-based advice. The interaction uses JSON-RPC 2.0 under the hood, with methods like resources/list, resources/read, tools/call, and prompts/get. When you run the client, it starts the server as a child process and communicates via standard input/output.

How to install

Prerequisites:

  • Node.js (LTS) installed
  • Basic familiarity with running Node scripts in a local environment

Installation steps:

  1. Clone the repository: git clone https://github.com/slug/mcp-client cd mcp-client

  2. Install dependencies (if a package.json is present): npm install

  3. Run the server independently (optional): node server.js

  4. Run the client (which will also start the server as a child process): node client.js

Notes:

  • The server runs on Node.js and uses a simple in-process JSON-RPC mechanism via stdio when started by the client.
  • If you modify the code, ensure server.js and client.js paths remain correct relative to your working directory.

Additional notes

Tips and common issues:

  • Transport: The example uses stdio (stdin/stdout) for communication between client and server. If you run the server independently, you may need a different transport layer.
  • Tools and prompts: Use the client to list resources, read city data, call get-weather for a city with a number of days, and request weather-advice prompts.
  • Debugging: The console will display raw JSON-RPC messages. Use these to verify method names (resources/list, resources/read, tools/call, prompts/get) and parameter shapes.
  • Environment: The mcp_config currently wires the server as a Node.js process with no required environment variables by default. If you introduce env vars (e.g., API keys, config toggles), add them under the env section for the server entry.
  • Extensibility: The server supports adding more city resources or additional tools and prompts by extending server.js. Ensure the client is updated to reflect any new endpoints.

Related MCP Servers

Sponsor this space

Reach thousands of developers