get_data_source
Retrieve configuration and connection details for a specific data source in Redash by providing its ID.
Instructions
Get details about a specific data source
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data_source_id | Yes | The ID of the data source |
Implementation Reference
- src/tools/datasource.ts:74-110 (handler)The handler function that implements the core logic of the 'get_data_source' tool: validates the data_source_id argument, fetches the data source using RedashClient, stringifies it to JSON, or returns an error response.handler: async (args, client) => { try { const dataSourceId = args.data_source_id; if (typeof dataSourceId !== 'number') { return { content: [ { type: 'text', text: 'Error: data_source_id is required and must be a number', } as TextContent, ], isError: true, }; } const dataSource = await client.getDataSource(dataSourceId); return { content: [ { type: 'text', text: JSON.stringify(dataSource, null, 2), } as TextContent, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error getting data source: ${error instanceof Error ? error.message : String(error)}`, } as TextContent, ], isError: true, }; } },
- src/tools/datasource.ts:62-73 (schema)Input schema definition for the 'get_data_source' tool, specifying the required 'data_source_id' as a number >=1.inputSchema: { type: 'object', properties: { data_source_id: { type: 'number', description: 'The ID of the data source', minimum: 1, }, }, required: ['data_source_id'], additionalProperties: false, },
- src/index.ts:56-59 (registration)Registration of the getDataSourceTool in the tools array used by the MCP server's list_tools and call_tool request handlers./** * Register tools */ const tools = [listDataSourcesTool, getDataSourceTool, executeQueryAndWaitTool, listQueriesTool];
- src/redash-client.ts:117-122 (helper)Helper method in RedashClient that performs the API request to fetch a specific data source by ID, used by the tool handler.*/ async getDataSource(id: number): Promise<DataSource> { return this.request<DataSource>(`/api/data_sources/${id}`); } /**