The MCP Client provides a standardized way to consume resources from MCP servers. It handles communication with the server and provides a simple API for accessing resources.
To create an MCP client, you need to specify the server URL:
Copy
import { MCPClient } from '@repo/mcp';// Create client with server URLconst client = new MCPClient({ serverUrl: 'https://mcp-server.example.com'});// For local development or in-memory serversconst localClient = new MCPClient({ serverUrl: '/api/mcp'});
Lists all available resources or resources of a specific type:
Copy
// List all resourcesconst allResources = await client.listResources();// List resources with paginationconst paginatedResources = await client.listResources({ cursor: 'previousCursor', limit: 10});// List resources of a specific typeconst userResources = await client.listResources({ type: 'user'});