Skip to main content
Glama

Consumer Rights Wiki MCP Server

usage.ts2.92 kB
// examples/usage.ts // Example script demonstrating how to use the Consumer Rights Wiki MCP server import { Client } from '@modelcontextprotocol/sdk/client/index.js'; import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'; import { spawn } from 'child_process'; async function main() { // Spawn the MCP server process const serverProcess = spawn('node', ['../build/index.js']); // Create a client transport connected to the server's stdio const transport = new StdioClientTransport({ command: 'node', args: ['../build/index.js'], }); // Create the MCP client const client = new Client({ name: 'consumer-rights-wiki-client', version: '1.0.0', }, { capabilities: {} }); // Connect to the server await client.connect(transport); try { console.log('Connected to Consumer Rights Wiki MCP Server\n'); // Example 1: Search for articles about privacy console.log('1. Searching for privacy-related articles...'); const searchResult = await client.callTool({ name: 'search_wiki', arguments: { query: 'privacy data', limit: 5 } }); console.log('Search results:', JSON.parse(searchResult.content[0].text)); console.log('\n---\n'); // Example 2: Get information about X Corp console.log('2. Getting X Corp article content...'); const xcorpContent = await client.callTool({ name: 'get_page_content', arguments: { title: 'X Corp' } }); const xcorpData = JSON.parse(xcorpContent.content[0].text); console.log('X Corp article excerpt:', xcorpData.content.substring(0, 500) + '...'); console.log('\n---\n'); // Example 3: Get recent changes console.log('3. Getting recent changes...'); const recentChanges = await client.callTool({ name: 'get_recent_changes', arguments: { limit: 5, namespace: 0 // Main articles only } }); console.log('Recent changes:', JSON.parse(recentChanges.content[0].text)); console.log('\n---\n'); // Example 4: List categories console.log('4. Listing available categories...'); const categories = await client.callTool({ name: 'get_categories', arguments: { limit: 10 } }); console.log('Categories:', JSON.parse(categories.content[0].text)); console.log('\n---\n'); // Example 5: Get page sections for a specific article console.log('5. Getting sections of the Main Page...'); const sections = await client.callTool({ name: 'get_page_sections', arguments: { title: 'Main Page' } }); console.log('Main Page sections:', JSON.parse(sections.content[0].text)); } catch (error) { console.error('Error:', error); } finally { // Disconnect and cleanup await client.close(); serverProcess.kill(); } } // Run the example main().catch(console.error);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Cicatriiz/consumer-rights-wiki-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server