Skip to main content
Glama
mwhesse

Dataverse MCP Server

by mwhesse

list_dataverse_optionsets

Retrieve available choice lists and option sets from Dataverse with filtering options to discover custom sets and manage reusable options.

Instructions

Retrieves a list of option sets in the Dataverse environment with filtering options. Use this to discover available choice lists, find custom option sets, or get an overview of reusable options. Supports filtering by custom/system and managed/unmanaged status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customOnlyNoWhether to list only custom option sets
filterNoOData filter expression
includeManagedNoWhether to include managed option sets
topNoMaximum number of option sets to return (default: 50)

Implementation Reference

  • The core handler logic that constructs an OData query for GlobalOptionSetDefinitions, retrieves option set metadata, transforms it into a user-friendly list with details like name, display name, description, status flags, and option count, then returns formatted text output or error.
    async (params) => { try { // Note: $filter is not supported on GlobalOptionSetDefinitions let queryParams: Record<string, any> = { $select: "Name,DisplayName,Description,IsCustomOptionSet,IsManaged,IsGlobal,OptionSetType" }; // Add top parameter if specified if (params.top) { queryParams.$top = params.top; } const result = await client.getMetadata<ODataResponse<OptionSetMetadata>>( "GlobalOptionSetDefinitions", queryParams ); const optionSetList = result.value.map(optionSet => ({ name: optionSet.Name, displayName: optionSet.DisplayName?.UserLocalizedLabel?.Label || optionSet.Name, description: optionSet.Description?.UserLocalizedLabel?.Label || "", isCustom: optionSet.IsCustomOptionSet, isManaged: optionSet.IsManaged, isGlobal: optionSet.IsGlobal, optionSetType: optionSet.OptionSetType, optionCount: optionSet.Options?.length || 0 })); return { content: [ { type: "text", text: `Found ${optionSetList.length} option sets:\n\n${JSON.stringify(optionSetList, null, 2)}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error listing option sets: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
  • Tool schema definition including title, description, and Zod-validated input schema for optional parameters to filter and limit option set listing.
    title: "List Dataverse Option Sets", description: "Retrieves a list of option sets in the Dataverse environment with filtering options. Use this to discover available choice lists, find custom option sets, or get an overview of reusable options. Supports filtering by custom/system and managed/unmanaged status.", inputSchema: { customOnly: z.boolean().default(false).describe("Whether to list only custom option sets"), includeManaged: z.boolean().default(false).describe("Whether to include managed option sets"), top: z.number().optional().describe("Maximum number of option sets to return (default: 50)"), filter: z.string().optional().describe("OData filter expression") } },
  • The exported registration function that defines and registers the 'list_dataverse_optionsets' tool on the MCP server using the provided schema and handler.
    export function listOptionSetsTool(server: McpServer, client: DataverseClient) { server.registerTool( "list_dataverse_optionsets", { title: "List Dataverse Option Sets", description: "Retrieves a list of option sets in the Dataverse environment with filtering options. Use this to discover available choice lists, find custom option sets, or get an overview of reusable options. Supports filtering by custom/system and managed/unmanaged status.", inputSchema: { customOnly: z.boolean().default(false).describe("Whether to list only custom option sets"), includeManaged: z.boolean().default(false).describe("Whether to include managed option sets"), top: z.number().optional().describe("Maximum number of option sets to return (default: 50)"), filter: z.string().optional().describe("OData filter expression") } }, async (params) => { try { // Note: $filter is not supported on GlobalOptionSetDefinitions let queryParams: Record<string, any> = { $select: "Name,DisplayName,Description,IsCustomOptionSet,IsManaged,IsGlobal,OptionSetType" }; // Add top parameter if specified if (params.top) { queryParams.$top = params.top; } const result = await client.getMetadata<ODataResponse<OptionSetMetadata>>( "GlobalOptionSetDefinitions", queryParams ); const optionSetList = result.value.map(optionSet => ({ name: optionSet.Name, displayName: optionSet.DisplayName?.UserLocalizedLabel?.Label || optionSet.Name, description: optionSet.Description?.UserLocalizedLabel?.Label || "", isCustom: optionSet.IsCustomOptionSet, isManaged: optionSet.IsManaged, isGlobal: optionSet.IsGlobal, optionSetType: optionSet.OptionSetType, optionCount: optionSet.Options?.length || 0 })); return { content: [ { type: "text", text: `Found ${optionSetList.length} option sets:\n\n${JSON.stringify(optionSetList, null, 2)}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error listing option sets: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } ); }
  • src/index.ts:163-163 (registration)
    Top-level invocation of the listOptionSetsTool registration function during server initialization, passing the MCP server and Dataverse client instances.
    listOptionSetsTool(server, dataverseClient);

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mwhesse/mcp-dataverse'

If you have feedback or need assistance with the MCP directory API, please join our Discord server