list_dataverse_tables
Retrieve and filter Dataverse tables to discover available data models, find custom tables, or get an overview of table structure with custom/system and managed/unmanaged filtering options.
Instructions
Retrieves a list of tables in the Dataverse environment with filtering options. Use this to discover available tables, find custom tables, or get an overview of the data model. Supports filtering by custom/system tables and managed/unmanaged status.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customOnly | No | Whether to list only custom tables | |
| filter | No | OData filter expression | |
| includeManaged | No | Whether to include managed tables |
Implementation Reference
- src/tools/table-tools.ts:366-422 (handler)The handler function for 'list_dataverse_tables' tool. It constructs an OData query for EntityDefinitions with filters based on input parameters (customOnly, includeManaged, filter), retrieves the metadata using client.getMetadata, processes the results into a simplified table list, and returns formatted text output or error.async (params) => { try { let queryParams: Record<string, any> = { $select: "LogicalName,DisplayName,DisplayCollectionName,IsCustomEntity,IsManaged,OwnershipType,HasActivities,HasNotes" }; let filters: string[] = []; if (params.customOnly) { filters.push("IsCustomEntity eq true"); } if (!params.includeManaged) { filters.push("IsManaged eq false"); } if (params.filter) { filters.push(params.filter); } if (filters.length > 0) { queryParams.$filter = filters.join(" and "); } const result = await client.getMetadata<ODataResponse<EntityMetadata>>("EntityDefinitions", queryParams); const tableList = result.value.map(entity => ({ logicalName: entity.LogicalName, displayName: entity.DisplayName?.UserLocalizedLabel?.Label || entity.LogicalName, displayCollectionName: entity.DisplayCollectionName?.UserLocalizedLabel?.Label || "", isCustom: entity.IsCustomEntity, isManaged: entity.IsManaged, ownershipType: entity.OwnershipType, hasActivities: entity.HasActivities, hasNotes: entity.HasNotes })); return { content: [ { type: "text", text: `Found ${tableList.length} tables:\n\n${JSON.stringify(tableList, null, 2)}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error listing tables: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
- src/tools/table-tools.ts:360-364 (schema)Zod input schema defining the parameters for the list_dataverse_tables tool: customOnly (boolean, default false), includeManaged (boolean, default false), filter (optional string for OData filter).inputSchema: { customOnly: z.boolean().default(false).describe("Whether to list only custom tables"), includeManaged: z.boolean().default(false).describe("Whether to include managed tables"), filter: z.string().optional().describe("OData filter expression") }
- src/tools/table-tools.ts:354-424 (registration)The exported listTablesTool function that registers the 'list_dataverse_tables' MCP tool with the server, including its title, description, input schema, and handler.export function listTablesTool(server: McpServer, client: DataverseClient) { server.registerTool( "list_dataverse_tables", { title: "List Dataverse Tables", description: "Retrieves a list of tables in the Dataverse environment with filtering options. Use this to discover available tables, find custom tables, or get an overview of the data model. Supports filtering by custom/system tables and managed/unmanaged status.", inputSchema: { customOnly: z.boolean().default(false).describe("Whether to list only custom tables"), includeManaged: z.boolean().default(false).describe("Whether to include managed tables"), filter: z.string().optional().describe("OData filter expression") } }, async (params) => { try { let queryParams: Record<string, any> = { $select: "LogicalName,DisplayName,DisplayCollectionName,IsCustomEntity,IsManaged,OwnershipType,HasActivities,HasNotes" }; let filters: string[] = []; if (params.customOnly) { filters.push("IsCustomEntity eq true"); } if (!params.includeManaged) { filters.push("IsManaged eq false"); } if (params.filter) { filters.push(params.filter); } if (filters.length > 0) { queryParams.$filter = filters.join(" and "); } const result = await client.getMetadata<ODataResponse<EntityMetadata>>("EntityDefinitions", queryParams); const tableList = result.value.map(entity => ({ logicalName: entity.LogicalName, displayName: entity.DisplayName?.UserLocalizedLabel?.Label || entity.LogicalName, displayCollectionName: entity.DisplayCollectionName?.UserLocalizedLabel?.Label || "", isCustom: entity.IsCustomEntity, isManaged: entity.IsManaged, ownershipType: entity.OwnershipType, hasActivities: entity.HasActivities, hasNotes: entity.HasNotes })); return { content: [ { type: "text", text: `Found ${tableList.length} tables:\n\n${JSON.stringify(tableList, null, 2)}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error listing tables: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } ); }
- src/index.ts:143-143 (registration)Top-level call in the main entry point that invokes listTablesTool to register the tool with the MCP server instance.listTablesTool(server, dataverseClient);