Files
semantic-kernel/python/semantic_kernel
SergeyMenshykhandCopilot efa3268a09 Python: Enforce excluded_functions on MCP tool invocation path (#14124)
### Motivation and Context

The MCP server created by `create_mcp_server_from_kernel` (and the
`Kernel.as_mcp_server` wrapper) accepts an `excluded_functions` argument
to keep selected kernel functions off the server. Previously this list
was applied only when building the tool set advertised by the
`list_tools` handler; the `call_tool` handler did not consult it and
forwarded the client-supplied name straight to the kernel. As a result
the set of advertised tools and the set of callable tools could diverge.

### Description

- Derive a single `exposed_names` set from `functions_to_expose` and
check it in the `call_tool` handler, returning a `METHOD_NOT_FOUND`
error for any name that is not exposed.
- Remove a leftover `print` debug statement in `_call_kernel_function`.
- Add a unit test covering the `call_tool` behavior for a non-exposed
function.

### Contribution Checklist

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the SK Contribution Guidelines
- [x] All unit tests pass, and I have added new tests where possible

---------

Co-authored-by: Copilot <[email protected]>
2026-06-30 14:51:30 +00:00
..
2024-10-10 22:33:42 +00:00
2024-03-28 15:10:28 +00:00