Skip to content

Conversation

@souvikghosh04
Copy link
Contributor

@souvikghosh04 souvikghosh04 commented Oct 9, 2025

Why make this change?

Closes on

Added fixes and refactored the describe_entities tool to support entity metadata discovery for AI agents and LLM clients before performing CRUD operations.

What is this change?

  • Expose entity descriptions with proper null handling
  • Expose field description for entities of type stored-procedure with parameter metadata
  • Expose permissions for all entities with distinct values
  • Added nameOnly parameter to return lightweight response (entity names and descriptions only)
  • Added entities parameter to filter results by specific entity names
  • Implemented proper error handling using McpResponseBuilder pattern
  • Added support for relationships, mappings, and primary key information
  • Improved response structure with metadata section including mode and count

How was this tested?

Functional testing using Insomnia client by running DAB in localhost and local SQL DB database

Expected (In-progress) format of entity description in response-

{
  "entities": [
    {
      "name": "entity-name",
      "description": "entity description",
      "type": "Table",
      "fields": [
        {
          "name": "field-name",
          "type": "unknown",
          "description": "field description"
        }
      ],
      "permissions": [
        "CREATE",
        "READ",
        "UPDATE",
        "DELETE"
      ],
      "primaryKey": ["id"],
      "relationships": [...],
      "mappings": {...}
    }
  ],
  "count": 1,
  "mode": "full"
}

Sample Request(s)

POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities"
  },
  "id": 1
}
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities",
    "arguments": {
      "nameOnly": true
    }
  },
  "id": 2
}
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities",
    "arguments": {
      "entities": ["Book", "Publisher"]
    }
  },
  "id": 1
}

@souvikghosh04 souvikghosh04 changed the title [MCP] describe_entities tool [MCP] Refactoring and additional fixes to describe_entities tool Oct 9, 2025
@souvikghosh04 souvikghosh04 changed the title [MCP] Refactoring and additional fixes to describe_entities tool [MCP] describe_entities tool fixes and refactoring Oct 9, 2025
@souvikghosh04 souvikghosh04 marked this pull request as ready for review October 9, 2025 11:15
Copilot AI review requested due to automatic review settings October 9, 2025 11:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR renames the describe-entities tool to describe_entities and enhances its functionality to provide comprehensive entity metadata including descriptions, fields for stored procedures, and permissions.

  • Renamed tool from describe-entities to describe_entities across configuration and implementation
  • Enhanced entity response to include descriptions, fields for stored procedures, and permissions
  • Added proper documentation and error handling to the tool implementation

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Config/ObjectModel/DmlToolsConfig.cs Updated comments to reflect the new tool name
src/Config/Converters/DmlToolsConfigConverter.cs Updated JSON property name and validation logic
src/Cli/ConfigGenerator.cs Updated logging message to use new tool name
src/Cli/Commands/ConfigureOptions.cs Updated CLI option name for the tool
src/Azure.DataApiBuilder.Mcp/BuiltInTools/DescribeEntitiesTool.cs Major refactoring with enhanced functionality and documentation
schemas/dab.draft.schema.json Updated JSON schema property name and description

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@souvikghosh04 souvikghosh04 self-assigned this Oct 9, 2025
@souvikghosh04 souvikghosh04 added this to the Oct 2025 milestone Oct 9, 2025
@souvikghosh04 souvikghosh04 added mssql an issue thats specific to mssql mcp-server labels Oct 9, 2025
@souvikghosh04 souvikghosh04 moved this from Todo to In Progress in Data API builder Oct 9, 2025
@souvikghosh04 souvikghosh04 moved this from In Progress to Review In Progress in Data API builder Oct 9, 2025
@souvikghosh04 souvikghosh04 linked an issue Oct 9, 2025 that may be closed by this pull request
11 tasks
@souvikghosh04 souvikghosh04 changed the title [MCP] describe_entities tool fixes and refactoring [MCP] describe-entities tool fixes and refactoring Oct 9, 2025
Copy link
Contributor

@anushakolan anushakolan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I will test this with Claude to see if there are any other errors.

@souvikghosh04 souvikghosh04 changed the title [MCP] describe-entities tool fixes and refactoring [MCP] describe_entities tool fixes and refactoring Oct 13, 2025
@souvikghosh04
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@RubenCerna2079
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@RubenCerna2079 RubenCerna2079 enabled auto-merge (squash) October 24, 2025 22:25
@RubenCerna2079
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

Copy link
Contributor

@RubenCerna2079 RubenCerna2079 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@RubenCerna2079 RubenCerna2079 dismissed Aniruddh25’s stale review October 24, 2025 23:52

The changes have been made

