Files
semantic-kernel/python/semantic_kernel/utils/validation.py
Evan Mattson ac5c37e442 Python: Allow hyphens in function param metadata which are sometimes present with MCP plugins (#12267)
### Motivation and Context

We recently relaxed the regex for `FUNCTION_NAME_REGEX` and
`FULLY_QUALIFIED_FUNCTION_NAME` to allow hyphens, which are sometimes
present while using MCP. However, we did not include a relaxed Regex for
`FUNCTION_PARAM_NAME_REGEX`, which was still causing errors while using
MCP within SK.

This PR relaxes the regex for `FUNCTION_PARAM_NAME_REGEX` so that there
are no errors while using MCP.

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

### Description

Relax the `FUNCTION_PARAM_NAME_REGEX` which won't throw validation
errors while using MCP.
- Fully closes #11758

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
2025-05-26 15:03:19 +00:00

8 lines
311 B
Python

# Copyright (c) Microsoft. All rights reserved.
AGENT_NAME_REGEX = r"^[0-9A-Za-z_-]+$"
PLUGIN_NAME_REGEX = r"^[0-9A-Za-z_]+$"
FUNCTION_NAME_REGEX = r"^[0-9A-Za-z_-]+$"
FULLY_QUALIFIED_FUNCTION_NAME = r"^(?P<plugin>[0-9A-Za-z_]+)[.](?P<function>[0-9A-Za-z_-]+)$"
FUNCTION_PARAM_NAME_REGEX = r"^[0-9A-Za-z_-]+$"