Skip to main content
Glama
cristip73

MCP Server for Asana

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;
      }
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses the filtering behavior with DEFAULT_WORKSPACE_ID, which is useful context. However, it doesn't mention rate limits, authentication needs, pagination, or return format, leaving gaps for a read operation with no annotation support.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences with zero waste, front-loading the core purpose and efficiently adding the conditional behavior. Every word earns its place, making it easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read tool with 1 parameter and no output schema, the description is adequate but not complete. It covers the purpose and a key behavioral nuance (DEFAULT_WORKSPACE_ID), but lacks details on return values, error handling, or authentication, which would be helpful given no annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single parameter 'opt_fields'. The description doesn't add any parameter-specific information beyond what's in the schema, such as examples of optional fields. Baseline 3 is appropriate when schema coverage is high.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('all available workspaces in Asana'), making the purpose specific. It distinguishes from siblings by focusing on workspaces rather than projects, tasks, or other entities, and includes the unique DEFAULT_WORKSPACE_ID filtering behavior.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context about when to use it (to list workspaces) and includes the DEFAULT_WORKSPACE_ID condition, which implicitly guides usage. However, it doesn't explicitly mention when not to use it or name alternatives among siblings, though the tool's unique focus on workspaces makes this less critical.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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