Skip to content

Modify the wpf to connect to the mcp server using the stdio method #694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

xbo729
Copy link

@xbo729 xbo729 commented Aug 11, 2025

Hi maintainers 👋,

I've opened this PR to fix an issue where attempting to set Console.InputEncoding and Console.OutputEncoding in non-console applications (like WPF) throws a NotSupportedException, which causes the connection to the MCP server via stdio to fail.

This change adds a check to detect whether the current environment supports console I/O before applying encoding settings, preventing the exception in GUI applications such as WPF.

✅ The fix has been tested locally in a real WPF application and resolves the connection issue.
✅ No breaking changes are introduced.

Could someone please review this when you have time? It would help enable smoother integration of the SDK in WPF and other desktop applications.

Thanks for your work on the project! 🙏

Modify the wpf to connect to the mcp server using the stdio method

Motivation and Context

WPF uses STDIO to connect to MCP server and throws an exception

How Has This Been Tested?

yes,i have tested in my wpf project

Breaking Changes

no

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

xiangb-a added 2 commits August 11, 2025 20:50
… we are not using a console program, setting the input and output language of Console will have no effect and will throw an exception. For example, when using WPF, an exception will be thrown here, causing the connection to fail
…ding format for the console program if it is a console program
@xbo729
Copy link
Author

xbo729 commented Aug 14, 2025

Hi @timheuer @johnw188 @koic @halter73 , could you please take a look at this PR when you have time? It fixes an issue with WPF applications.

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.

1 participant