JSPM

@codelytv/mcp-client

0.7.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 235
  • Score
    100M100P100Q98710F
  • License GPL-3.0

A typed TypeScript client for Model Context Protocol (MCP) servers

Package Exports

  • @codelytv/mcp-client
  • @codelytv/mcp-client/dist/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@codelytv/mcp-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@codelytv/mcp-client

A TypeScript test client for Model Context Protocol (MCP) servers that provides a convenient way to test MCP functionality in your test suites.

Installation

npm install --save-dev @codelytv/mcp-client

Usage

Basic Example

import { McpClient } from '@codelytv/mcp-client';

const mcpClient = new McpClient("stdio", [
  "npx",
  "ts-node",
  "./src/app/mcp/server.ts",
]);

await mcpClient.connect();

// List available tools
const tools = await mcpClient.listTools();
console.log('Available tools:', tools.names());

// Call a tool
const response = await mcpClient.callTool('search-course-by-id', { id: 'course-123' });

// List resources
const resources = await mcpClient.listResources();
console.log('Available resources:', resources.uris());

// Read a resource
const resource = await mcpClient.readResource('courses://all');

await mcpClient.disconnect();

HTTP Transport

const mcpClient = new McpClient("http", ["http://localhost:3000/mcp"]);

API

McpClient

The main client class for interacting with MCP servers.

Constructor

  • new McpClient(transport: "stdio" | "http", args: string[])

Methods

  • connect() - Connect to the MCP server
  • disconnect() - Disconnect from the MCP server
  • listTools() - List available tools
  • callTool(name: string, args?: Record<string, unknown>) - Call a tool
  • listResources() - List available resources
  • readResource(uri: string) - Read a resource
  • listResourceTemplates() - List resource templates
  • completeResourceTemplateParam(uri: string, paramName: string, textToComplete: string) - Complete resource template parameters
  • listPrompts() - List available prompts
  • getPrompt(name: string, args?: Record<string, unknown>) - Get a prompt

License

See LICENSE