logesh-kumar
MCP Serverlogesh-kumarpublic

mcp client server

A simple MCP example with client and server

Repository Info

1
Stars
1
Forks
1
Watchers
0
Issues
JavaScript
Language
-
License

About This Server

A simple MCP example with client and server

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

A Simple MCP Server and Client

This is a simple Model Context Protocol (MCP) server and client implementation that demonstrates how to expose and access weather information.

Server

The server is implemented in server.js. It provides the following capabilities:

  • Resources:

    • city://NewYork: Basic information about New York City
    • city://London: Basic information about London
    • city://Tokyo: Basic information about Tokyo
  • Tools:

    • get-weather: Get weather forecast for a city with parameters for city name and number of days
  • Prompts:

    • weather-advice: Get travel advice based on weather conditions

Client

The client is implemented in client.js. It demonstrates how to:

  • Connect to the MCP server
  • List available resources
  • Read a specific city resource
  • Call the weather forecast tool
  • Get a weather advice prompt

JSON-RPC Communication

This implementation uses JSON-RPC 2.0 as the underlying communication protocol between client and server. Key JSON-RPC concepts used:

  • Methods: Standard method names like resources/list, resources/read, tools/call, and prompts/get
  • Parameters: Input data sent with method calls
  • Request IDs: Unique identifiers to match requests with responses
  • Results/Errors: Structured response data or error information

The MCP SDK abstracts much of this, but understanding the protocol is helpful for debugging and customization. You can see the raw JSON-RPC messages by examining the console output.

Running the Server and Client

  1. Start the client:

    node client.js
    

    Starting the client will automatically start the server as a child process. The client will connect to the server and perform all the example operations.

  2. To start the server independently:

    node server.js
    

Transport Mechanism

This example uses stdio (standard input/output) as the transport mechanism between client and server. When the client is started, it spawns the server as a child process and communicates with it through stdin/stdout streams.

A custom logging transport is implemented to show the messages exchanged between the client and server. These messages are logged to the console in a human-readable format, which is helpful for understanding the protocol.

Troubleshooting

If you encounter issues with resource or prompt requests timing out, check the server implementation. The example includes direct message handling for certain request types to work around limitations in the current SDK version.

Quick Start

1

Clone the repository

git clone https://github.com/logesh-kumar/mcp-client-server
2

Install dependencies

cd mcp-client-server
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownerlogesh-kumar
Repomcp-client-server
LanguageJavaScript
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation