Skip to main content
Glama
mwhesse

Dataverse MCP Server

by mwhesse

List Dataverse Option Sets

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);
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It mentions 'filtering options' and 'supports filtering by custom/system and managed/unmanaged status,' which adds some behavioral context beyond basic retrieval. However, it lacks details on permissions, rate limits, pagination behavior (implied by 'top' parameter but not explained), or what the output format looks like, leaving gaps for a tool with multiple parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence, followed by usage scenarios and filtering support. Every sentence adds value without redundancy, making it efficiently structured and appropriately sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description provides adequate purpose and usage context but lacks details on behavioral aspects like output format, error handling, or authentication needs. For a list tool with filtering parameters, it's minimally complete but could benefit from more transparency about what the returned data looks like or any limitations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all four parameters. The description adds marginal value by mentioning filtering by 'custom/system and managed/unmanaged status,' which loosely maps to 'customOnly' and 'includeManaged' parameters but doesn't provide additional syntax or usage details beyond what's in the schema. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('retrieves') and resource ('list of option sets in the Dataverse environment'), specifying the exact operation. It distinguishes from siblings like 'get_dataverse_optionset' (singular retrieval) and 'create_dataverse_optionset' (creation) by focusing on listing with filtering capabilities.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('to discover available choice lists, find custom option sets, or get an overview of reusable options'), giving practical scenarios. However, it doesn't explicitly state when not to use it or name specific alternatives among siblings, though the context implies it's for listing rather than detailed retrieval or management.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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