# mcp-client

> MCP Client

This repository provides a convenient Node.js client for the Model Context Protocol (MCP), abstracting away complexities and offering a more user-friendly API for interacting with MCP servers. This repository provides

## Overview

- **Category:** Developer Tools
- **Language:** TypeScript
- **Stars:** 101
- **Forks:** 2
- **Owner:** punkpeye
- **GitHub:** https://github.com/punkpeye/mcp-client
- **Homepage:** https://glama.ai/mcp/clients
- **Created:** 2025-03-11T04:25:57+00:00
- **Updated:** 2025-03-28T05:09:46+00:00
- **Source:** https://model-context-protocol.com/clients/nodejs-mcp-client-model-context-protocol

## Setup

## Setup

To create a client:

```ts
import { MCPClient } from "mcp-client";

const client = new MCPClient({
  name: "Test",
  version: "1.0.0",
});
```

To connect using `stdio`:

```ts
await client.connect({
  type: "stdio",
  args: ["--port", "8080"],
  command: "node",
  env: {
    PORT: "8080",
  },
});
```

To connect using SSE:

```ts
await client.connect({
  type: "sse",
  url: "http://localhost:8080/sse",
});
```

## Tools

## Available Tools

1.  Pinging the server (Checks if the server is reachable).
2.  Calling a tool (Executes a specific tool with provided arguments).
3.  Calling a tool with a custom result schema (Executes a tool and validates the result against a custom schema).
4.  Listing tools (Retrieves a list of available tools).
5.  Listing resources (Retrieves a list of available resources).
6.  Reading a resource (Retrieves a specific resource by its URI).
7.  Getting a prompt (Retrieves a specific prompt by its name).
8.  Listing prompts (Retrieves a list of available prompts).
9.  Setting the logging level (Configures the logging level of the client).
10. Completing a prompt (Completes a prompt with a given argument).
11. Listing resource templates (Retrieves a list of available resource templates).
12. Receiving logging messages (Subscribes to and processes logging messages from the server).