@RubenCerna2079 RubenCerna2079 merged commit 5ba8682 into main Oct 25, 2025
11 checks passed
@RubenCerna2079 RubenCerna2079 deleted the Usr/sogh/describe-entities branch October 25, 2025 00:34
@github-project-automation github-project-automation bot moved this from Review In Progress to Done in Data API builder Oct 25, 2025
{
["entities"] = finalEntityList,
["count"] = finalEntityList.Count,
["mode"] = nameOnly ? "basic" : "full"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mode in the response was not expected as per the spec. Why do we need to add it? Without looking at code, I didnt realize basic meant nameOnly. We should remove this from the response unless we confirm value from adding this.

["mode"] = nameOnly ? "basic" : "full"
};

if (entityFilter != null && entityFilter.Count > 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the entityFilter needed in the response? The spec doesnt ask for it

logger?.LogInformation(
"DescribeEntitiesTool returned {EntityCount} entities in {Mode} mode.",
finalEntityList.Count,
nameOnly ? "basic" : "full");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the terms basic and full defined anywhere in the spec? We should log nameOnly or not instead of these terms because they are not self explanatory.

{
Content = [new TextContentBlock { Type = "text", Text = $"Error: {ex.Message}" }]
});
foreach (EntityAction action in permission.Actions)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should limit the actions that are added to the permissions HashSet to be only those actions of the role in which this request was made.

