Skip to main content
Glama
cristip73
by cristip73

asana_list_workspaces

Retrieve available Asana workspaces to manage tasks and projects. Returns all workspaces or a specific one if configured.

Instructions

List all available workspaces in Asana. If DEFAULT_WORKSPACE_ID is set, only returns that workspace.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
opt_fieldsNoComma-separated list of optional fields to include

Implementation Reference

  • Core implementation of the asana_list_workspaces tool logic in AsanaClientWrapper class. Handles default workspace fallback and full pagination of workspaces via Asana API.
    async listWorkspaces(opts: any = {}) { try { // If DEFAULT_WORKSPACE_ID is set, only return that workspace if (this.defaultWorkspaceId) { console.error(`Using default workspace ID: ${this.defaultWorkspaceId}`); const response = await this.workspaces.getWorkspace(this.defaultWorkspaceId, opts); return [response.data]; // Return as an array with a single workspace } // Extract pagination parameters const { auto_paginate = false, max_pages = 10, limit, offset, ...otherOpts } = opts; // Build search parameters const searchParams: any = { ...otherOpts }; // Add pagination parameters if (limit !== undefined) { // Ensure limit is between 1 and 100 searchParams.limit = Math.min(Math.max(1, Number(limit)), 100); } if (offset) searchParams.offset = offset; // Use the paginated results handler for more reliable pagination return await this.handlePaginatedResults( // Initial fetch function () => this.workspaces.getWorkspaces(searchParams), // Next page fetch function (nextOffset) => this.workspaces.getWorkspaces({ ...searchParams, offset: nextOffset }), // Pagination options { auto_paginate, max_pages } ); } catch (error: any) { console.error(`Error listing workspaces: ${error.message}`); throw error; } }
  • Tool handler dispatch case that invokes AsanaClientWrapper.listWorkspaces and formats the response.
    case "asana_list_workspaces": { const response = await asanaClient.listWorkspaces(args); return { content: [{ type: "text", text: JSON.stringify(response) }], }; }
  • Defines the input schema, name, and description for the asana_list_workspaces tool.
    export const listWorkspacesTool: Tool = { name: "asana_list_workspaces", description: "List all available workspaces in Asana. If DEFAULT_WORKSPACE_ID is set, only returns that workspace.", inputSchema: { type: "object", properties: { opt_fields: { type: "string", description: "Comma-separated list of optional fields to include" } } } };
  • Registers the listWorkspacesTool in the central tools array used for MCP tool exposure.
    export const tools: Tool[] = [ listWorkspacesTool,
  • Helper method used by listWorkspaces for handling pagination of Asana API responses.
    private async handlePaginatedResults<T>( initialFetch: () => Promise<PaginatedResponse<T>>, nextPageFetch: (offset: string) => Promise<PaginatedResponse<T>>, options: PaginationOptions = {} ): Promise<T[]> { try { // Fetch the initial page const initialResponse = await initialFetch(); // Use the pagination utility to handle additional pages if needed return await handlePagination(initialResponse, nextPageFetch, options); } catch (error: any) { console.error(`Error in paginated request: ${error.message}`); throw error; } }

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/cristip73/mcp-server-asana'

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