[PR #170] [MERGED] Fix: Handle MCP parameter names with 2 leading underscores #196

Closed
opened 2026-10-18 21:12:36 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/mcpo/pull/170
Author: @2underscores
Created: 6/4/2025
Status: ✅ Merged
Merged: 6/6/2025
Merged by: @tjbck

Base: dev ← Head: fix-leading-underscore-parameters


📝 Commits (3)

  • 1953ace Fix: Handle parameter names with leading underscores in Pydantic models - Add field aliasing for parameters starting with '__' (e.g., __top, __filter) - Apply fix to both top-level and nested object properties - Use by_alias=True in model_dump to preserve original parameter names for MCP calls - Prevents Pydantic v2 NameError - Enables compatibility with Microsoft 365 MCP server and other OData-based APIs - Fixes #160
  • 93297c9 Abstracted out alias checks and creation
  • 0d93fef rm debug logs

📊 Changes

1 file changed (+53 additions, -4 deletions)

View changed files

📝 src/mcpo/utils/main.py (+53 -4)

📄 Description

Add field aliasing for parameters starting with '__' (e.g., __top, __filter) - Apply fix to both top-level and nested object properties - Use by_alias=True in model_dump to preserve original parameter names for MCP calls - Prevents Pydantic v2 NameError. Enables compatibility with OData-based APIs.

Fixes feat #160 (IMO addressing incompatibility with some MCP interfaces is a bug fix, not a new feature)

Changelog Entry

Description

Fixes Pydantic v2 validation error when MCP servers use parameter names with leading underscores (e.g., __top, __filter) (e.g. any OData-based APIs that follow Microsoft Graph API conventions).

Added

  • Field aliasing for parameters with leading underscores in Pydantic model generation
  • Support for both top-level and nested object properties with leading underscore names

Fixed

  • Pydantic v2 NameError: "Fields must not use names with leading underscores"

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/mcpo/pull/170 **Author:** [@2underscores](https://github.com/2underscores) **Created:** 6/4/2025 **Status:** ✅ Merged **Merged:** 6/6/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `fix-leading-underscore-parameters` --- ### 📝 Commits (3) - [`1953ace`](https://github.com/open-webui/mcpo/commit/1953ace032fc152b0afcbc349f9ae2d953472709) Fix: Handle parameter names with leading underscores in Pydantic models - Add field aliasing for parameters starting with '__' (e.g., __top, __filter) - Apply fix to both top-level and nested object properties - Use by_alias=True in model_dump to preserve original parameter names for MCP calls - Prevents Pydantic v2 NameError - Enables compatibility with Microsoft 365 MCP server and other OData-based APIs - Fixes #160 - [`93297c9`](https://github.com/open-webui/mcpo/commit/93297c9bc0fe292a092acf7f351255c7060cd148) Abstracted out alias checks and creation - [`0d93fef`](https://github.com/open-webui/mcpo/commit/0d93fef2791eb45299af5e2fb5504e0093e6c350) rm debug logs ### 📊 Changes **1 file changed** (+53 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/mcpo/utils/main.py` (+53 -4) </details> ### 📄 Description Add field aliasing for parameters starting with '__' (e.g., __top, __filter) - Apply fix to both top-level and nested object properties - Use by_alias=True in model_dump to preserve original parameter names for MCP calls - Prevents Pydantic v2 NameError. Enables compatibility with OData-based APIs. Fixes feat #160 (IMO addressing incompatibility with some MCP interfaces is a bug fix, not a new feature) # Changelog Entry ### Description Fixes Pydantic v2 validation error when MCP servers use parameter names with leading underscores (e.g., `__top`, `__filter`) (e.g. any OData-based APIs that follow Microsoft Graph API conventions). ### Added - Field aliasing for parameters with leading underscores in Pydantic model generation - Support for both top-level and nested object properties with leading underscore names ### Fixed - Pydantic v2 NameError: "Fields must not use names with leading underscores" --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-18 21:12:36 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/mcpo#196
No description provided.