{
result.Add(new
{
name = field.Name,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be sending back the alias not the name. Onlyu if alias is absent, should it send back the name.

{
name = param.Name,
required = param.Default == null, // required if no default
@default = param.Default,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the expected response key @default? why not simply default?

anushakolan pushed a commit that referenced this pull request Nov 8, 2025
… describe-entities MCP tool (#2956)

## Why make this change?

- Addresses follow ups to PR #2900
The `describe_entities` tool response format needed improvements to
better align with MCP specifications and provide more accurate,
user-scoped information. Key issues included non-specification compliant
response fields, overly broad permission reporting across all roles, and
inconsistent entity/field naming conventions that didn't prioritize
user-friendly aliases.


## What is this change?

- **Removed non-spec fields from response**: Eliminated `mode` and
`filter` fields that were not part of the MCP specification
- **Scoped permissions to current user's role**: Modified permissions
logic to only return permissions available to the requesting user's role
instead of all permissions across all roles
- **Implemented entity alias support**: Updated entity name resolution
to prefer GraphQL singular names (aliases) over configuration names,
falling back to entity name only when alias is absent
- **Fixed parameter metadata format**: Changed parameter default value
key from `@default` to `default` in JSON response
- **Enhanced field name resolution**: Updated field metadata to use
field aliases when available, falling back to field names when aliases
are absent
- **Added proper authorization context**: Integrated HTTP context and
authorization resolver to determine current user's role for permission
filtering

## How was this tested?

- [x] Manual Tests

## Sample Request(s)

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities"
  },
  "id": 1
}
```

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities",
    "arguments": {
      "nameOnly": true
    }
  },
  "id": 2
}
```

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities",
    "arguments": {
      "entities": ["Book", "Publisher"]
    }
  },
  "id": 1
}
```
souvikghosh04 added a commit that referenced this pull request Nov 10, 2025
… describe-entities MCP tool (#2956)

## Why make this change?

- Addresses follow ups to PR #2900
The `describe_entities` tool response format needed improvements to
better align with MCP specifications and provide more accurate,
user-scoped information. Key issues included non-specification compliant
response fields, overly broad permission reporting across all roles, and
inconsistent entity/field naming conventions that didn't prioritize
user-friendly aliases.


## What is this change?

- **Removed non-spec fields from response**: Eliminated `mode` and
`filter` fields that were not part of the MCP specification
- **Scoped permissions to current user's role**: Modified permissions
logic to only return permissions available to the requesting user's role
instead of all permissions across all roles
- **Implemented entity alias support**: Updated entity name resolution
to prefer GraphQL singular names (aliases) over configuration names,
falling back to entity name only when alias is absent
- **Fixed parameter metadata format**: Changed parameter default value
key from `@default` to `default` in JSON response
- **Enhanced field name resolution**: Updated field metadata to use
field aliases when available, falling back to field names when aliases
are absent
- **Added proper authorization context**: Integrated HTTP context and
authorization resolver to determine current user's role for permission
filtering

## How was this tested?

- [x] Manual Tests

## Sample Request(s)

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities"
  },
  "id": 1
}
```

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities",
    "arguments": {
      "nameOnly": true
    }
  },
  "id": 2
}
```

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities",
    "arguments": {
      "entities": ["Book", "Publisher"]
    }
  },
  "id": 1
}
```
souvikghosh04 added a commit that referenced this pull request Nov 10, 2025
… describe-entities MCP tool (#2956)

## Why make this change?

- Addresses follow ups to PR #2900
The `describe_entities` tool response format needed improvements to
better align with MCP specifications and provide more accurate,
user-scoped information. Key issues included non-specification compliant
response fields, overly broad permission reporting across all roles, and
inconsistent entity/field naming conventions that didn't prioritize
user-friendly aliases.


## What is this change?

- **Removed non-spec fields from response**: Eliminated `mode` and
`filter` fields that were not part of the MCP specification
- **Scoped permissions to current user's role**: Modified permissions
logic to only return permissions available to the requesting user's role
instead of all permissions across all roles
- **Implemented entity alias support**: Updated entity name resolution
to prefer GraphQL singular names (aliases) over configuration names,
falling back to entity name only when alias is absent
- **Fixed parameter metadata format**: Changed parameter default value
key from `@default` to `default` in JSON response
- **Enhanced field name resolution**: Updated field metadata to use
field aliases when available, falling back to field names when aliases
are absent
- **Added proper authorization context**: Integrated HTTP context and
authorization resolver to determine current user's role for permission
filtering

## How was this tested?

- [x] Manual Tests

## Sample Request(s)

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities"
  },
  "id": 1
}
```

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities",
    "arguments": {
      "nameOnly": true
    }
  },
  "id": 2
}
```

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities",
    "arguments": {
      "entities": ["Book", "Publisher"]
    }
  },
  "id": 1
}
```
anushakolan pushed a commit that referenced this pull request Nov 21, 2025
… describe-entities MCP tool (#2956)

## Why make this change?

- Addresses follow ups to PR #2900
The `describe_entities` tool response format needed improvements to
better align with MCP specifications and provide more accurate,
user-scoped information. Key issues included non-specification compliant
response fields, overly broad permission reporting across all roles, and
inconsistent entity/field naming conventions that didn't prioritize
user-friendly aliases.


## What is this change?

- **Removed non-spec fields from response**: Eliminated `mode` and
`filter` fields that were not part of the MCP specification
- **Scoped permissions to current user's role**: Modified permissions
logic to only return permissions available to the requesting user's role
instead of all permissions across all roles
- **Implemented entity alias support**: Updated entity name resolution
to prefer GraphQL singular names (aliases) over configuration names,
falling back to entity name only when alias is absent
- **Fixed parameter metadata format**: Changed parameter default value
key from `@default` to `default` in JSON response
- **Enhanced field name resolution**: Updated field metadata to use
field aliases when available, falling back to field names when aliases
are absent
- **Added proper authorization context**: Integrated HTTP context and
authorization resolver to determine current user's role for permission
filtering

## How was this tested?

- [x] Manual Tests

## Sample Request(s)

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities"
  },
  "id": 1
}
```

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities",
    "arguments": {
      "nameOnly": true
    }
  },
  "id": 2
}
```

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities",
    "arguments": {
      "entities": ["Book", "Publisher"]
    }
  },
  "id": 1
}
```
anushakolan pushed a commit that referenced this pull request Dec 19, 2025
… describe-entities MCP tool (#2956)

## Why make this change?

- Addresses follow ups to PR #2900
The `describe_entities` tool response format needed improvements to
better align with MCP specifications and provide more accurate,
user-scoped information. Key issues included non-specification compliant
response fields, overly broad permission reporting across all roles, and
inconsistent entity/field naming conventions that didn't prioritize
user-friendly aliases.


## What is this change?

- **Removed non-spec fields from response**: Eliminated `mode` and
`filter` fields that were not part of the MCP specification
- **Scoped permissions to current user's role**: Modified permissions
logic to only return permissions available to the requesting user's role
instead of all permissions across all roles
- **Implemented entity alias support**: Updated entity name resolution
to prefer GraphQL singular names (aliases) over configuration names,
falling back to entity name only when alias is absent
- **Fixed parameter metadata format**: Changed parameter default value
key from `@default` to `default` in JSON response
- **Enhanced field name resolution**: Updated field metadata to use
field aliases when available, falling back to field names when aliases
are absent
- **Added proper authorization context**: Integrated HTTP context and
authorization resolver to determine current user's role for permission
filtering

## How was this tested?

- [x] Manual Tests

## Sample Request(s)

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities"
  },
  "id": 1
}
```

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities",
    "arguments": {
      "nameOnly": true
    }
  },
  "id": 2
}
```

```
POST http://localhost:5000/mcp

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "describe_entities",
    "arguments": {
      "entities": ["Book", "Publisher"]
    }
  },
  "id": 1
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mcp-server mssql an issue thats specific to mssql

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Enh]: Add DML tool: describe_entities

5 participants