Skip to main content
Glama
njlnaet
by njlnaet

coderswap_get_job_status

Check the status of a research ingestion job by providing the job ID to monitor progress and completion.

Instructions

Check the status of a research ingestion job

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
job_idYes

Implementation Reference

  • src/index.ts:428-483 (registration)
    Registration of the 'coderswap_get_job_status' tool, including input/output schemas and the handler function.
    server.registerTool(
      'coderswap_get_job_status',
      {
        title: 'Get CoderSwap Job Status',
        description: 'Check the status of a research ingestion job',
        inputSchema: {
          job_id: z.string().min(1, 'job_id is required')
        },
        outputSchema: {
          job_id: z.string(),
          state: z.string(),
          crawled_count: z.number().optional(),
          failed_count: z.number().optional()
        }
      },
      async ({ job_id }) => {
        try {
          log('debug', 'Checking job status', { job_id })
          const job = await client.getJobStatus(job_id)
    
          const output = {
            job_id: job.job_id,
            state: job.state,
            crawled_count: job.crawled_count,
            failed_count: job.failed_count
          }
    
          log('info', `Job ${job_id} status: ${job.state}`)
    
          let statusText = `Job: ${job_id}\nStatus: ${job.state}`
          if (job.crawled_count !== undefined) {
            statusText += `\nCrawled: ${job.crawled_count} documents`
          }
          if (job.failed_count !== undefined && job.failed_count > 0) {
            statusText += `\nFailed: ${job.failed_count} documents`
          }
    
          return {
            content: [{
              type: 'text',
              text: statusText
            }],
            structuredContent: output
          }
        } catch (error) {
          log('error', 'Failed to get job status', { job_id, error: error instanceof Error ? error.message : error })
          return {
            content: [{
              type: 'text',
              text: `✗ Failed to get job status: ${error instanceof Error ? error.message : 'Unknown error'}`
            }],
            isError: true
          }
        }
      }
    )
  • The async handler function that executes the tool logic: fetches job status via client and formats response.
    async ({ job_id }) => {
      try {
        log('debug', 'Checking job status', { job_id })
        const job = await client.getJobStatus(job_id)
    
        const output = {
          job_id: job.job_id,
          state: job.state,
          crawled_count: job.crawled_count,
          failed_count: job.failed_count
        }
    
        log('info', `Job ${job_id} status: ${job.state}`)
    
        let statusText = `Job: ${job_id}\nStatus: ${job.state}`
        if (job.crawled_count !== undefined) {
          statusText += `\nCrawled: ${job.crawled_count} documents`
        }
        if (job.failed_count !== undefined && job.failed_count > 0) {
          statusText += `\nFailed: ${job.failed_count} documents`
        }
    
        return {
          content: [{
            type: 'text',
            text: statusText
          }],
          structuredContent: output
        }
      } catch (error) {
        log('error', 'Failed to get job status', { job_id, error: error instanceof Error ? error.message : error })
        return {
          content: [{
            type: 'text',
            text: `✗ Failed to get job status: ${error instanceof Error ? error.message : 'Unknown error'}`
          }],
          isError: true
        }
      }
    }
  • CoderSwapClient.getJobStatus method that makes the API request to retrieve the job status from the backend.
    async getJobStatus(jobId: string): Promise<IngestJobStatus> {
      const res = await fetch(`${this.baseUrl}/research/jobs/${jobId}`, {
        headers: this.headers
      })
      const data = await this.handleResponse<{ job: IngestJobStatus }>(res)
      return data.job
    }
  • Zod schema for job status input (job_id), defined in types.ts (matches inline schema).
    export const jobStatusSchema = z.object({
      job_id: z.string().min(1)
    })

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

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