Skip to main content
Glama
mafzaal

Dynamics 365 Finance & Operations MCP Server

by mafzaal

d365fo_execute_sql_query

Run SELECT queries against D365FO metadata to analyze data entities, environments, and versions for reporting and insights.

Instructions

Execute a SELECT query against the D365FO metadata database to get insights from cached metadata.

IMPORTANT SAFETY NOTES:

  • Only SELECT queries are allowed (no INSERT, UPDATE, DELETE, DROP, etc.)

  • Query results are limited to 1000 rows maximum

  • Queries timeout after 30 seconds

  • Some sensitive tables may be restricted

AVAILABLE TABLES AND THEIR PURPOSE:

  • metadata_environments: D365FO environments and their details

  • global_versions: Global version registry with hash and reference counts

  • environment_versions: Links between environments and global versions

  • data_entities: D365FO data entities metadata

  • public_entities: Public entity schemas and configurations

  • entity_properties: Detailed property information for entities

  • entity_actions: Available OData actions for entities

  • enumerations: System enumerations and their metadata

  • enumeration_members: Individual enumeration values and labels

  • metadata_search_v2: FTS5 search index for metadata

EXAMPLE QUERIES:

  1. Get most used entities by category: SELECT entity_category, COUNT(*) as count FROM data_entities GROUP BY entity_category ORDER BY count DESC

  2. Find entities with most properties: SELECT pe.name, COUNT(ep.id) as property_count FROM public_entities pe LEFT JOIN entity_properties ep ON pe.id = ep.entity_id GROUP BY pe.id ORDER BY property_count DESC LIMIT 10

  3. Analyze environment versions: SELECT me.environment_name, gv.version_hash, ev.detected_at FROM metadata_environments me JOIN environment_versions ev ON me.id = ev.environment_id JOIN global_versions gv ON ev.global_version_id = gv.id

Use this tool to analyze metadata patterns, generate reports, and gain insights into D365FO structure.

Args: query: SQL SELECT query to execute. Must be a SELECT statement only. Query will be validated for safety before execution. limit: Maximum number of rows to return. Default is 100, maximum is 1000. format: Output format for results. 'table' for human-readable format, 'json' for structured data, 'csv' for spreadsheet-compatible format. profile: Configuration profile to use (optional - uses default profile if not specified)

Returns: Dictionary with query results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
queryYes
formatNotable
profileNodefault
Behavior5/5

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

With no annotations provided, the description fully discloses behavioral traits: only SELECT allowed, 1000 row limit, 30-second timeout, restricted tables, and a list of available tables. This is comprehensive and leaves no ambiguity about safety or constraints.

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

Conciseness4/5

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

The description is well-structured with clear sections (safety, tables, examples, args). It is relatively long but front-loaded with key information. Minor redundancy (safety notes repeated in args) but overall efficient.

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

Completeness5/5

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

Given the lack of output schema and 4 parameters, the description is very complete. It covers safety, table catalog, examples, parameter details, and return type. An agent can confidently use this tool without further information.

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

Parameters5/5

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

The input schema has 0% description coverage, so the description carries full burden. It explains each parameter: query must be SELECT, limit default 100 and max 1000, format options (table/json/csv), and profile is optional. This adds essential meaning beyond the schema.

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 tool executes SELECT queries against the D365FO metadata database. It specifies the action (execute), resource (metadata database), and purpose (insights from cached metadata), distinguishing it from sibling tools that perform specific operations like record management or profile handling.

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 explicitly restricts queries to SELECT only, outlines table usage, and provides examples. It does not explicitly mention when not to use or suggest alternatives, but the context is clear enough for an agent to decide.

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/mafzaal/d365fo-client'

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