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

@reaatech/mcp-server-doctor-client

v1.0.0

Published

MCP transport client with auto-negotiation for stdio, SSE, and streamable HTTP

Readme

@reaatech/mcp-server-doctor-client

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

MCP transport client with auto-negotiation across stdio, SSE, and streamable HTTP transports. Handles the full MCP lifecycle — initialize, tools/list, tools/call, ping, and graceful disconnect — with credential injection and intelligent fallback.

Installation

npm install @reaatech/mcp-server-doctor-client
# or
pnpm add @reaatech/mcp-server-doctor-client

Feature Overview

  • Auto-negotiation — detects transport type from endpoint format (URL → HTTP/SSE, command string → stdio)
  • Three transportsStdioTransport, SSETransport, StreamableHTTPTransport
  • Credential injection — API key, Bearer token, and OAuth credentials via headers (HTTP/SSE) or env vars (stdio)
  • Fallback — HTTP → SSE auto-fallback on connection failure
  • Private network detection — warns when connecting to localhost or private IP ranges
  • Dual ESM/CJS output — works with import and require

Quick Start

import { createDoctorClient } from "@reaatech/mcp-server-doctor-client";

// Connect to an MCP server over HTTP
const client = createDoctorClient("http://localhost:8080", {
  transport: "auto",
  auth: "none",
  timeout: 30000,
  concurrency: 10,
  verbose: false,
});

await client.connect();

// Discover tools
const tools = await client.listTools();
console.log(`Found ${tools.length} tools`);

// Call a tool
const result = await client.callTool("echo", { message: "hello" });

// Send a raw JSON-RPC request
await client.sendRequest("ping", {});

await client.disconnect();

API Reference

createDoctorClient(endpoint: string, options: DiagnosticOptions): MCPClient

Factory function that creates and returns an MCPClient instance.

MCPClient (interface)

| Method | Description | |--------|-------------| | connect() | Connects to the MCP server, negotiates transport, calls initialize and tools/list | | disconnect() | Disconnects from the server and cleans up resources | | sendRequest(method, params?) | Sends a raw JSON-RPC 2.0 request and returns the result | | listTools() | Returns the list of tools discovered during connect() | | callTool(name, args) | Calls a tool by name with arguments (wraps tools/call) | | getSessionId() | Returns the MCP session ID (null for non-HTTP transports) | | getServerInfo() | Returns the server info object from the initialize response |

Transport Negotiation

The transport option controls behavior:

| Value | Behavior | |-------|----------| | "auto" | URL → HTTP (with SSE fallback), non-URL → stdio | | "http" | Force streamable HTTP transport | | "sse" | Force SSE with automatic endpoint discovery | | "stdio" | Spawn the endpoint as a child process; communicates via stdin/stdout |

Auth Modes

| Mode | HTTP/SSE Behavior | Stdio Behavior | |------|-------------------|----------------| | "none" | No auth headers | No env vars | | "api-key" | X-Api-Key header | MCP_API_KEY env var | | "bearer" | Authorization: Bearer ... header | MCP_BEARER_TOKEN env var | | "oauth" | Authorization: Basic ... (client credentials) | MCP_OAUTH_CLIENT_ID + MCP_OAUTH_CLIENT_SECRET env vars |

Transports

All transports implement the same interface and can be used directly if you need finer control:

import { StreamableHTTPTransport } from "@reaatech/mcp-server-doctor-client";

const transport = new StreamableHTTPTransport({
  url: "http://localhost:8080",
  timeout: 30000,
  headers: { "X-Api-Key": "secret" },
});
await transport.connect();
const result = await transport.sendRequest("ping", {});
await transport.disconnect();

| Transport | Use Case | |-----------|----------| | StreamableHTTPTransport | Stateless HTTP JSON-RPC with session ID tracking | | SSETransport | SSE-based endpoint discovery + bidirectional RPC via POST | | StdioTransport | Spawns a child process; communicates over stdin/stdout |

TransportError

All transport errors are thrown as TransportError instances with optional JSON-RPC 2.0 fields:

import { TransportError } from "@reaatech/mcp-server-doctor-client";

try {
  await transport.sendRequest("bad_method", {});
} catch (error) {
  if (error instanceof TransportError) {
    console.log(error.rpcCode);  // -32601
    console.log(error.rpcData);  // optional error data
  }
}

Request Builders

Low-level JSON-RPC 2.0 request builders are also exported:

| Function | Description | |----------|-------------| | buildInitializeRequest(id?) | Build an initialize request object | | buildListToolsRequest(id?) | Build a tools/list request object | | buildToolCallRequest(name, args, id?) | Build a tools/call request object | | buildPingRequest(id?) | Build a ping request object |

Usage Patterns

With Authentication

const client = createDoctorClient("http://localhost:8080", {
  transport: "http",
  auth: "bearer",
  bearerToken: process.env.MCP_BEARER_TOKEN,
  timeout: 30000,
  concurrency: 10,
  verbose: false,
});
await client.connect();

Stdio Transport

const client = createDoctorClient("/usr/local/bin/mcp-server", {
  transport: "stdio",
  auth: "none",
  timeout: 30000,
  concurrency: 10,
  verbose: false,
});
await client.connect();

Programmatic Transport Access

import { StreamableHTTPTransport } from "@reaatech/mcp-server-doctor-client";

const http = new StreamableHTTPTransport({
  url: "http://localhost:8080",
  timeout: 15000,
  headers: { "Content-Type": "application/json" },
});
await http.connect();
const result = await http.sendRequest("ping", {});
console.log(http.getSessionId()); // "session-123"
await http.disconnect();

Related Packages

License

MIT