halopsa_list_tables
Discover available tables in the HaloPSA database to identify what data can be queried. Use this tool to explore database structure before writing SQL queries.
Instructions
List all available tables in the HaloPSA database by querying sys.tables. Returns a complete list of all tables that can be queried. Use this to discover what data is available before writing queries.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | Optional filter to search for specific tables. Example: "fault", "user", "ticket" |
Input Schema (JSON Schema)
{
"properties": {
"filter": {
"description": "Optional filter to search for specific tables. Example: \"fault\", \"user\", \"ticket\"",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/index.ts:291-317 (handler)Main handler logic for the halopsa_list_tables tool: constructs SQL query for sys.tables (with optional filter), executes it via haloPSAClient, extracts and sorts table names, returns formatted JSON response.case 'halopsa_list_tables': { const { filter } = args as any; let sql = 'SELECT Name FROM sys.tables'; if (filter) { const escapedFilter = filter.replace(/'/g, "''"); sql += ` WHERE LOWER(Name) LIKE '%${escapedFilter.toLowerCase()}%'`; } result = await haloPSAClient.executeQuery(sql); let tables: string[] = []; if (result?.report?.rows && Array.isArray(result.report.rows)) { tables = result.report.rows.map((row: any) => row.Name || row.name); tables.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase())); } return { content: [{ type: 'text', text: JSON.stringify({ tables, count: tables.length, filter: filter || 'none' }, null, 2) }] }; }
- src/index.ts:43-55 (schema)Tool schema definition for halopsa_list_tables, including name, description, and inputSchema with optional filter parameter.{ name: 'halopsa_list_tables', description: 'List all available tables in the HaloPSA database by querying sys.tables. Returns a complete list of all tables that can be queried. Use this to discover what data is available before writing queries.', inputSchema: { type: 'object', properties: { filter: { type: 'string', description: 'Optional filter to search for specific tables. Example: "fault", "user", "ticket"' } } } },
- src/index.ts:279-281 (registration)Tool registration via the listTools request handler that returns the complete tools array containing halopsa_list_tables.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });