Skip to main content
Glama
mafzaal

Dynamics 365 Finance & Operations MCP Server

by mafzaal

d365fo_execute_sql_query

Execute SELECT queries on Dynamics 365 Finance & Operations metadata database to analyze data entities, environments, and system structure for insights and reporting.

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
queryYes
limitNo
formatNotable
profileNodefault
Behavior5/5

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

Since no annotations are provided, the description carries the full burden of behavioral disclosure. It excels by detailing critical behavioral traits: query restrictions (SELECT only), result limits (1000 rows max), timeout (30 seconds), access restrictions (some sensitive tables may be restricted), and output format options. This goes well beyond what a basic description would provide, giving the agent comprehensive operational context.

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 (purpose, safety notes, available tables, examples, usage guidance, args, returns) and front-loads the core functionality. While comprehensive, some sections like the table list and example queries are quite detailed, making it longer than minimal. However, every sentence adds value, and the structure helps the agent quickly find relevant information.

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 complexity of a SQL execution tool with 4 parameters, no annotations, and no output schema, the description provides exceptional completeness. It covers purpose, safety constraints, available data sources, example usage, parameter semantics, and return format. The agent has everything needed to use this tool correctly without needing to infer behavior from structured fields that don't exist.

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?

With 0% schema description coverage, the description must compensate fully, which it does excellently. It explains all four parameters: 'query' (SQL SELECT statement with validation), 'limit' (default 100, max 1000), 'format' (table/json/csv options), and 'profile' (optional configuration). The description adds crucial semantic details like safety validation, default values, maximum limits, and format purposes that aren't in the bare 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 to get insights from cached metadata. It specifies the exact verb ('execute') and resource ('D365FO metadata database'), and distinguishes itself from siblings like d365fo_get_database_schema or d365fo_query_entities by focusing on raw SQL execution rather than structured queries or schema retrieval.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool: 'to analyze metadata patterns, generate reports, and gain insights into D365FO structure.' It also includes important safety notes that indicate when NOT to use it (e.g., no INSERT/UPDATE/DELETE queries). The example queries further illustrate appropriate use cases, and the sibling tools list shows clear alternatives for non-SQL operations.

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