Skip to main content
Glama

docs-mcp-server

ListJobsTool.ts2.22 kB
import type { IPipeline } from "../pipeline/trpc/interfaces"; import type { PipelineJob, PipelineJobStatus } from "../pipeline/types"; import type { JobInfo } from "./GetJobInfoTool"; // Import JobInfo /** * Input parameters for the ListJobsTool. */ export interface ListJobsInput { /** Optional status to filter jobs by. */ status?: PipelineJobStatus; } /** * Response structure for the ListJobsTool. */ export interface ListJobsToolResponse { jobs: JobInfo[]; } /** * Tool for listing pipeline jobs managed by the pipeline. * Allows filtering jobs by their status. */ export class ListJobsTool { private pipeline: IPipeline; /** * Creates an instance of ListJobsTool. * @param pipeline The pipeline instance. */ constructor(pipeline: IPipeline) { this.pipeline = pipeline; } /** * Executes the tool to retrieve a list of pipeline jobs using single source of truth. * @param input - The input parameters, optionally including a status filter. * @returns A promise that resolves with the list of simplified job objects. */ async execute(input: ListJobsInput): Promise<ListJobsToolResponse> { const jobs = await this.pipeline.getJobs(input.status); // Transform jobs into simplified objects using enhanced PipelineJob interface const simplifiedJobs: JobInfo[] = jobs.map((job: PipelineJob): JobInfo => { return { id: job.id, library: job.library, version: job.version, status: job.status, dbStatus: job.versionStatus, createdAt: job.createdAt.toISOString(), startedAt: job.startedAt?.toISOString() ?? null, finishedAt: job.finishedAt?.toISOString() ?? null, error: job.error?.message ?? null, progress: job.progressMaxPages && job.progressMaxPages > 0 ? { pages: job.progressPages || 0, totalPages: job.progressMaxPages, totalDiscovered: job.progress?.totalDiscovered || job.progressMaxPages, } : undefined, updatedAt: job.updatedAt?.toISOString(), errorMessage: job.errorMessage ?? undefined, }; }); return { jobs: simplifiedJobs }; } }

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/arabold/docs-mcp-server'

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