### Initialize and Start MCP Server Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/mcp-server.md Initializes and starts the MCP server instance. Sets up the Asana client, registers all tool/prompt/resource handlers, and connects to stdio transport for client communication. Requires ASANA_ACCESS_TOKEN environment variable. ```typescript import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; async function main() { const asanaToken = process.env.ASANA_ACCESS_TOKEN; if (!asanaToken) { console.error("Please set ASANA_ACCESS_TOKEN environment variable"); process.exit(1); } const server = new Server( { name: "Asana MCP Server", version: "1.8.0", }, { capabilities: { tools: {}, prompts: {}, resources: {} }, } ); const asanaClient = new AsanaClientWrapper(asanaToken); // Register tool handler server.setRequestHandler( CallToolRequestSchema, tool_handler(asanaClient) ); // Register prompt handlers const promptHandlers = createPromptHandlers(asanaClient); server.setRequestHandler(ListPromptsRequestSchema, promptHandlers.listPrompts); server.setRequestHandler(GetPromptRequestSchema, promptHandlers.getPrompt); // Register resource handlers const resourceHandlers = createResourceHandlers(asanaClient); server.setRequestHandler(ListResourcesRequestSchema, resourceHandlers.listResources); server.setRequestHandler(ListResourceTemplatesRequestSchema, resourceHandlers.listResourceTemplates); server.setRequestHandler(ReadResourceRequestSchema, resourceHandlers.readResource); const transport = new StdioServerTransport(); await server.connect(transport); console.error("Asana MCP Server running on stdio"); } main().catch((error) => { console.error("Fatal error in main():", error); process.exit(1); }); ``` -------------------------------- ### Example MCP Tool Definition Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/types.md An example demonstrating how to define a concrete MCP tool, 'asana_create_task', including its name, description, and a detailed input schema with required parameters. This serves as a template for creating new tools. ```typescript const exampleTool: Tool = { name: "asana_create_task", description: "Create a new task in a project", inputSchema: { type: "object", properties: { project_id: { type: "string", description: "The project GID" }, name: { type: "string", description: "Task name" } }, required: ["project_id", "name"] } }; ``` -------------------------------- ### Tool Registration Example Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/architecture.md Example of importing and registering tool definitions within the tool handler, combining specific tools with a general list. ```typescript import { searchProjectsTool } from './tools/project-tools.js'; const all_tools = [searchProjectsTool, ...]; ``` -------------------------------- ### Example Response for listResources Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/resources.md Illustrates the structure of the response when listing all workspaces and project templates. ```json { "resources": [ { "uri": "asana://workspace/1234567890", "name": "Engineering Workspace", "description": "Asana workspace: Engineering Workspace" }, { "uri": "asana://workspace/9876543210", "name": "Marketing Workspace", "description": "Asana workspace: Marketing Workspace" } ], "resourceTemplates": [ { "uriTemplate": "asana://project/{project_gid}", "name": "Asana Project Template", "description": "Get details for a specific Asana project by GID", "mimeType": "application/json" } ] } ``` -------------------------------- ### MCP Server Entry Point Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/COMPLETION_SUMMARY.txt Documentation for the server entry point (`src/index.ts`), covering initialization and transport setup. ```APIDOC ## MCP Server Entry Point ### Description Details the main server entry point and its initialization process. ### Coverage - Main server entry point (`src/index.ts`) - CLI executable configuration - Transport setup (stdio) ### Documentation Refer to `api-reference/mcp-server.md` for more information. ``` -------------------------------- ### Install MCP Tools via Homebrew Source: https://github.com/roychri/mcp-server-asana/blob/main/HOW-TO-TEST-MCP-ON-CLI.md Installs the 'mcp' command-line tool from the fka.dev repository using Homebrew. This tool provides an alternative way to interact with MCP servers. ```bash # Install via Homebrew brew tap f/mcptools && brew install mcp ``` -------------------------------- ### Example Request/Response for readResource Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/resources.md Demonstrates the expected JSON format for a request to read a specific project resource and its corresponding response. ```json Request: { "params": { "uri": "asana://project/9876543210" } } Response: { "contents": [ { "uri": "asana://project/9876543210", "mimeType": "application/json", "text": "{...project data...}" } ] } ``` -------------------------------- ### Example Response for listPrompts Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/prompts.md Illustrates the structure of the response when listing available prompts, including prompt name, description, and arguments. ```json { "prompts": [ { "name": "task-summary", "description": "Get a summary and status update for a task", "arguments": [ { "name": "task_id", "description": "The task ID to get summary for", "required": true } ] } // ... other prompts ] } ``` -------------------------------- ### Install Beta Version of Asana MCP Server Source: https://github.com/roychri/mcp-server-asana/blob/main/README.md To install the beta version of the Asana MCP server, use the `@beta` tag. You can find beta releases and check available versions using npm. ```bash @roychri/mcp-server-asana@beta ``` -------------------------------- ### Install Asana Node.js Package Source: https://github.com/roychri/mcp-server-asana/blob/main/Asana-v3.md Install the Asana Node.js package using npm. This command saves the package as a dependency in your project. ```shell npm install asana --save ``` -------------------------------- ### create-task Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/prompts.md Guides creation of a new task with comprehensive details. ```APIDOC ## create-task ### Description Guides creation of a new task with comprehensive details. ### Method `prompts/get` ### Parameters #### Query Parameters - **name** (string) - Required - The name of the prompt, 'create-task'. - **arguments** (object) - Required - The arguments for the prompt. - **project_name** (string) - Required - The name of the Asana project where the task should be created. - **title** (string) - Required - The title of the task. - **notes** (string) - Optional - Notes or description for the task. - **due_date** (string) - Optional - Due date for the task (YYYY-MM-DD format). ### Response #### Success Response Pre-populated conversation with task creation guidelines and parameters. ### Description Provides structured guidance for creating comprehensive tasks. The prompt instructs the AI to create a task with all necessary details including: - Clear objectives and scope - Detailed deliverables - Technical requirements - Design considerations - Resource requirements - Dependencies and timeline - Success criteria ### Availability Only available when `READ_ONLY_MODE` is not set to 'true'. ``` -------------------------------- ### Get Prompt Example: Correct vs. Incorrect Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/errors.md Demonstrates how to correctly specify a prompt name versus an invalid one when calling getPrompt. Ensure the prompt name exists in the available prompts list. ```typescript // Wrong const result = await getPrompt({ params: { name: "invalid-prompt-name" } }); // Correct const result = await getPrompt({ params: { name: "task-summary" } }); ``` -------------------------------- ### Node Version Management with nvm Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/configuration.md Recommended for managing Node.js versions. Installs and uses Node.js version 22. ```bash nvm install 22 nvm use 22 ``` -------------------------------- ### Example Response for listResourceTemplates Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/resources.md Shows the JSON structure returned when listing only the available resource templates, specifically the project URI template. ```json { "resourceTemplates": [ { "uriTemplate": "asana://project/{project_gid}", "name": "Asana Project Template", "description": "Get details for a specific Asana project by GID", "mimeType": "application/json" } ] } ``` -------------------------------- ### Using the `callApi` Method for Tasks Source: https://github.com/roychri/mcp-server-asana/blob/main/Asana-v3.md Examples of using the `callApi` method to perform GET, POST, and PUT operations on tasks. ```APIDOC ## Using the `callApi` method Use the `callApi` method to make http calls when the endpoint does not exist in the current library version or has bugs ### Example: GET, POST, PUT, DELETE on tasks #### GET - get a task ##### Description Retrieves details for a specific task using its GID. ##### Method GET ##### Endpoint `/tasks/{task_gid}` ##### Parameters ###### Path Parameters - **task_gid** (string) - Required - The gid of the task to retrieve. ###### Request Example ```javascript const Asana = require('asana'); let client = Asana.ApiClient.instance; let token = client.authentications['token']; token.accessToken = ''; client.callApi( path='/tasks/{task_gid}', httpMethod='GET', pathParams={"task_gid": ""}, queryParams={}, headerParams={}, formParams={}, bodyParam=null, authNames=['token'], contentTypes=[], accepts=['application/json; charset=UTF-8'], returnType='Blob' ).then((response_and_data) => { let result = response_and_data.data; let task = result.data; console.log(task.name); }, (error) => { console.error(error.response.body); }); ``` #### GET - get multiple tasks -> with opt_fields ##### Description Retrieves a list of tasks, with options to filter and specify returned fields. ##### Method GET ##### Endpoint `/tasks` ##### Parameters ###### Query Parameters - **limit** (integer) - Optional - The number of results to return. - **modified_since** (string) - Optional - Filters tasks modified since this date/time. - **project** (string) - Optional - Filters tasks by the project they belong to. - **opt_fields** (string) - Optional - Comma-separated list of fields to return for each task. ###### Request Example ```javascript const Asana = require('asana'); let client = Asana.ApiClient.instance; let token = client.authentications['token']; token.accessToken = ''; client.callApi( path='/tasks', httpMethod='GET', pathParams={}, queryParams={ "limit": 50, "modified_since": '2012-02-22T02:06:58.158Z', // OR new Date("2012-02-22T02:06:58.158Z") "project": '', "opt_fields": 'name,notes' }, headerParams={}, formParams={}, bodyParam=null, authNames=['token'], contentTypes=[], accepts=['application/json; charset=UTF-8'], returnType='Blob' ).then((response_and_data) => { let result = response_and_data.data; let tasks = result.data; if (tasks.length > 0) { console.log(`Task 1 Name: ${tasks[0].name}`); console.log(`Task 1 Notes: ${tasks[0].notes}`); } }, (error) => { console.error(error.response.body); }); ``` #### POST - create a task ##### Description Creates a new task in Asana. ##### Method POST ##### Endpoint `/tasks` ##### Parameters ###### Request Body - **data** (object) - Required - The task object to create. - **name** (string) - Required - The name of the task. - **approval_status** (string) - Optional - The approval status of the task. - **assignee_status** (string) - Optional - The assignee status of the task. - **completed** (boolean) - Optional - Whether the task is completed. - **html_notes** (string) - Optional - HTML notes for the task. - **is_rendered_as_separator** (boolean) - Optional - Whether the task is rendered as a separator. - **liked** (boolean) - Optional - Whether the task is liked. - **assignee** (string) - Optional - The assignee of the task (user GID or 'me'). - **projects** (array of strings) - Optional - An array of project GIDs the task belongs to. ###### Request Example ```javascript const Asana = require('asana'); let client = Asana.ApiClient.instance; let token = client.authentications['token']; token.accessToken = ''; client.callApi( path='/tasks', httpMethod='POST', pathParams={}, queryParams={}, headerParams={}, formParams={}, bodyParam={ data: { "name": "New Task", "approval_status": "pending", "assignee_status": "upcoming", "completed": false, "html_notes": "Mittens really likes the stuff from Humboldt.", "is_rendered_as_separator": false, "liked": true, "assignee": "me", "projects": [""] } }, authNames=['token'], contentTypes=[], accepts=['application/json; charset=UTF-8'], returnType='Blob' ).then((response_and_data) => { let result = response_and_data.data; let task = result.data; console.log(task.name); }, (error) => { console.error(error.response.body); }); ``` #### PUT - update a task ##### Description Updates an existing task. ##### Method PUT ##### Endpoint `/tasks/{task_gid}` ##### Parameters ###### Path Parameters - **task_gid** (string) - Required - The GID of the task to update. ###### Request Body - **data** (object) - Required - The fields to update on the task. - **name** (string) - Optional - The new name for the task. - **html_notes** (string) - Optional - Updated HTML notes for the task. - **due_at** (string) - Optional - The new due date for the task. ###### Request Example ```javascript const Asana = require('asana'); let client = Asana.ApiClient.instance; let token = client.authentications['token']; token.accessToken = ''; client.callApi( path='/tasks/{task_gid}', httpMethod='PUT', pathParams={task_gid: ""}, queryParams={}, headerParams={}, formParams={}, bodyParam={ "data": { "name": "Updated Task", "html_notes": "Updated task notes", "due_at": "2025-01-20T02:06:58.147Z" } }, authNames=['token'], contentTypes=[], accepts=['application/json; charset=UTF-8'], returnType='Blob' ).then((response_and_data) => { let result = response_and_data.data; let task = result.data; console.log(task.name); }, (error) => { console.error(error.response.body); }); ``` ``` -------------------------------- ### Build and Development Commands Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/README.md Commands for building the project for production, running in development mode with ts-node, enabling watch mode, testing with MCP Inspector, and starting the server. ```bash # Build for production npm run build # Development with ts-node npm run dev # Watch mode npm run watch # Test with MCP Inspector npm run inspector # Start server npm start ``` -------------------------------- ### Start MCP Inspector in CLI Mode Source: https://github.com/roychri/mcp-server-asana/blob/main/HOW-TO-TEST-MCP-ON-CLI.md Use this command to start the MCP Inspector in CLI mode, specifying the command to start your MCP server. ```bash npx @modelcontextprotocol/inspector --cli ``` -------------------------------- ### Build and Development Commands Source: https://github.com/roychri/mcp-server-asana/blob/main/CLAUDE.md Standard npm scripts for building, running in development, starting the server, watching for changes, and testing with the MCP Inspector UI. Use custom ports if defaults are taken. ```bash # Build the project (uses esbuild) npm run build ``` ```bash # Run in development mode with ts-node (requires Node.js 18-22, fails on v24+) npm run dev ``` ```bash # Start the built server npm start ``` ```bash # Watch mode for TypeScript compilation npm run watch ``` ```bash # Test with MCP Inspector UI (opens client on port 5173, server on port 3000) npm run inspector ``` ```bash # Use custom ports if defaults are taken CLIENT_PORT=5009 SERVER_PORT=3009 npm run inspector ``` -------------------------------- ### Asana SDK Wrapper Example Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/architecture.md Illustrates how the Asana SDK methods are wrapped for consistent naming, parameter transformation, and type safety within the AsanaClientWrapper. ```typescript // Wraps SDK methods const client = new Asana.WorkspacesApi(); client.getWorkspaces(opts); // Exposed as AsanaClientWrapper.listWorkspaces(opts) ``` -------------------------------- ### Start Interactive Shell with MCP Tools (fka.dev) Source: https://github.com/roychri/mcp-server-asana/blob/main/HOW-TO-TEST-MCP-ON-CLI.md Launches an interactive shell session for interacting with an MCP server using the 'mcp' CLI tool. This allows for multiple commands to be run in sequence without re-specifying the server command. ```bash # Interactive shell mode mcp shell npx -y @modelcontextprotocol/server-filesystem ~/Code ``` -------------------------------- ### List Asana Workspaces and Project Templates Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/resources.md Fetches all workspaces and declares the project URI template. Use this to get a list of available workspaces and understand how to reference projects. ```typescript const listResources = async (): Promise ``` -------------------------------- ### Tool Handler Example Usage Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/tool-handler.md Demonstrates how to create and use the tool handler function to invoke an Asana API method. ```typescript import { tool_handler } from './tool-handler.js'; const handler = tool_handler(asanaClient); // Called by MCP server for each tool invocation const result = await handler({ name: "asana_list_workspaces", arguments: { opt_fields: "name,gid" } }); ``` -------------------------------- ### Project Resource Example Response Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/resources.md This JSON object details a specific Asana project, including its GID, name, timestamps, and various attributes like archived status, color, and default view. It also contains nested objects for workspace and team references, and arrays for sections and custom fields. ```json { "name": "Product Launch Q4", "id": "9876543210", "type": "project", "created_at": "2024-01-15T10:30:00.000Z", "modified_at": "2024-06-20T15:45:00.000Z", "archived": false, "public": false, "notes": "Q4 product launch initiative", "color": "light-green", "default_view": "timeline", "due_on": "2024-12-31", "start_on": "2024-10-01", "workspace": { "gid": "1234567890", "name": "My Company Workspace" }, "team": { "gid": "5678901234", "name": "Product Team" }, "sections": [ { "gid": "section-1", "name": "To Do", "created_at": "2024-01-15T10:30:00.000Z" }, { "gid": "section-2", "name": "In Progress", "created_at": "2024-01-15T10:30:00.000Z" } ], "custom_fields": [ { "gid": "field-1", "name": "Priority", "type": "custom_field", "field_type": "enum", "description": "Task priority level", "enum_options": [ { "gid": "option-1", "name": "High" }, { "gid": "option-2", "name": "Medium" }, { "gid": "option-3", "name": "Low" } ] }, { "gid": "field-2", "name": "Estimated Hours", "type": "custom_field", "field_type": "number", "description": "Estimated work hours", "precision": 1 } ] } ``` -------------------------------- ### Initialize AsanaClientWrapper Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/asana-client-wrapper.md Instantiate the AsanaClientWrapper with your personal access token. Ensure the token is securely stored and accessible, for example, via environment variables. ```typescript import { AsanaClientWrapper } from './asana-client-wrapper.js'; const token = process.env.ASANA_ACCESS_TOKEN; const asanaClient = new AsanaClientWrapper(token); ``` -------------------------------- ### Test Local Node.js MCP Server Source: https://github.com/roychri/mcp-server-asana/blob/main/HOW-TO-TEST-MCP-ON-CLI.md A basic example of testing a local Node.js MCP server using the inspector in CLI mode. ```bash npx @modelcontextprotocol/inspector --cli node build/index.js ``` -------------------------------- ### GitHub Actions Workflow for MCP Server Testing Source: https://github.com/roychri/mcp-server-asana/blob/main/HOW-TO-TEST-MCP-ON-CLI.md A GitHub Actions workflow that automates the build and testing of an MCP server. It checks out code, sets up Node.js, installs dependencies, builds the server, and runs tests using the Inspector CLI. ```yaml name: Test MCP Server on: [push, pull_request] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '22' - name: Install dependencies run: npm install - name: Build server run: npm run build - name: Test with Inspector CLI run: | # Test tools listing npx @modelcontextprotocol/inspector --cli node build/index.js --method tools/list # Test tool execution npx @modelcontextprotocol/inspector --cli node build/index.js \ --method tools/call \ --tool-name test_tool \ --tool-arg input=test ``` -------------------------------- ### Tool Methods Reference Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/INDEX.md Provides a complete reference for all 41 tools available in the MCP Server for Asana, including their parameters and examples. This covers various domains like workspace, project, task, comment, tag, section, project status, task-project, and task relationship tools. ```APIDOC ## Tool Methods Reference ### Description This section details all 41 tools available within the MCP Server for Asana. It includes comprehensive information on each tool's signature, parameters, return values, and usage examples. The tools are categorized into Workspace, Project, Task, Comment, Tag, Section, Project Status, Task-Project, and Task Relationship tools. ### Scope Complete API surface of all tools with full signature, parameters, returns, and examples. ``` -------------------------------- ### Tool Methods Reference Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/COMPLETION_SUMMARY.txt A comprehensive reference for all 41 tools available in the MCP Server, detailing parameters, return types, usage examples, error conditions, and read-only status. ```APIDOC ## Tool Methods ### Description Provides detailed documentation for all 41 integrated tools, covering their functionality and usage within the MCP Server. ### Tools - **Total Tools**: 41 - **Categories**: Workspace (1), Project (7), Task (12), Comment/Story (2), Tag (8), Section (4), Project Status (4), Task Relationship (3). ### Documentation Each tool includes complete parameter lists, return types, usage examples, error conditions, and read-only status. Refer to `api-reference/tool-methods.md` for specifics. ``` -------------------------------- ### Export Asana Access Token and Run Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/README.md Set the ASANA_ACCESS_TOKEN environment variable and run the server. This is for full access. ```bash export ASANA_ACCESS_TOKEN="your-token" node dist/index.js ``` -------------------------------- ### Constructor Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/asana-client-wrapper.md Initializes the Asana client with a personal access token. This sets up internal API instances for various Asana resources. ```APIDOC ## Constructor ### Description Initializes the Asana client with the provided access token and sets up internal API instances for workspaces, projects, tasks, stories, project statuses, tags, custom fields, sections, and user task lists. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **token** (string) - Required - Asana personal access token for authentication ### Request Example ```typescript import { AsanaClientWrapper } from './asana-client-wrapper.js'; const token = process.env.ASANA_ACCESS_TOKEN; const asanaClient = new AsanaClientWrapper(token); ``` ### Response N/A (Constructor) ``` -------------------------------- ### Build Process Configuration Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/architecture.md Details the build process using esbuild, specifying the entry point, output, target environment, and injected variables. ```bash build.js (esbuild) ├── Entry: src/index.ts ├── Output: dist/index.js (single file, ESM) ├── Target: Node 18+ ├── Define: __VERSION__ injected from package.json └── Platform: node ``` -------------------------------- ### task-summary Source: https://github.com/roychri/mcp-server-asana/blob/main/README.md Get a summary and status update for a task based on its notes, custom fields and comments. ```APIDOC ## task-summary ### Description Get a summary and status update for a task based on its notes, custom fields and comments. ### Input * **task_id** (string): The task ID to get summary for. ### Returns A detailed prompt with instructions for generating a task summary. ``` -------------------------------- ### List Tools using MCP Tools (fka.dev) Source: https://github.com/roychri/mcp-server-asana/blob/main/HOW-TO-TEST-MCP-ON-CLI.md Lists available tools on an MCP server using the 'mcp' CLI tool. This is an alternative to using the '@modelcontextprotocol/inspector'. ```bash # List tools mcp tools npx -y @modelcontextprotocol/server-filesystem ~/Code ``` -------------------------------- ### Get Tags for a Task Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/asana-client-wrapper.md Retrieve all tags associated with a specific task. Supports pagination and field selection. ```typescript const tags = await asanaClient.getTagsForTask('task-gid', { limit: 20, opt_fields: 'name,color' }); ``` -------------------------------- ### Get Tasks for a Project Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/asana-client-wrapper.md Retrieves all tasks associated with a specific project. Supports pagination and field selection. ```typescript async getTasksForProject(projectId: string, opts: any = {}): Promise ``` ```typescript const tasks = await asanaClient.getTasksForProject('project-gid', { opt_fields: 'name,completed,due_on,assignee', limit: 50 }); ``` -------------------------------- ### Run @wong2/mcp-cli with Configuration Source: https://github.com/roychri/mcp-server-asana/blob/main/HOW-TO-TEST-MCP-ON-CLI.md Executes the '@wong2/mcp-cli' tool using a specified configuration file. This allows for custom settings and authentication methods. ```bash # Use Claude Desktop config npx @wong2/mcp-cli -c config.json ``` -------------------------------- ### Instantiate Asana v3 Client Source: https://github.com/roychri/mcp-server-asana/blob/main/CONVENTIONS.md Instantiate the Asana v3 client and set the access token. Use this for accessing resources like users. ```javascript const Asana = require('asana'); let client = Asana.ApiClient.instance; let token = client.authentications['token']; token.accessToken = ''; let usersApiInstance = new Asana.UsersApi(); // instance to access users usersApiInstance.getUser("me").then(function(me) { console.log(me); }); ``` -------------------------------- ### Get Tasks for a Tag Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/asana-client-wrapper.md Retrieve all tasks that are associated with a specific tag. Allows for filtering and field selection in the response. ```typescript const tasks = await asanaClient.getTasksForTag('tag-gid', { opt_fields: 'name,completed,assignee' }); ``` -------------------------------- ### Build Commands Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/configuration.md Common npm scripts for building, watching, developing, and testing the project. ```bash # Build for production npm run build # Watch mode for development npm run watch # Development with ts-node npm run dev # Test with MCP Inspector UI npm run inspector # Custom ports for inspector CLIENT_PORT=5009 SERVER_PORT=3009 npm run inspector ``` -------------------------------- ### Instantiate Asana v1 Client Source: https://github.com/roychri/mcp-server-asana/blob/main/CONVENTIONS.md Instantiate the Asana v1 client and set the access token. This version uses a different client creation method. ```javascript const asana = require('asana'); const client = asana.Client.create().useAccessToken(''); client.users.me().then(function(me) { console.log(me); }); ``` -------------------------------- ### Get a Specific Tag Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/asana-client-wrapper.md Retrieve details for a specific tag using its GID. You can specify optional fields to include in the response. ```typescript const tag = await asanaClient.getTag('tag-gid', { opt_fields: 'name,color,notes' }); ``` -------------------------------- ### Initialize Asana Client and Authenticate Source: https://github.com/roychri/mcp-server-asana/blob/main/Asana-v3.md Initialize the Asana API client and set your access token for authentication. This is a prerequisite for making API calls. ```javascript const Asana = require('asana'); let client = Asana.ApiClient.instance; let token = client.authentications['token']; token.accessToken = ''; let usersApiInstance = new Asana.UsersApi(); let user_gid = "me"; // String | A string identifying a user. This can either be the string "me", an email, or the gid of a user. let opts = { "opt_fields": "email,name,photo,photo.image_1024x1024,photo.image_128x128,photo.image_21x21,photo.image_27x27,photo.image_36x36,photo.image_60x60,workspaces,workspaces.name" // [String] | This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include. }; usersApiInstance.getUser(user_gid, opts).then((result) => { console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2)); }, (error) => { console.error(error.response.body); }); ``` -------------------------------- ### Get Stories for a Task Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/asana-client-wrapper.md Retrieves all stories and comments associated with a specific task. Supports field selection for customized output. ```typescript async getStoriesForTask(taskId: string, opts: any = {}): Promise ``` ```typescript const stories = await asanaClient.getStoriesForTask('task-gid', { opt_fields: 'text,created_at,created_by,created_by.name' }); ``` -------------------------------- ### Get Project Sections Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/asana-client-wrapper.md Retrieves a list of all sections within a given project. Supports specifying fields to include in the response. ```typescript async getProjectSections(projectId: string, opts: any = {}): Promise ``` ```typescript const sections = await asanaClient.getProjectSections('project-gid', { opt_fields: 'name,created_at' }); ``` -------------------------------- ### Get Project Task Counts Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/asana-client-wrapper.md Fetches the number of tasks within a specific project. Options can be provided for additional fields. ```typescript async getProjectTaskCounts(projectId: string, opts: any = {}): Promise ``` ```typescript const counts = await asanaClient.getProjectTaskCounts('project-gid'); ``` -------------------------------- ### Stories API Endpoints Source: https://github.com/roychri/mcp-server-asana/blob/main/Asana-v3.md Endpoints for managing Asana stories on tasks, including creating, deleting, getting, and updating stories. ```APIDOC ## POST /tasks/{task_gid}/stories ### Description Create a story on a task. ### Method POST ### Endpoint /tasks/{task_gid}/stories ### Parameters #### Path Parameters - **task_gid** (string) - Required - The ID of the task to add the story to. ## DELETE /stories/{story_gid} ### Description Delete a story. ### Method DELETE ### Endpoint /stories/{story_gid} ### Parameters #### Path Parameters - **story_gid** (string) - Required - The ID of the story to delete. ## GET /tasks/{task_gid}/stories ### Description Get stories from a task. ### Method GET ### Endpoint /tasks/{task_gid}/stories ### Parameters #### Path Parameters - **task_gid** (string) - Required - The ID of the task to retrieve stories from. ## GET /stories/{story_gid} ### Description Get a story. ### Method GET ### Endpoint /stories/{story_gid} ### Parameters #### Path Parameters - **story_gid** (string) - Required - The ID of the story to retrieve. ## PUT /stories/{story_gid} ### Description Update a story. ### Method PUT ### Endpoint /stories/{story_gid} ### Parameters #### Path Parameters - **story_gid** (string) - Required - The ID of the story to update. ``` -------------------------------- ### Get a Specific Project Status Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/asana-client-wrapper.md Retrieves a single project status by its GID. Use `opt_fields` to specify which fields to include in the response. ```typescript const status = await asanaClient.getProjectStatus('status-gid', { opt_fields: 'title,text,color,created_at' }); ``` -------------------------------- ### Configure for Claude Desktop Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/README.md Add Asana server configuration to claude_desktop_config.json, specifying command, arguments, and environment variables. ```json { "mcpServers": { "asana": { "command": "npx", "args": ["-y", "@roychri/mcp-server-asana"], "env": {"ASANA_ACCESS_TOKEN": "your-token"} } } } ``` -------------------------------- ### List Available Tools via CLI Source: https://github.com/roychri/mcp-server-asana/blob/main/HOW-TO-TEST-MCP-ON-CLI.md Use this command to list all available tools for an MCP server in CLI mode. ```bash npx @modelcontextprotocol/inspector --cli node build/index.js --method tools/list ``` -------------------------------- ### Get Single Asana Task Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/asana-client-wrapper.md Retrieves a detailed task object by its GID. Supports specifying fields to retrieve using opt_fields. ```typescript async getTask(taskId: string, opts: any = {}): Promise{ // ... implementation details ... } ``` ```typescript const task = await asanaClient.getTask('task-gid', { opt_fields: 'name,notes,assignee,due_on,custom_fields,dependencies,dependents' }); ``` -------------------------------- ### Get Project Details Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/asana-client-wrapper.md Retrieves detailed information for a specific project using its GID. Allows specifying additional fields to be returned. ```typescript async getProject(projectId: string, opts: any = {}): Promise ``` ```typescript const project = await asanaClient.getProject('project-gid', { opt_fields: 'name,notes,color,default_view,archived' }); ``` -------------------------------- ### Request to Get a Prompt Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/types.md Defines the request structure for retrieving or expanding an MCP prompt. Specify the prompt name and any required arguments. ```typescript interface GetPromptRequest { params: { name: string; arguments?: Record; }; } ``` -------------------------------- ### Configure Claude Desktop for Asana Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/README.md Add this configuration to your 'claude_desktop_config.json' file to enable the Asana MCP server. Ensure you replace 'your-token-here' with your actual Asana access token. ```json { "mcpServers": { "asana": { "command": "npx", "args": ["-y", "@roychri/mcp-server-asana"], "env": { "ASANA_ACCESS_TOKEN": "your-token-here" } } } } ``` -------------------------------- ### GET /tasks Source: https://github.com/roychri/mcp-server-asana/blob/main/Asana-v3.md Retrieves a list of tasks. Supports filtering and pagination. The `opt_fields` parameter allows for specifying which fields to include in the response. ```APIDOC ## GET /tasks ### Description Retrieves a list of tasks. Supports filtering and pagination. The `opt_fields` parameter allows for specifying which fields to include in the response. ### Method GET ### Endpoint /tasks ### Parameters #### Query Parameters - **limit** (integer) - Optional - The number of results to return per page. - **project** (string) - Optional - The GID of the project to filter tasks by. - **opt_fields** (string) - Optional - A comma-separated list of fields to include in the response. For example: `name,assignee.name,completed_at`. ### Request Example (without opt_fields) ```javascript const Asana = require('asana'); let client = Asana.ApiClient.instance; let token = client.authentications['token']; token.accessToken = ''; let tasksApiInstance = new Asana.TasksApi(); let opts = { "limit": 2, "project": "" }; // GET - get multiple tasks tasksApiInstance.getTasks(opts).then((result) => { console.log(JSON.stringify(result.data, null, 2)); }, (error) => { console.error(error.response.body); }); ``` ### Request Example (with opt_fields) ```javascript const Asana = require('asana'); let client = Asana.ApiClient.instance; let token = client.authentications['token']; token.accessToken = ''; let tasksApiInstance = new Asana.TasksApi(); let opts = { "limit": 1, "project": "", "opt_fields": "actual_time_minutes,approval_status,assignee,assignee.name,assignee_section,assignee_section.name,assignee_status,completed,completed_at,completed_by,completed_by.name,created_at,created_by,custom_fields,custom_fields.asana_created_field,custom_fields.created_by,custom_fields.created_by.name,custom_fields.currency_code,custom_fields.custom_label,custom_fields.custom_label_position,custom_fields.date_value,custom_fields.date_value.date,custom_fields.date_value.date_time,custom_fields.description,custom_fields.display_value,custom_fields.enabled,custom_fields.enum_options,custom_fields.enum_options.color,custom_fields.enum_options.enabled,custom_fields.enum_options.name,custom_fields.enum_value,custom_fields.enum_value.color,custom_fields.enum_value.enabled,custom_fields.enum_value.name,custom_fields.format,custom_fields.has_notifications_enabled,custom_fields.is_formula_field,custom_fields.is_global_to_workspace,custom_fields.is_value_read_only,custom_fields.multi_enum_values,custom_fields.multi_enum_values.color,custom_fields.multi_enum_values.enabled,custom_fields.multi_enum_values.name,custom_fields.name,custom_fields.number_value,custom_fields.people_value,custom_fields.people_value.name,custom_fields.precision,custom_fields.resource_subtype,custom_fields.text_value,custom_fields.type,dependencies,dependents,due_at,due_on,external,external.data,followers,followers.name,hearted,hearts,hearts.user,hearts.user.name,html_notes,is_rendered_as_separator,liked,likes,likes.user,likes.user.name,memberships,memberships.project,memberships.project.name,memberships.section,memberships.section.name,modified_at,name,notes,num_hearts,num_likes,num_subtasks,offset,parent,parent.created_by,parent.name,parent.resource_subtype,path,permalink_url,projects,projects.name,resource_subtype,start_at,start_on,tags,tags.name,uri,workspace,workspace.name" }; // GET - get multiple tasks tasksApiInstance.getTasks(opts).then((result) => { console.log(JSON.stringify(result.data, null, 2)); }, (error) => { console.error(error.response.body); }); ``` ### Response #### Success Response (200) - **gid** (string) - The GID of the task. - **name** (string) - The name of the task. - **resource_type** (string) - The type of resource. - **resource_subtype** (string) - The subtype of the resource. #### Response Example (without opt_fields) ```json [ { "gid": "123", "name": "Task 1", "resource_type": "task", "resource_subtype": "default_task" }, { "gid": "456", "name": "Task 2", "resource_type": "task", "resource_subtype": "default_task" } ] ``` ``` -------------------------------- ### MCP Server Package.json Configuration Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/mcp-server.md Configures the MCP server's entry point and binary for command-line execution within the package.json file. ```json { "main": "dist/index.js", "bin": { "mcp-server-asana": "dist/index.js" } } ``` -------------------------------- ### Task Templates API Endpoints Source: https://github.com/roychri/mcp-server-asana/blob/main/Asana-v3.md Endpoints for managing Asana task templates, including deleting, getting, and instantiating tasks from templates. ```APIDOC ## DELETE /task_templates/{task_template_gid} ### Description Delete a task template. ### Method DELETE ### Endpoint /task_templates/{task_template_gid} ### Parameters #### Path Parameters - **task_template_gid** (string) - Required - The ID of the task template to delete. ## GET /task_templates/{task_template_gid} ### Description Get a task template. ### Method GET ### Endpoint /task_templates/{task_template_gid} ### Parameters #### Path Parameters - **task_template_gid** (string) - Required - The ID of the task template to retrieve. ## GET /task_templates ### Description Get multiple task templates. ### Method GET ### Endpoint /task_templates ## POST /task_templates/{task_template_gid}/instantiateTask ### Description Instantiate a task from a task template. ### Method POST ### Endpoint /task_templates/{task_template_gid}/instantiateTask ### Parameters #### Path Parameters - **task_template_gid** (string) - Required - The ID of the task template to instantiate a task from. ``` -------------------------------- ### Tags API Endpoints Source: https://github.com/roychri/mcp-server-asana/blob/main/Asana-v3.md Endpoints for managing Asana tags, including creating, deleting, getting, and retrieving tags for tasks and workspaces. ```APIDOC ## POST /tags ### Description Create a tag. ### Method POST ### Endpoint /tags ## POST /workspaces/{workspace_gid}/tags ### Description Create a tag in a workspace. ### Method POST ### Endpoint /workspaces/{workspace_gid}/tags ### Parameters #### Path Parameters - **workspace_gid** (string) - Required - The workspace in which to create the tag. ## DELETE /tags/{tag_gid} ### Description Delete a tag. ### Method DELETE ### Endpoint /tags/{tag_gid} ### Parameters #### Path Parameters - **tag_gid** (string) - Required - The ID of the tag to delete. ## GET /tags/{tag_gid} ### Description Get a tag. ### Method GET ### Endpoint /tags/{tag_gid} ### Parameters #### Path Parameters - **tag_gid** (string) - Required - The ID of the tag to retrieve. ## GET /tags ### Description Get multiple tags. ### Method GET ### Endpoint /tags ## GET /tasks/{task_gid}/tags ### Description Get a task's tags. ### Method GET ### Endpoint /tasks/{task_gid}/tags ### Parameters #### Path Parameters - **task_gid** (string) - Required - The ID of the task to retrieve tags from. ## GET /workspaces/{workspace_gid}/tags ### Description Get tags in a workspace. ### Method GET ### Endpoint /workspaces/{workspace_gid}/tags ### Parameters #### Path Parameters - **workspace_gid** (string) - Required - The workspace to retrieve tags from. ## PUT /tags/{tag_gid} ### Description Update a tag. ### Method PUT ### Endpoint /tags/{tag_gid} ### Parameters #### Path Parameters - **tag_gid** (string) - Required - The ID of the tag to update. ``` -------------------------------- ### Call a Tool using MCP Tools (fka.dev) Source: https://github.com/roychri/mcp-server-asana/blob/main/HOW-TO-TEST-MCP-ON-CLI.md Calls a specific tool on an MCP server using the 'mcp' CLI. The tool name and its parameters (as a JSON string) are provided. ```bash # Call a tool mcp call read_file --params '{"path": "/path/to/file"}' \ npx -y @modelcontextprotocol/server-filesystem ~/Code ``` -------------------------------- ### Call Specific Tool with Simple Parameters Source: https://github.com/roychri/mcp-server-asana/blob/main/HOW-TO-TEST-MCP-ON-CLI.md Call a specific tool on an MCP server using simple key-value arguments. ```bash npx @modelcontextprotocol/inspector --cli node build/index.js \ --method tools/call \ --tool-name mytool \ --tool-arg key=value \ --tool-arg another=value2 ``` -------------------------------- ### Pass Arguments to MCP Server Command Source: https://github.com/roychri/mcp-server-asana/blob/main/HOW-TO-TEST-MCP-ON-CLI.md Pass arguments directly to the MCP server command when starting it via the inspector in CLI mode. ```bash npx @modelcontextprotocol/inspector --cli node build/index.js arg1 arg2 ``` -------------------------------- ### listResources Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/api-reference/resources.md Fetches all workspaces in the authenticated user's account and returns them as resources. Also declares the project URI template. ```APIDOC ## listResources ### Description Fetches all workspaces in the authenticated user's account and returns them as resources. Also declares the project URI template. ### Method async ### Endpoint N/A (SDK function) ### Returns Object with two arrays: - `resources`: Array of concrete workspace resources - `resourceTemplates`: Array of resource templates (projects) ### Response Example ```json { "resources": [ { "uri": "asana://workspace/1234567890", "name": "Engineering Workspace", "description": "Asana workspace: Engineering Workspace" }, { "uri": "asana://workspace/9876543210", "name": "Marketing Workspace", "description": "Asana workspace: Marketing Workspace" } ], "resourceTemplates": [ { "uriTemplate": "asana://project/{project_gid}", "name": "Asana Project Template", "description": "Get details for a specific Asana project by GID", "mimeType": "application/json" } ] } ``` ``` -------------------------------- ### Project Structure Overview Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/README.md Illustrates the directory and file structure of the MCP Server Asana project, highlighting key modules and tool definitions. ```plaintext src/ index.ts # Entry point asana-client-wrapper.ts # Asana SDK wrapper tool-handler.ts # Tool routing prompt-handler.ts # Prompts resource-handler.ts # Resources asana-validate-xml.ts # HTML validation version.ts # Version injection └── tools/ # Tool definitions ├── workspace-tools.ts ├── project-tools.ts ├── task-tools.ts ├── story-tools.ts ├── tag-tools.ts ├── section-tools.ts ├── task-relationship-tools.ts └── project-status-tools.ts ``` -------------------------------- ### Handle ASANA_ACCESS_TOKEN Not Set Error Source: https://github.com/roychri/mcp-server-asana/blob/main/_autodocs/errors.md This example shows how to fix the 'ASANA_ACCESS_TOKEN Not Set' error by exporting the environment variable before running the Node.js script. ```bash $ node dist/index.js Please set ASANA_ACCESS_TOKEN environment variable ``` ```bash export ASANA_ACCESS_TOKEN="your-token-here" node dist/index.js ```