Skip to main content
Glama

DataForSEO MCP Server

test.ts2 kB
import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; import readline from "readline/promises"; class MCPClient { private mcp: Client; private transport: StdioClientTransport | null = null; constructor() { // Initialize Anthropic client and MCP client this.mcp = new Client({ name: "mcp-client-cli", version: "1.0.0" }); } async connectToServer(serverScriptPath: string) { /** * Connect to an MCP server * * @param serverScriptPath - Path to the server script (.py or .js) */ try { // Determine script type and appropriate command const isJs = serverScriptPath.endsWith(".js"); const isPy = serverScriptPath.endsWith(".py"); if (!isJs && !isPy) { throw new Error("Server script must be a .js or .py file"); } const command = isPy ? process.platform === "win32" ? "python" : "python3" : process.execPath; // Initialize transport and connect to server this.transport = new StdioClientTransport({ command, args: [serverScriptPath], }); this.mcp.connect(this.transport); // List available tools const toolsResult = await this.mcp.listTools(); console.log(toolsResult); console.log( "Connected to server with tools:", toolsResult.tools.map(({ name }) => name), ); } catch (e) { console.log("Failed to connect to MCP server: ", e); throw e; } } async cleanup() { /** * Clean up resources */ await this.mcp.close(); } } async function main() { if (process.argv.length < 3) { console.log("Usage: node build/test.js <path_to_server_script>"); return; } const mcpClient = new MCPClient(); try { await mcpClient.connectToServer(process.argv[2]); } finally { await mcpClient.cleanup(); process.exit(0); } } main();

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/ravinwebsurgeon/seo-mcp'

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