Skip to content

fix: accept explicit null in get_current_config; keep screenshot logs off stdout - #33

Merged
mijun (houlianpi) merged 1 commit into
microsoft:mainfrom
vishalhabib99:fix/mcp-null-default-and-stdout
Oct 28, 2026
Merged

mijun (houlianpi) merged 1 commit into
microsoft:mainfrom
vishalhabib99:fix/mcp-null-default-and-stdout

Conversation

@vishalhabib99

Copy link
Copy Markdown
Contributor

Two small MCP protocol fixes, in the same spirit as #9 (Optional[list] for app_launch arguments).

1. get_current_config(platform) rejects an explicit null (appium-mcp-server)

platform: str = None makes FastMCP advertise {"type": "string", "default": null}. Clients that send the advertised default explicitly get a validation error, and the tool never runs. Reproduced with the same signature on mcp 1.25 (inside the mcp>=1.23.0,<2 pin):

before isError=True  -> 1 validation error ... platform  Input should be a valid string [type=string_type, input_value=None]
after  isError=False -> ran      # with Optional[str] = None

Fix: platform: Optional[str] = None. Behaviour for omitted or real values is unchanged.

2. app_screenshot prints to stdout (pywinauto-mcp-server)

With --transport stdio, stdout is the JSON-RPC stream, and the spec says a server must not write non-MCP output there. A client reading it gets Invalid JSON: expected value at line 1 column 1 for each line. The success message now goes through logger.info. The error path already calls logger.error with the same message, so I removed the duplicate print. Both loggers use the default StreamHandler(), which writes to stderr.

Checked

  • python -m py_compile passes on both files.
  • A static scan (mcp-doctor) flags these 2 issues before the change and 0 after.
  • I didn't run the servers end to end, since pywinauto needs Windows and appium needs a device.

…nshot logs off stdout

- get_current_config(platform: str = None) advertised default null on a
  string-typed field, so an explicit null failed validation. Type it
  Optional[str], like #9 did for app_launch arguments.
- app_screenshot printed to stdout, which is the JSON-RPC stream when the
  pywinauto server runs with --transport stdio. Log instead; the error path
  already logs via logger.error.
@vishalhabib99

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@houlianpi mijun (houlianpi) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed locally: explicit null is accepted by the Optional annotation, screenshot logging no longer writes to stdout, and the focused behavioral smoke test passed.

@houlianpi
mijun (houlianpi) merged commit 71730a4 into microsoft:main Oct 28, 2026
1 check passed
@vishalhabib99

Copy link
Copy Markdown
Contributor Author

Thanks mijun (@houlianpi) for reviewing it locally and merging, and for running the smoke test on the stdout change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants