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-ts

v1.0.1

Published

TypeScript Client SDK for Model-Context Protocol

Downloads

9

Readme

An easier client SDK for MCP NPM Version MIT licensed

A thin wrapper around the official MCP SDK that just works everywhere - Node, Bun, Deno, and browsers without configuration headaches.

This is a client-only version of the MCP TypeScript SDK that provides tools for interacting with MCP servers.

Why this exists?

The official SDK has some funny quirks that make it difficult to use:

  • No more import failures due to missing .js extensions
  • No verbose subpath-only exports
  • Works seamlessly with Bun, Deno, and bundlers like Vite/Webpack
  • LLMs (Claude, GPT) can generate valid code without special documentation

Same functionality as the official SDK, just packaged to eliminate common developer frustrations.

Installation

npm install mcp-ts

That's it! All dependencies are automatically included - you don't need to install the Model Context Protocol SDK separately.

For detailed installation instructions for different project types (TypeScript, ESM, CommonJS), see INSTALL.md.

Usage

TypeScript (recommended)

import { MCPClient, MCPToolSpec } from "mcp-ts";

// Define your own return type for strong typing
interface CalculationResult {
  value: number;
  unit: string;
}

async function main() {
  // Create a client
  const client = await MCPClient.create("https://your-mcp-server.com/endpoint");

  // List available tools with proper typing
  const tools: MCPToolSpec[] = await client.listTools();

  // Call a tool with typed response
  const result = await client.callTool<CalculationResult>("calculator", {
    a: 5,
    b: 10,
    operation: "add",
  });

  // TypeScript knows the shape of the result
  console.log(`Result: ${result.value} ${result.unit}`);
}

// Properly handle the promise
main().catch((error) => console.error("Unhandled error:", error));

ESM (JavaScript)

import { MCPClient } from "mcp-ts";

// Create a client
const client = await MCPClient.create("https://your-mcp-server.com/endpoint");

// List available tools
const tools = await client.listTools();
console.log(tools);

// Call a tool
const result = await client.callTool("toolName", { param1: "value1" });
console.log(result);

CommonJS

const { MCPClient } = require("mcp-ts");

// Create a client
const client = await MCPClient.create("https://your-mcp-server.com/endpoint");

// Use client as with ESM

Testing

You can verify that the package and its dependencies are working correctly by running:

# Test both ESM and CommonJS imports
npm run test:full

# Test only ESM imports
npm run test:imports:esm

# Test only CommonJS imports
npm run test:imports:cjs

# Test TypeScript imports
npm run test:imports:ts

This will build the package and run test scripts that try to import and use the client.

If you're experiencing import issues, make sure:

  1. You're using the correct import syntax for your environment (see Usage section above)

  2. Your package.json has the correct configuration:

    {
      "type": "module" // For ESM projects
      // or remove this line for CommonJS projects
    }

TypeScript Integration

This package includes TypeScript type definitions and can be used in TypeScript projects without additional configuration. The main exports are:

  • MCPClient: The main client class
  • MCPToolSpec: Interface describing the structure of tools returned by listTools()

You can use generic type parameters with the callTool method to specify the expected response type:

interface MyResponse {
  status: string;
  data: number[];
}

const result = await client.callTool<MyResponse>("myTool", { param: "value" });
// result is typed as MyResponse

API Reference

MCPClient

The main client class for interacting with MCP servers.

Static Methods

  • static async create(endpoint: string): Promise<MCPClient> - Creates a client using SSE transport
  • static async createWithHTTP(endpoint: string): Promise<MCPClient> - Creates a client using HTTP transport

Instance Methods

  • async listTools(): Promise<MCPToolSpec[]> - Lists all available tools from the server
  • async callTool<T>(name: string, args: Record<string, unknown>): Promise<T> - Calls a tool with arguments

License

MIT