npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mcp-client-kit

v0.1.1

Published

TypeScript/Node.js client library for connecting to multiple MCP (Model Context Protocol) servers

Readme

MCP Client Kit

npm version npm downloads

mcp-client-kit A TypeScript/Node.js client library for connecting to multiple Model Context Protocol (MCP) servers and aggregating their capabilities through a unified interface.

Features

  • Multi-Server Support: Connect to multiple MCP servers simultaneously
  • Multiple Transport Protocols: Support for SSE, HTTP Streaming, and stdio transports
  • JSON-RPC 2.0: Full JSON-RPC 2.0 protocol implementation
  • Aggregated API: Unified interface to interact with all connected servers
  • TypeScript: Full TypeScript support with type definitions
  • Authentication: Built-in support for Bearer token authentication

Installation

npm install mcp-client-kit

Quick Start

1. Create Configuration File

Create a mcp_servers.json file in your project root:

{
  "mcpServers": {
     "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "d:/DevSpaces/MNTWS/CVAWS"
      ]
    },
    "canva-dev": {
      "command": "npx",
      "args": ["-y", "@canva/cli@latest", "mcp"]
    },
    "leo-sse-mcp": {
      "type": "sse",
      "url": "http://localhost:3000/sse",
      "headers": {
        "Authorization": "Bearer leo-dGluaHRkLmluZm9AZ21haWwuY29t"
      }
    }
  }
}

2. Use the Client

import { McpClient } from 'mcp-client-kit';
import * as path from 'path';

async function main() {
  // Initialize the client
  const configPath = path.join(process.cwd(), 'mcp_servers.json');;
  const client = new McpClient(configPath);

  try {
    // Connect to all servers
    await client.connect();

    // List all available tools from all servers
    const tools = await client.listTools();
    console.log(`Found ${tools.length} tools`);

    tools.forEach((tool) => {
      console.log(`- [${tool.serverName}] ${tool.name}`);
    });

    // Call a specific tool
    const result = await client.callTool('leo-sse-mcp', 'my-tool', {
      param1: 'value1',
    });
    console.log('Result:', result);

  } finally {
    // Always disconnect when done
    await client.disconnect();
  }
}

main().catch(console.error);

Transport Types

SSE (Server-Sent Events)

{
  "type": "sse",
  "url": "http://localhost:3000/sse",
  "headers": {
    "Authorization": "Bearer token"
  }
}

HTTP Streaming

{
  "type": "httpStream",
  "url": "http://localhost:3000/stream",
  "headers": {
    "Authorization": "Bearer token"
  }
}

stdio (Local Process)

{
  "type": "stdio",
  "command": "node",
  "args": ["./mcp-server.js"],
  "env": {
    "DEBUG": "mcp:*"
  }
}

API Reference

McpClient

constructor(configPath: string)

Create a new MCP client instance.

  • configPath: Path to the mcp_servers.json configuration file

connect(): Promise<void>

Initialize and connect to all configured servers.

disconnect(): Promise<void>

Disconnect from all servers.

listTools(): Promise<IAggregatedTool[]>

List all tools from all connected servers. Each tool includes a serverName property indicating which server it belongs to.

listResources(): Promise<IAggregatedResource[]>

List all resources from all connected servers.

listPrompts(): Promise<IAggregatedPrompt[]>

List all prompts from all connected servers.

callTool(serverName: string, toolName: string, params?: unknown): Promise<unknown>

Execute a specific tool on a specific server.

  • serverName: Name of the server (from config)
  • toolName: Name of the tool to call
  • params: Optional parameters for the tool

readResource(serverName: string, uri: string): Promise<unknown>

Read a resource from a specific server.

getPrompt(serverName: string, promptName: string, args?: Record<string, unknown>): Promise<unknown>

Get a prompt from a specific server.

getConnectedServers(): string[]

Get list of connected server names.

isServerConnected(serverName: string): boolean

Check if a specific server is connected.

Examples

See the examples directory for more usage examples:

  • basic-usage.ts - Basic client usage
  • advanced-usage.ts - Advanced features and error handling
  • stdio-transport.ts - Using stdio transport for local servers

Testing

The library includes several test scripts in the tests directory:

Quick Test (Single Server)

npm run test:quick

Comprehensive Test (All Servers)

npm run test:all

Local Server Test

npm run test:local

Development

Build

npm run build

Watch Mode

npm run build:watch

Run Unit Tests

npm test

Lint

npm run lint

Architecture

For more detailed architecture information, see PROJECT_STRUCTURE.md.

Documentation

Additional documentation is available in the docs directory:

License

MIT

Contributors

Init by me & Claude and I want to make contributing to this project as easy and transparent as possible. So, just simple do the change then create PR