MCP Client
@1999AZZAR
TypeScript client for interacting with MCP (Model Context Protocol) servers
Overview
What is MCP Client?
A TypeScript client for interacting with MCP (Model Context Protocol) servers. It includes specialized clients for Wikipedia, Dictionary, Google Search, and LRU Caching services, providing a promise-based API with full type definitions.
How to use MCP Client?
Install via npm (npm install @your-org/mcp-client) or yarn. Create a base MCPClient instance with a server URL, then call request(method, params) or batchRequest(requests). For specialized services, instantiate WikipediaClient, DictionaryClient, GoogleSearchClient, or LRUCacheClient with the appropriate server URL and use their dedicated methods.
Key features of MCP Client
- TypeScript support with full type definitions
- JSON-RPC 2.0 protocol and batch request support
- Configurable timeouts and custom headers
- Specialized clients for Wikipedia, Dictionary, Google Search, and LRU Cache
- Promise-based API with comprehensive error handling
Use cases of MCP Client
- Search Wikipedia and retrieve page content
- Look up word definitions, synonyms, and antonyms
- Perform web, image, and news searches via Google
- Set, get, and manage key-value entries in an LRU cache with TTL
- Make arbitrary JSON-RPC requests to any MCP server
FAQ from MCP Client
What protocols does the client support?
It supports the JSON-RPC 2.0 protocol, including batch requests.
How does error handling work?
Methods return Promises that reject on failure: network/HTTP errors provide status and data, while MCP protocol errors include an error code.
What are the runtime requirements?
A TypeScript/Node.js environment. Install the npm package (@your-org/mcp-client) and build with npm run build.
Where does data live?
All data resides on the MCP server specified by the url option; the client only sends requests and receives responses.
What are the transport and authentication options?
The client uses HTTP and accepts custom headers (e.g., for authentication) via the headers option in the constructor.