asana_list_workspaces
Retrieve available Asana workspaces to select the right environment for task and project management. When DEFAULT_WORKSPACE_ID is configured, returns only that specific workspace.
Instructions
List all available workspaces in Asana. If DEFAULT_WORKSPACE_ID is set, only returns that workspace.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| opt_fields | No | Comma-separated list of optional fields to include |
Input Schema (JSON Schema)
{
"properties": {
"opt_fields": {
"description": "Comma-separated list of optional fields to include",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/asana-client-wrapper.ts:70-113 (handler)Core implementation of the listWorkspaces method in AsanaClientWrapper, handling default workspace, pagination, and Asana API calls.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; } }
- src/tool-handler.ts:138-143 (handler)MCP tool handler dispatch case that executes asanaClient.listWorkspaces with validated arguments and returns JSON response.case "asana_list_workspaces": { const response = await asanaClient.listWorkspaces(args); return { content: [{ type: "text", text: JSON.stringify(response) }], }; }
- src/tools/workspace-tools.ts:3-15 (schema)Defines the tool metadata, description, and input schema for asana_list_workspaces.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" } } } };
- src/tool-handler.ts:61-103 (registration)Registers listWorkspacesTool (imported at line 7) in the exported tools array used for MCP tool discovery.export const tools: Tool[] = [ listWorkspacesTool, searchProjectsTool, getProjectTool, getProjectTaskCountsTool, getProjectSectionsTool, createSectionForProjectTool, createProjectForWorkspaceTool, updateProjectTool, reorderSectionsTool, getProjectStatusTool, getProjectStatusesForProjectTool, createProjectStatusTool, deleteProjectStatusTool, searchTasksTool, getTaskTool, createTaskTool, updateTaskTool, createSubtaskTool, getMultipleTasksByGidTool, addTaskToSectionTool, getTasksForSectionTool, getProjectHierarchyTool, getSubtasksForTaskTool, getTasksForProjectTool, getTasksForTagTool, getTagsForWorkspaceTool, addTagsToTaskTool, addTaskDependenciesTool, addTaskDependentsTool, setParentForTaskTool, addFollowersToTaskTool, getStoriesForTaskTool, createTaskStoryTool, getTeamsForUserTool, getTeamsForWorkspaceTool, addMembersForProjectTool, addFollowersForProjectTool, getUsersForWorkspaceTool, getAttachmentsForObjectTool, uploadAttachmentForObjectTool, downloadAttachmentTool ];