Azure / Azure/azure-functions-agents-runtime

Handle MCP prompt-list change notifications safely

Open
#50 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
9
Forks
7
Avg merge
1d 21h
Merged PRs (30d)
20

Description

## Problem

PR #48 hardcodes MCP discovery to load tools and skip prompts:

```python
load_tools=True
load_prompts=False
```

This avoids the connect-time `prompts/list` call for connector-backed MCP servers that support tools but reject prompt discovery with HTTP 400.

However, a review pointed out that Agent Framework's MCP notification dispatcher may still call `self.load_prompts()` unconditionally when an MCP server emits `notifications/prompts/list_changed`. If that happens, a server that rejects `prompts/list` can still surface a `ToolExecutionException` from the notification handler, even though prompt loading was disabled at construction time.

## Context

Review comment from PR #48:

> `load_prompts=False` only suppresses the connect-time call. In MAF's mcp.py the server-notification dispatcher calls `self.load_prompts()` unconditionally. So any MCP server that emits `prompts/list_changed` will surface a `ToolExecutionException` from the runtime's notification handler.

This feels separate from PR #48's immediate goal, which was to remove the public `load_tools` / `load_prompts` config knobs and use fixed runtime behavior.

## Desired outcome

Figure out how the runtime should handle MCP prompt-list change notifications from servers where prompt loading is disabled or unsupported.

Possible approaches to evaluate:

- Report/fix upstream in Microsoft Agent Framework so `notifications/prompts/list_changed` respects `load_prompts_flag` before calling `load_prompts()`.
- Wrap or subclass the MCP tool in this runtime to ignore prompt-list changed notifications when prompt loading is disabled.
- Add a custom message handler that delegates to the MAF default handler for tool notifications but ignores prompt notifications.
- Keep the runtime as-is if the failure is only logged by MAF and does not affect tool use, but verify this with a reproduction.

## Acceptance criteria

- Reproduce or otherwise verify the behavior when a server emits `notifications/prompts/list_changed` while prompt loading is disabled.
- Decide whether the fix belongs in this runtime, upstream MAF, or both.
- If fixed in this runtime, ensure connector-backed MCP tools continue working when prompt-list notifications are emitted.
- Add tests that cover prompt-list notifications with prompt loading disabled.
- Document any remaining limitation or upstream dependency.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the behavior described in the Microsoft Agent Framework MCP notification dispatcher when a server emits notifications/prompts/list_changed with prompt loading disabled. Compare the runtime and upstream handling, then add coverage for the chosen fix or verified limitation; done means connector-backed tools remain usable and any upstream dependency is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.