Skip to main content
Glama

list_tasks

Read-only

View and filter tasks by status, batch ID, or recency to monitor AI workflow progress and manage long-running operations.

Instructions

List all tasks with their current status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
status_filterNoOptional: Filter tasks by status
batch_idNoOptional: Filter tasks by batch ID to only show tasks from a specific batch
recent_onlyNoOptional: Only show tasks from the last 2 hours (default: false)

Implementation Reference

  • Handler function that executes the list_tasks tool. Retrieves all tasks from TaskManager, applies optional filters (status_filter, batch_id, recent_only), computes summaries and stats, and returns formatted JSON response.
    case 'list_tasks': {
        let allTasks = taskManager.getAllTasks();
    
        // Apply recent_only filter (last 2 hours)
        if (args.recent_only) {
            const twoHoursAgo = Date.now() - 2 * 60 * 60 * 1000;
            allTasks = allTasks.filter(
                t => t.createdAt.getTime() > twoHoursAgo
            );
        }
    
        // Apply batch_id filter
        if (args.batch_id) {
            allTasks = allTasks.filter(
                t => t.batchId === args.batch_id
            );
        }
    
        // Apply status filter
        const filteredTasks = args.status_filter
            ? allTasks.filter(t => t.status === args.status_filter)
            : allTasks;
    
        const taskSummaries = filteredTasks.map(t => ({
            id: t.id,
            status: t.status,
            task: t.task.substring(0, 100),
            model: t.model || t.modelClass,
            batchId: t.batchId,
            readOnly: t.readOnly,
            createdAt: t.createdAt,
            completedAt: t.completedAt,
        }));
    
        // Calculate stats for filtered tasks
        const stats = {
            total: filteredTasks.length,
            pending: filteredTasks.filter(t => t.status === 'pending')
                .length,
            running: filteredTasks.filter(t => t.status === 'running')
                .length,
            completed: filteredTasks.filter(
                t => t.status === 'completed'
            ).length,
            failed: filteredTasks.filter(t => t.status === 'failed')
                .length,
            cancelled: filteredTasks.filter(
                t => t.status === 'cancelled'
            ).length,
        };
    
        return {
            content: [
                {
                    type: 'text',
                    text: JSON.stringify(
                        {
                            stats,
                            tasks: taskSummaries,
                            filters_applied: {
                                batch_id: args.batch_id || null,
                                status: args.status_filter || null,
                                recent_only: args.recent_only || false,
                            },
                        },
                        null,
                        2
                    ),
                },
            ],
        };
    }
  • Tool schema definition including name, description, annotations, and inputSchema for parameters: status_filter (enum), batch_id (string), recent_only (boolean).
    const LIST_TASKS_TOOL: Tool = {
        name: 'list_tasks',
        description: 'List all tasks with their current status.',
        annotations: {
            title: 'List All Tasks',
            readOnlyHint: true, // Only reads task list
            destructiveHint: false, // Doesn't modify or destroy data
            idempotentHint: false, // Task list may change between calls
            openWorldHint: false, // Only queries local task state
        },
        inputSchema: {
            type: 'object',
            properties: {
                status_filter: {
                    type: 'string',
                    description: 'Optional: Filter tasks by status',
                    enum: [
                        'pending',
                        'running',
                        'completed',
                        'failed',
                        'cancelled',
                    ],
                },
                batch_id: {
                    type: 'string',
                    description:
                        'Optional: Filter tasks by batch ID to only show tasks from a specific batch',
                },
                recent_only: {
                    type: 'boolean',
                    description:
                        'Optional: Only show tasks from the last 2 hours (default: false)',
                    default: false,
                },
            },
            required: [], // All parameters are optional
        },
    };
  • src/serve.ts:558-579 (registration)
    Registers the list_tasks tool by including LIST_TASKS_TOOL in the array returned by the ListToolsRequestHandler.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
        if (process.env.MCP_MODE !== 'true') {
            logger.debug('Received ListTools request');
        }
        const response = {
            tools: [
                RUN_TASK_TOOL,
                CHECK_TASK_STATUS_TOOL,
                GET_TASK_RESULT_TOOL,
                CANCEL_TASK_TOOL,
                WAIT_FOR_TASK_TOOL,
                LIST_TASKS_TOOL,
            ],
        };
        if (process.env.MCP_MODE !== 'true') {
            logger.debug(
                'Returning tools:',
                response.tools.map(t => t.name)
            );
        }
        return response;
    });
  • Helper method in TaskManager that returns the complete list of all current tasks, used by the list_tasks handler.
    public getAllTasks(): TaskInfo[] {
        return Array.from(this.tasks.values());
    }
Behavior3/5

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

Annotations provide key behavioral hints (readOnlyHint: true, destructiveHint: false), indicating it's a safe read operation. The description adds minimal context by implying it returns current statuses, but doesn't disclose details like pagination, rate limits, or what 'all' entails (e.g., system-wide or user-specific). No contradiction with annotations exists.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse quickly.

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?

Given the tool's moderate complexity (list operation with filtering), rich annotations (covering safety), and full schema coverage, the description is adequate but incomplete. It lacks output details (no schema provided), doesn't explain behavioral constraints like limits, and misses sibling differentiation, leaving gaps for an agent to infer usage.

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?

With 100% schema description coverage, the input schema fully documents all three parameters (status_filter, batch_id, recent_only), including enums and defaults. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline for high coverage without compensating value.

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

Purpose4/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 ('tasks') with scope ('all'), making the purpose evident. However, it doesn't explicitly differentiate from sibling tools like 'check_task_status' or 'get_task_result', which might also involve task retrieval but with different scopes or purposes.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'check_task_status' for individual tasks or 'get_task_result' for completed tasks. It lacks context on prerequisites, such as whether authentication is needed or if it's suitable for real-time monitoring versus historical queries.

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/just-every/mcp-task'

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