Skip to content

Conversation

@souvikghosh04
Copy link
Contributor

@souvikghosh04 souvikghosh04 commented Nov 6, 2025

Why make this change?

  • Addresses follow ups to PR [MCP] describe_entities tool fixes and refactoring #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?

  • 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
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@souvikghosh04 souvikghosh04 self-assigned this Nov 6, 2025
@souvikghosh04 souvikghosh04 added mssql an issue thats specific to mssql mcp-server labels Nov 6, 2025
@souvikghosh04 souvikghosh04 added this to the Nov 2025 milestone Nov 6, 2025
@souvikghosh04 souvikghosh04 moved this from Todo to In Progress in Data API builder Nov 6, 2025
@souvikghosh04 souvikghosh04 linked an issue Nov 6, 2025 that may be closed by this pull request
1 task
@souvikghosh04 souvikghosh04 added the bug Something isn't working label Nov 6, 2025
@souvikghosh04 souvikghosh04 marked this pull request as ready for review November 6, 2025 11:02
Copilot AI review requested due to automatic review settings November 6, 2025 11:02
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 pull request adds role-based permission filtering to the DescribeEntitiesTool, ensuring that entity metadata only includes permissions relevant to the current user's role rather than all configured permissions.

  • Extracts the current user's role from the HTTP request headers
  • Filters entity permissions to show only those available to the current user's role
  • Updates entity and field names to use GraphQL aliases when available
  • Refactors parameter metadata to use dictionaries instead of anonymous objects
Comments suppressed due to low confidence (1)

src/Azure.DataApiBuilder.Mcp/BuiltInTools/DescribeEntitiesTool.cs:87

  • This assignment to authResolver is useless, since its value is never read.
                IAuthorizationResolver authResolver = serviceProvider.GetRequiredService<IAuthorizationResolver>();

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@souvikghosh04
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@souvikghosh04 souvikghosh04 moved this from In Progress to Review In Progress in Data API builder Nov 6, 2025
Copy link
Collaborator

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

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

LGTM as long as you have verified anonymous role value is set on the X_MS_API_ROLE header

@souvikghosh04 souvikghosh04 changed the title Follow-up changes and fixes to describe-entities tool Honoring incoming request role in determining allowed permissions for describe-entities MCP tool Nov 7, 2025
@souvikghosh04
Copy link
Contributor Author

LGTM as long as you have verified anonymous role value is set on the X_MS_API_ROLE header

confirming the same here after validating.
image

@souvikghosh04
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@souvikghosh04 souvikghosh04 enabled auto-merge (squash) November 7, 2025 06:55
@anushakolan anushakolan disabled auto-merge November 7, 2025 19:30
@anushakolan anushakolan enabled auto-merge (squash) November 7, 2025 19:30
@Aniruddh25
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@anushakolan anushakolan merged commit 7b31e9a into main Nov 8, 2025
11 checks passed
@anushakolan anushakolan deleted the Usr/sogh/describeentitypermroles branch November 8, 2025 01:05
@github-project-automation github-project-automation bot moved this from Review In Progress to Done in Data API builder Nov 8, 2025
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
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mcp-server mssql an issue thats specific to mssql

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: MCP describe-entities does not honor the incoming request role

4 participants