get-dataflow
Retrieve details of a Coupler.io data flow by its ID to access its configuration and status.
Instructions
Get a Coupler.io data flow by ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dataflowId | Yes | The ID of the data flow with a successful run. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dataflow | Yes |
Implementation Reference
- src/tools/get-dataflow/handler.ts:11-48 (handler)Main handler function for the get-dataflow tool. Validates input with zod, makes a GET request to Coupler.io API /dataflows/{dataflowId}{?type}, and returns the dataflow JSON.
export const handler = async (params?: Record<string, unknown>): Promise<CallToolResult> => { const validationResult = zodInputSchema.safeParse(params) if (!validationResult.success) { const error = fromError(validationResult.error) logger.error(`Invalid parameters for get-dataflow tool: ${error.toString()}`) return textResponse({ text: `Invalid parameters for get-dataflow tool. ${error.toString()}`, isError: true, }) } const coupler = new CouplerioClient({ auth: COUPLER_ACCESS_TOKEN }) const response = await coupler.request('/dataflows/{dataflowId}{?type}', { expand: { dataflowId: validationResult.data.dataflowId, type: 'from_template' }, request: { method: 'GET' } }) if (!response.ok) { const errorText = await buildErrorMessage( { response, customText: `Failed to get data flow ${validationResult.data.dataflowId}.`}) logger.error(errorText) return textResponse({ isError: true, text: errorText }) } const dataflow = await response.json() return textResponse({ text: JSON.stringify(dataflow, null, 2), structuredContent: { dataflow } }) } - Input and output schemas using Zod. Input requires 'dataflowId' as a non-empty string. Output describes the dataflow object with id, name, schedule, sources, etc.
import { z } from 'zod' import { zodToJsonSchema } from 'zod-to-json-schema' export const zodInputSchema = z.object({ dataflowId: z.string() .min(1, 'dataflowId is required.') .regex(/^\S+$/, 'dataflowId must not be empty.') .describe('The ID of the data flow with a successful run.') }).strict() export const inputSchema = zodToJsonSchema(zodInputSchema) const zodOutputSchema = z.object({ dataflow: z.object({ id: z.string().describe('The ID of the data flow.'), name: z.string().describe('The name of the data flow.'), last_successful_execution_id: z.string().describe('The ID of the last successful run (execution) of the data flow.'), schedule: z.string().nullish().describe('The schedule of the data flow. Crontab format.'), sources: z.array(z.object({ id: z.string().describe('The ID of the source.'), name: z.string().describe('The name of the source.'), type: z.string().describe('The type of the source.'), params_configured: z.boolean().describe('Whether the source params are configured.'), enabled: z.boolean().describe('Whether the source is enabled.'), data_connections_count: z.number().int().nonnegative().describe('The number of data connections for the source.'), last_success_run_at: z.string().nullish().describe('The date and time of the last successful run of the source. ISO 8601 format.'), error_details: z.string().nullish().describe('The error details of the source.'), })).describe('The sources of the data flow.'), }) }) export const outputSchema = zodToJsonSchema(zodOutputSchema) - src/tools/get-dataflow/index.ts:1-19 (registration)Exports the tool's name, description, handler, and toolListEntry (which includes inputSchema, outputSchema, annotations). This is used by the server to register and list the tool.
import { inputSchema, outputSchema } from './schema.js' export { handler } from './handler.js' export const name = 'get-dataflow' export const description = 'Get a Coupler.io data flow by ID.' const annotations = { title: 'Get a Coupler.io data flow by ID.' } export const toolListEntry = { name, description, inputSchema, outputSchema, annotations, } - src/server/index.ts:8-8 (registration)Import of the get-dataflow tool module into the server.
import * as getDataflow from '../tools/get-dataflow/index.js' - src/server/index.ts:14-14 (registration)Registration of the get-dataflow handler in the TOOL_MAP, mapping the tool name to its handler function.
[getDataflow.name]: getDataflow.handler,