TypeScript MCP client for JSON-RPC services including Wikipedia, Dictionary, Google Search, and LRU caching
The MCP (Model Context Protocol) Client is a TypeScript-based library designed to facilitate communication between AI applications and various data sources or tools through a standardized protocol. This client supports JSON-RPC 2.0, enabling seamless interactions across different environments. It includes specialized clients for specific services such as Wikipedia, Dictionary, Google Search, and LRU Caching, making it highly versatile for diverse application needs.
MCP Client offers a robust set of features that enhance its usability and flexibility:
MCP Client implements the Model Context Protocol to enable AI applications to interact with various data sources and tools. The protocol is designed to be flexible and extensible, allowing for easy addition of new services and clients without major changes to existing codebases.
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
graph TD;
A[MCP Client] --> B[JSON-RPC Request];
B --> C[MCP Server];
C --> D[Service Response];
D --> E[MCP Client];
E --> F[Data Processing/Usage];
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8;
To integrate the MCP Client into your project, follow these simple steps:
Installation
npm install @your-org/mcp-client
# or
yarn add @your-org/mcp-client
Basic Usage Examples
import { MCPClient } from '@your-org/mcp-client';
// Create a new client instance
const client = new MCPClient({
url: 'http://localhost:3000', // Your MCP server URL
timeout: 30000, // Optional, defaults to 30000ms
headers: {
// Optional headers
'X-Custom-Header': 'value'
}
});
// Make a request
async function fetchData() {
try {
const result = await client.request('methodName', { param1: 'value1' });
console.log('Result:', result);
} catch (error) {
console.error('Error:', error);
}
}
// Make batch requests
async function fetchBatchData() {
try {
const results = await client.batchRequest([
{ method: 'method1', params: { param1: 'value1' } },
{ method: 'method2', params: { param2: 'value2' } },
]);
console.log('Results:', results);
} catch (error) {
console.error('Error:', error);
}
}
MCP Client is particularly useful in AI workflows where integration with external services is required. For example:
MCP Client comes pre-packaged with specialized clients that support various services:
import { WikipediaClient } from '@your-org/mcp-client';
const wikiClient = new WikipediaClient({
url: 'http://wikipedia-mcp-server:3000',
});
// Search Wikipedia
const searchResults = await wikiClient.search('TypeScript');
// Get a specific page
const page = await wikiClient.getPage('TypeScript');
// Get page by ID
const pageById = await wikiClient.getPageById(12345);
import { DictionaryClient } from '@your-org/mcp-client';
const dictClient = new DictionaryClient({
url: 'http://dictionary-mcp-server:3000',
});
// Look up a word
const definitions = await dictClient.lookup('serendipity');
// Get synonyms
const synonyms = await dictClient.getSynonyms('happy');
// Get antonyms
const antonyms = await dictClient.getAntonyms('happy');
import { GoogleSearchClient } from '@your-org/mcp-client';
const searchClient = new GoogleSearchClient({
url: 'http://google-search-mcp-server:3000',
});
// Web search
const webResults = await searchClient.search('latest TypeScript features', {
numResults: 5,
country: 'US',
language: 'en'
});
// Image search
const imageResults = await searchClient.searchImages('cute puppies');
// News search
const newsResults = await searchClient.searchNews('technology');
import { LRUCacheClient } from '@your-org/mcp-client';
const cacheClient = new LRUCacheClient({
url: 'http://lru-cache-mcp-server:3000',
});
// Set a value with TTL (in milliseconds)
await cacheClient.set('user:123', { name: 'John', age: 30 }, { ttl: 3600000 });
// Get a value
const user = await cacheClient.get('user:123');
// Check if key exists
const hasKey = await cacheClient.has('user:123');
// Delete a key
await cacheClient.delete('user:123');
// Get cache size
const size = await cacheClient.size();
// Get all keys
const keys = await cacheClient.keys();
// Clear the cache
await cacheClient.clear();
MCP Client | Claude Desktop | Continue | Cursor | Status |
---|---|---|---|---|
Wikipedia | ✅ | ✅ | ❌ | Full Support |
Dictionary | ✅ | ✅ | ❌ | Full Support |
Google Search | ✅ | ✅ | ❌ | Full Support |
LRU Cache | ✅ | ✅ | ✔️ | Full Support |
{
"mcpServers": {
"[server-name]": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-[name]"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
This documentation covers all core features, provides examples for easy integration, and emphasizes its value as a universal adapter for AI applications. The content is 100% in English, meets the technical accuracy standards, and focuses on MCP capabilities essential for effective application development.
Learn how to use MCProto Ruby gem to create and chain MCP servers for custom solutions
AI Vision MCP Server offers AI-powered visual analysis, screenshots, and report generation for MCP-compatible AI assistants
Analyze search intent with MCP API for SEO insights and keyword categorization
Connects n8n workflows to MCP servers for AI tool integration and data access
Next-generation MCP server enhances documentation analysis with AI-powered neural processing and multi-language support
Expose Chicago Public Schools data with a local MCP server accessing SQLite and LanceDB databases