Skip to main content
Glama
mwhesse

Dataverse MCP Server

by mwhesse

get_dataverse_column

Retrieve detailed information about a specific column in a Dataverse table, including data type, properties, and configuration settings to inspect column definitions and understand field structure.

Instructions

Retrieves detailed information about a specific column in a Dataverse table, including its data type, properties, and configuration settings. Use this to inspect column definitions and understand field structure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entityLogicalNameYesLogical name of the table
logicalNameYesLogical name of the column to retrieve

Implementation Reference

  • Handler function that fetches the column metadata from Dataverse, enhances it for lookup attributes by querying relationships to find the navigation property name, and returns formatted details or error.
    async (params) => { try { // Retrieve the base attribute metadata const attribute = await client.getMetadata<AttributeMetadata>( `EntityDefinitions(LogicalName='${params.entityLogicalName}')/Attributes(LogicalName='${params.logicalName}')` ); // Prepare enhanced payload that can include navigationProperty when applicable const enhanced: any = { ...attribute }; // Determine if this is a Lookup attribute using multiple heuristics for robustness const attrType: any = (attribute as any)?.AttributeType; const odataType: string | undefined = (attribute as any)?.["@odata.type"]; const isLookup = (typeof attrType === "string" && attrType.toLowerCase() === "lookup") || (typeof attrType === "number" && attrType === 6) || // AttributeTypeCode.Lookup (typeof odataType === "string" && odataType.toLowerCase().includes("lookupattributemetadata")); if (isLookup) { try { // Query ManyToOneRelationships for this entity to map ReferencingAttribute -> ReferencingEntityNavigationPropertyName const relationshipsUrl = `EntityDefinitions(LogicalName='${params.entityLogicalName}')/ManyToOneRelationships?$select=ReferencingAttribute,ReferencingEntityNavigationPropertyName`; const relationshipsResponse: any = await client.getMetadata(relationshipsUrl); // Find the relationship entry that matches the current attribute logical name const match = relationshipsResponse?.value?.find( (rel: any) => typeof rel?.ReferencingAttribute === "string" && rel.ReferencingAttribute.toLowerCase() === params.logicalName.toLowerCase() ); if (match?.ReferencingEntityNavigationPropertyName) { enhanced.navigationProperty = match.ReferencingEntityNavigationPropertyName; } } catch (relError) { // Do not fail the tool for relationship lookup issues; just omit navigationProperty } } return { content: [ { type: "text", text: `Column information for '${params.logicalName}' in table '${params.entityLogicalName}':\n\n${JSON.stringify(enhanced, null, 2)}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error retrieving column: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
  • Zod input schema defining the required parameters: entityLogicalName and logicalName.
    inputSchema: { entityLogicalName: z.string().describe("Logical name of the table"), logicalName: z.string().describe("Logical name of the column to retrieve") }
  • Tool registration call within the exported getColumnTool function, specifying the tool name, metadata (title, description, schema), and handler.
    server.registerTool( "get_dataverse_column", { title: "Get Dataverse Column", description: "Retrieves detailed information about a specific column in a Dataverse table, including its data type, properties, and configuration settings. Use this to inspect column definitions and understand field structure.", inputSchema: { entityLogicalName: z.string().describe("Logical name of the table"), logicalName: z.string().describe("Logical name of the column to retrieve") } }, async (params) => { try { // Retrieve the base attribute metadata const attribute = await client.getMetadata<AttributeMetadata>( `EntityDefinitions(LogicalName='${params.entityLogicalName}')/Attributes(LogicalName='${params.logicalName}')` ); // Prepare enhanced payload that can include navigationProperty when applicable const enhanced: any = { ...attribute }; // Determine if this is a Lookup attribute using multiple heuristics for robustness const attrType: any = (attribute as any)?.AttributeType; const odataType: string | undefined = (attribute as any)?.["@odata.type"]; const isLookup = (typeof attrType === "string" && attrType.toLowerCase() === "lookup") || (typeof attrType === "number" && attrType === 6) || // AttributeTypeCode.Lookup (typeof odataType === "string" && odataType.toLowerCase().includes("lookupattributemetadata")); if (isLookup) { try { // Query ManyToOneRelationships for this entity to map ReferencingAttribute -> ReferencingEntityNavigationPropertyName const relationshipsUrl = `EntityDefinitions(LogicalName='${params.entityLogicalName}')/ManyToOneRelationships?$select=ReferencingAttribute,ReferencingEntityNavigationPropertyName`; const relationshipsResponse: any = await client.getMetadata(relationshipsUrl); // Find the relationship entry that matches the current attribute logical name const match = relationshipsResponse?.value?.find( (rel: any) => typeof rel?.ReferencingAttribute === "string" && rel.ReferencingAttribute.toLowerCase() === params.logicalName.toLowerCase() ); if (match?.ReferencingEntityNavigationPropertyName) { enhanced.navigationProperty = match.ReferencingEntityNavigationPropertyName; } } catch (relError) { // Do not fail the tool for relationship lookup issues; just omit navigationProperty } } return { content: [ { type: "text", text: `Column information for '${params.logicalName}' in table '${params.entityLogicalName}':\n\n${JSON.stringify(enhanced, null, 2)}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error retrieving column: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } ); }

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