MCP Client logo

MCP Client

by 1999AZZAR

A TypeScript client for interacting with MCP (Model Context Protocol) servers. It includes specialized clients for Wikipedia, Dictionary, Google Search, and LRU Caching services.

View on GitHub

Last updated: N/A

What is MCP Client?

The MCP Client is a TypeScript library designed to simplify interactions with MCP (Model Context Protocol) servers. It provides a base client for making JSON-RPC requests and specialized clients for common services like Wikipedia, Dictionary, Google Search, and LRU caching.

How to use MCP Client?

Install the package using npm or yarn. Create a client instance with the server URL and optional configurations like timeout and headers. Use the request or batchRequest methods for generic MCP requests. For specialized services, use the corresponding client (e.g., WikipediaClient, DictionaryClient) and its methods.

Key features of MCP Client

  • TypeScript support with full type definitions

  • Support for JSON-RPC 2.0 protocol

  • Batch request support

  • Configurable timeouts and headers

  • Comprehensive error handling

  • Specialized clients for different MCP services

  • Promise-based API

Use cases of MCP Client

  • Accessing data from Wikipedia via MCP

  • Looking up word definitions and synonyms/antonyms via MCP

  • Performing Google searches (web, image, news) via MCP

  • Implementing an LRU cache using an MCP server

  • Building applications that rely on structured data from various sources exposed through MCP

FAQ from MCP Client

What is MCP?

MCP stands for Model Context Protocol. It's a protocol for interacting with servers that provide access to various data models.

How do I install the MCP Client?

You can install it using npm: npm install @your-org/mcp-client or yarn: yarn add @your-org/mcp-client.

How do I handle errors?

All client methods return Promises that reject with an error object. The error object contains information about network issues, HTTP errors, or MCP protocol errors.

Can I configure the request timeout?

Yes, you can configure the timeout in milliseconds when creating a new client instance using the timeout option.

How do I make a batch request?

Use the batchRequest method and provide an array of request objects, each containing the method and params.