get_teams
Retrieve a list of all teams configured in your Sprout Social account.
Instructions
List all teams in your Sprout Social account.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:150-157 (handler)The 'get_teams' tool handler. It is registered via server.tool(), accepts no parameters (empty schema {}), makes a GET request to /metadata/customer/teams, and returns the JSON response as text content. This is both the handler and registration.
server.tool( "get_teams", "List all teams in your Sprout Social account.", {}, async () => { const data = await sproutRequest("GET", "/metadata/customer/teams"); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } - src/index.ts:153-153 (schema)The input schema for get_teams is an empty object ({}) — no parameters are required.
{}, - src/index.ts:150-158 (registration)The tool is registered using server.tool() on the McpServer instance. Registration, handler, and schema are all in the same call.
server.tool( "get_teams", "List all teams in your Sprout Social account.", {}, async () => { const data = await sproutRequest("GET", "/metadata/customer/teams"); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } ); - src/index.ts:29-59 (helper)The sproutRequest helper function used by get_teams to make the actual API GET request to the Sprout Social API. It constructs the URL with customer ID, sets auth headers, and parses the JSON response.
async function sproutRequest( method: "GET" | "POST", path: string, body?: Record<string, unknown> ): Promise<unknown> { const { apiKey, customerId } = getConfig(); const url = `${SPROUT_API_BASE}/v1/${customerId}${path}`; const headers: Record<string, string> = { Authorization: `Bearer ${apiKey}`, Accept: "application/json", }; const options: RequestInit = { method, headers }; if (body) { headers["Content-Type"] = "application/json"; options.body = JSON.stringify(body); } const response = await fetch(url, options); if (!response.ok) { const errorText = await response.text(); throw new Error( `Sprout Social API error (${response.status}): ${errorText}` ); } return response.json(); }