Skip to main content
Glama

Gemini Context MCP Server

by ogoldberg
client.ts1.7 kB
import { Client } from '@modelcontextprotocol/sdk/client/index.js'; import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'; import * as dotenv from 'dotenv'; // Load environment variables from .env file dotenv.config(); if (!process.env.GEMINI_API_KEY) { throw new Error('GEMINI_API_KEY environment variable is required'); } export async function startClient() { try { const transport = new StdioClientTransport({ command: 'node', args: ['dist/mcp-server.js'], env: { ...process.env, GEMINI_API_KEY: process.env.GEMINI_API_KEY as string } }); const client = new Client( { name: 'Gemini Context MCP Client', version: '1.0.0' }, { capabilities: { tools: {} } } ); await client.connect(transport); console.log('Connected to MCP server'); // Test the connection by calling a tool const result = await client.callTool({ name: 'generate_text', arguments: { prompt: 'Hello, how are you?', contextMetadata: { sessionId: 'test' } } }); console.log('Tool result:', result); return client; } catch (error) { console.error('Failed to start client:', error); process.exit(1); } } // Use ES modules import.meta.url to check if this is the main module if (import.meta.url === new URL(process.argv[1], 'file:').href) { startClient(); }

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/ogoldberg/gemini-context-mcp-server'

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