eemario opened a new issue, #1490: URL: https://github.com/apache/flink-agents/issues/1490
### Search before asking - [x] I searched in the [issues](https://github.com/apache/flink-agents/issues) and found nothing similar. ### Description Python `MCPPrompt` silently drops explicitly supplied optional arguments. If a prompt declares `language` with `required=False` or omits `required` (`None`), passing `language="French"` does not forward the value to the server. The call can succeed while the server uses its default language. Both `format_messages()` and `format_string()` are affected. `_check_arguments()` only copies values inside `if argument.required`, conflating required-argument validation with argument forwarding. Expected behavior: forward every explicitly supplied, declared argument, including optional arguments and empty strings; reject missing required arguments; omit optional arguments not supplied. Java `MCPPrompt.validateAndPrepareArguments()` already preserves explicitly supplied optional values. [Python filtering on the verified main commit](https://github.com/apache/flink-agents/blob/c1dc0d782e1736efef6c28989efd2239173a4335/python/flink_agents/integrations/mcp/mcp.py#L112-L145). This is independent of #1481, which separates prompt variables from the message-role parameter but leaves `_check_arguments()` unchanged. #578 / #583 concern Java handling of a missing `required` field, rather than Python dropping optional values. ### How to reproduce This captures the server boundary without a network service or LLM: ```python from unittest.mock import patch from mcp.types import PromptArgument from flink_agents.api.chat_message import ChatMessage, MessageRole from flink_agents.integrations.mcp.mcp import MCPPrompt, MCPServer prompt = MCPPrompt( name="translate", title=None, prompt_arguments=[ PromptArgument(name="text", required=True), PromptArgument(name="language", required=False), ], mcp_server=MCPServer(endpoint="http://localhost:8000/mcp"), ) with patch.object(MCPServer, "get_prompt") as get_prompt: get_prompt.side_effect = lambda name, arguments: [ ChatMessage.of(MessageRole.USER, arguments.get("language", "English")) ] result = prompt.format_string(text="Hello", language="French") print(get_prompt.call_args.args[1]) print(result) ``` Actual: `{'text': 'Hello'}` and `English`. Expected: `{'text': 'Hello', 'language': 'French'}` and `French`. `required=None` produces the same failure; `required=True` preserves `French`. A local uncommitted fix separates presence from requiredness. Fourteen regression cases cover both formatting entry points, `required=False` / `None`, supplied and omitted optional values, empty strings, undeclared arguments, and missing required arguments. Eight cases fail before the fix. With the fix, all 71 MCP tests pass, as do Ruff and formatting checks. The new regression cases mock the server boundary. ### Version and environment - Upstream `main`: `c1dc0d782e1736efef6c28989efd2239173a4335`. - Python 3.11.15, macOS arm64. - Reproduces without a Flink cluster or Java bridge. ### Are you willing to submit a PR? - [x] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
