Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.2 KB
Raw Blame
import { createAction } from '@activepieces/pieces-framework';
import { assertNotNullOrUndefined } from '@activepieces/pieces-framework';
import { todoistRestClient } from '../common/client/rest-client';
import { todoistAuth } from '../..';
import { listProjectsActionOutputSchema } from '../output-schemas';

export const todoistListProjectsAction = createAction({
  auth: todoistAuth,
  name: 'todoist_list_projects',
  classification: 'SEARCH',
  displayName: 'List Projects',
  description: 'List all Todoist projects.',
  audience: 'ai',
  aiMetadata: {
    description:
      'Lists every Todoist project (active, not archived) with id and name. Use this to resolve a project name to its ID before any project-scoped operation, or to enumerate available projects; to match by a name fragment use Search Projects, for archived ones use List Archived Projects. Read-only and idempotent.',
    idempotent: true,
  },
  outputSchema: listProjectsActionOutputSchema,
  props: {},
  async run(context) {
    const token = context.auth.access_token;
    assertNotNullOrUndefined(token, 'token');

    const projects = await todoistRestClient.projects.list({ token });
    return {
      projects,
      count: projects.length,
    };
  },
});