list_teams
Retrieve a list of teams for the authenticated user in Webex, with optional control over the number of teams returned using the max parameter.
Instructions
List teams for the authenticated user in Webex.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max | No | The maximum number of teams to return. |
Implementation Reference
- The main handler function executeFunction that lists teams by making a GET request to the Webex /teams API endpoint with optional max parameter.const executeFunction = async ({ max = 100 }) => { try { // Construct the URL with query parameters const url = new URL(getWebexUrl('/teams')); url.searchParams.append('max', max.toString()); // Set up headers for the request const headers = getWebexHeaders(); // Perform the fetch request const response = await fetch(url.toString(), { method: 'GET', headers }); // Check if the response was successful if (!response.ok) { const errorData = await response.json(); throw new Error(JSON.stringify(errorData)); } // Parse and return the response data const data = await response.json(); return data; } catch (error) { console.error('Error listing teams:', error); return { error: 'An error occurred while listing teams.' }; } };
- The apiTool export containing the schema definition (parameters) and reference to the handler function for the list_teams tool.const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'list_teams', description: 'List teams for the authenticated user in Webex.', parameters: { type: 'object', properties: { max: { type: 'integer', description: 'The maximum number of teams to return.' } }, required: [] } } } };
- mcpServer.js:87-138 (registration)The registration loop in createMcpServer that iterates over discovered tools and calls server.registerTool for each, using the tool name from the schema.for (const tool of tools) { const definition = tool.definition?.function; if (!definition) { console.error(`[MCP Server] Skipping tool with invalid definition:`, tool); continue; } try { server.registerTool( definition.name, { title: definition.name.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase()), description: definition.description, // MCP SDK v1.17.4 requires inputSchema with Zod schemas for parameter validation inputSchema: convertJsonSchemaToZod(definition.parameters?.properties || {}, definition.parameters?.required || []) }, async (args) => { try { // Debug logging to see what we actually receive console.error(`[DEBUG] Tool ${definition.name} called with args:`, JSON.stringify(args)); console.error(`[DEBUG] Args type:`, typeof args); console.error(`[DEBUG] Args keys:`, Object.keys(args || {})); // Handle both function and handler patterns const toolFunction = tool.function || tool.handler; if (!toolFunction) { throw new Error(`Tool ${definition.name} has no function or handler`); } const result = await toolFunction(args); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { console.error(`[MCP Server] Tool ${definition.name} error:`, error); return { content: [{ type: 'text', text: `Error: ${error.message}` }], isError: true }; } } ); } catch (error) { console.error(`[MCP Server] Failed to register tool ${definition.name}:`, error); } }
- lib/tools.js:7-16 (registration)The discoverTools function that loads all tool modules dynamically from toolPaths and returns an array of apiTool objects for registration.export async function discoverTools() { const toolPromises = toolPaths.map(async (file) => { const module = await import(`../tools/${file}`); return { ...module.apiTool, path: file, }; }); return Promise.all(toolPromises); }