get_data_source
Retrieve configuration details and metadata for a specific data source by providing its unique identifier to manage database connections and query settings.
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 async handler function that executes the get_data_source tool logic: validates data_source_id, fetches the data source via RedashClient, stringifies to JSON, or returns error.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 data_source_id as a required 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:59-59 (registration)Registration of getDataSourceTool in the tools array used by the MCP server's list_tools and call_tool request handlers.const tools = [listDataSourcesTool, getDataSourceTool, executeQueryAndWaitTool, listQueriesTool];
- src/redash-client.ts:118-120 (helper)Helper method in RedashClient that performs the API request to retrieve 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}`); }