Skip to main content
Glama

Plugwise MCP Server

by Tommertom
test-mcp-connection.tsโ€ข5.17 kB
#!/usr/bin/env node /** * Test script for Plugwise MCP Server * * This script: * 1. Spawns the MCP server as a child process * 2. Connects to it via stdio using the MCP SDK client * 3. Displays the server description * 4. Lists all available tools */ import { Client } from '@modelcontextprotocol/sdk/client/index.js'; import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'; async function testMcpConnection() { console.log('๐Ÿš€ Starting Plugwise MCP Server test...\n'); // Create stdio transport - this will spawn the server process console.log('๐Ÿ“ก Creating MCP client transport...'); const transport = new StdioClientTransport({ command: 'node', args: ['dist/index.js'], }); // Create MCP client const client = new Client({ name: 'test-client', version: '1.0.0', }, { capabilities: {} }); try { // Connect to the server console.log('๐Ÿ”Œ Connecting to MCP server...'); await client.connect(transport); console.log('โœ… Connected successfully!\n'); // Get server information const serverInfo = client.getServerVersion(); console.log('โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”'); console.log('๐Ÿ“‹ SERVER INFORMATION'); console.log('โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”'); console.log(`Name: ${serverInfo?.name || 'N/A'}`); console.log(`Version: ${serverInfo?.version || 'N/A'}`); console.log(`\nDescription:`); const description = serverInfo?.description ? String(serverInfo.description) : 'N/A'; console.log(wrapText(description, 80)); console.log('\n'); // List all available tools console.log('โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”'); console.log('๐Ÿ”ง AVAILABLE TOOLS'); console.log('โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”'); const toolsResponse = await client.listTools(); if (toolsResponse.tools && toolsResponse.tools.length > 0) { console.log(`\nFound ${toolsResponse.tools.length} tools:\n`); toolsResponse.tools.forEach((tool, index) => { console.log(`${index + 1}. ${tool.name}`); console.log(` ${wrapText(tool.description || 'No description', 75, ' ')}`); if (tool.inputSchema && typeof tool.inputSchema === 'object') { const schema = tool.inputSchema as any; if (schema.properties) { const props = Object.keys(schema.properties); const required = schema.required || []; console.log(` Parameters: ${props.join(', ')}`); if (required.length > 0) { console.log(` Required: ${required.join(', ')}`); } } } console.log(''); }); } else { console.log('No tools available.'); } console.log('โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”\n'); console.log('โœจ Test completed successfully!'); } catch (error) { console.error('โŒ Error during test:', error); throw error; } finally { // Clean up console.log('\n๐Ÿงน Cleaning up...'); await client.close(); console.log('โœ… Cleanup complete'); } } /** * Wrap text to a specified width while preserving intentional line breaks */ function wrapText(text: string, width: number, indent: string = ''): string { // Split by newlines to preserve intentional breaks const paragraphs = text.split('\n'); const wrappedParagraphs: string[] = []; for (const paragraph of paragraphs) { if (paragraph.trim() === '') { // Preserve empty lines wrappedParagraphs.push(''); continue; } const words = paragraph.trim().split(' '); const lines: string[] = []; let currentLine = indent; for (const word of words) { if (currentLine.length + word.length + 1 <= width) { currentLine += (currentLine === indent ? '' : ' ') + word; } else { lines.push(currentLine); currentLine = indent + word; } } if (currentLine.length > indent.length) { lines.push(currentLine); } wrappedParagraphs.push(lines.join('\n')); } return wrappedParagraphs.join('\n'); } // Run the test testMcpConnection().catch((error) => { console.error('Fatal error:', error); process.exit(1); });

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/Tommertom/plugwise-mcp'

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