Skip to main content
Glama

getv2users

Retrieve a paginated list of Gong users in 100-row batches using a cursor for efficient data navigation and management.

Instructions

List Gong users (100-row pages)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cursorNo

Implementation Reference

  • src/index.ts:90-99 (registration)
    Registration of the 'getv2users' tool in the toolDefinitionMap, defining its metadata, input schema, API endpoint details, and security requirements.
    ["getv2users", { name: "getv2users", description: `List Gong users (100-row pages)`, inputSchema: {"type":"object","properties":{"cursor":{"type":"string"}}}, method: "get", pathTemplate: "/v2/users", executionParameters: [{"name":"cursor","in":"query"}], requestBodyContentType: undefined, securityRequirements: [{"basicAuth":[]}] }],
  • Input schema definition for the 'getv2users' tool, specifying an optional 'cursor' string parameter for pagination.
    inputSchema: {"type":"object","properties":{"cursor":{"type":"string"}}},
  • MCP CallTool request handler that looks up the tool definition by name and dispatches execution to the generic executeApiTool function.
    server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest): Promise<CallToolResult> => { const { name: toolName, arguments: toolArgs } = request.params; const toolDefinition = toolDefinitionMap.get(toolName); if (!toolDefinition) { console.error(`Error: Unknown tool requested: ${toolName}`); return { content: [{ type: "text", text: `Error: Unknown tool requested: ${toolName}` }] }; } return await executeApiTool(toolName, toolDefinition, toolArgs ?? {}, securitySchemes); });
  • Core handler function that executes the API call for 'getv2users': validates input, builds URL for /v2/users with cursor query param, adds Basic Auth, calls Gong API, and formats response as MCP content.
    async function executeApiTool( toolName: string, definition: McpToolDefinition, toolArgs: JsonObject, allSecuritySchemes: Record<string, any> ): Promise<CallToolResult> { try { // Validate input arguments using Zod const zodSchema = getZodSchemaFromJsonSchema(definition.inputSchema, toolName); const validatedArgs = zodSchema.parse(toolArgs); // Build the request URL let url = API_BASE_URL + definition.pathTemplate; // Replace path parameters for (const param of definition.executionParameters) { if (param.in === 'path') { const value = validatedArgs[param.name]; if (value !== undefined) { url = url.replace(`{${param.name}}`, encodeURIComponent(value)); } } } // Build query parameters const queryParams: Record<string, string> = {}; for (const param of definition.executionParameters) { if (param.in === 'query') { const value = validatedArgs[param.name]; if (value !== undefined) { queryParams[param.name] = value; } } } if (Object.keys(queryParams).length > 0) { url += '?' + new URLSearchParams(queryParams).toString(); } // Debug logging (safe) console.error('Debug - Making API request to:', url); // Get credentials from environment const accessKey = process.env.GONG_ACCESS_KEY || ''; const secret = process.env.GONG_SECRET || ''; if (!accessKey || !secret) { throw new Error('Missing Gong credentials in environment'); } // Create authorization header const authHeader = `Basic ${Buffer.from(`${accessKey}:${secret}`).toString('base64')}`; // Build request config const config: AxiosRequestConfig = { method: definition.method, url, headers: { 'Accept': 'application/json', 'Authorization': authHeader } }; // Add request body if needed if (definition.requestBodyContentType) { config.headers!['Content-Type'] = definition.requestBodyContentType; if (validatedArgs.requestBody) { config.data = validatedArgs.requestBody; } } // Make the request const response = await axios(config); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2) } ] }; } catch (error: any) { if (error instanceof ZodError) { return { content: [{ type: 'text', text: `Validation error: ${error.message}` }] }; } if (axios.isAxiosError(error)) { return { content: [{ type: 'text', text: formatApiError(error) }] }; } return { content: [{ type: 'text', text: `Unexpected error: ${error.message}` }] }; } }
  • ListTools handler that exposes the 'getv2users' tool (along with others) to MCP clients, including its schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { const toolsForClient: Tool[] = Array.from(toolDefinitionMap.values()).map(def => ({ name: def.name, description: def.description, inputSchema: def.inputSchema })); return { tools: toolsForClient }; });

Other Tools

Related Tools

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/MaPa07/gong-mcp'

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