Skip to content

Improve stdio test Windows compatibility and refactor command logic #284

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 4 commits into
base: main
Choose a base branch
from

Conversation

HoberMin
Copy link

@HoberMin HoberMin commented Apr 8, 2025

Description

This PR improves the Windows compatibility of stdio tests and refactors the OS-specific command logic. The main changes include:

  • Move OS-specific command logic from test file to implementation
  • Add getDefaultServerParameters function for cross-platform support
  • Use more command for Windows instead of tee
  • Clean up test code structure

Motivation and Context

The stdio tests were not properly handling Windows environments, and the OS-specific logic was mixed in the test file. This PR improves code organization and cross-platform compatibility.

Type 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 not work as expected)

How Has This Been Tested?

  • Tested on Windows environment
  • All existing tests pass
  • Verified stdio functionality works correctly on both Windows and Unix/Linux

Checklist:

  • My code follows the code style of this project
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

@HoberMin HoberMin changed the title feat: Improve stdio test Windows compatibility and refactor command logic Improve stdio test Windows compatibility and refactor command logic Apr 8, 2025
Pizzaface pushed a commit to RewstApp/mcp-inspector that referenced this pull request May 2, 2025
…lt-tool-json

fix: When tool type cannot be determined, use DynamicJsonForm
@ihrpr ihrpr added this to the win milestone Jun 25, 2025
Copy link
Contributor

@felixweinberger felixweinberger left a comment

Choose a reason for hiding this comment

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

Hi @HoberMin thank you for putting up this PR!

The core change looks good to me and after trying it out on Windows, I can confirm it fixes stdio tests there, which is great:

Without #284 With #284
CleanShot 2025-06-27 at 16 54 46@2x CleanShot 2025-06-27 at 16 55 17@2x

2 Small asks before we can merge:

  • Could we please move getDefaultServerParameters into the test file directly? It's unused outside of tests, so we shouldn't expose it.
  • There seem to be some unrelated changes to inMemory and associated tests; could you confirm that these are indeed unrelated and submit a separate PR for these changes, explaining the rationale in the description? Happy to re-review when that is ready.

Comment on lines +42 to +50
// Configure default server parameters based on OS
// Uses 'more' command for Windows and 'tee' command for Unix/Linux
export const getDefaultServerParameters = (): StdioServerParameters => {
if (process.platform === "win32") {
return { command: "more" };
}
return { command: "/usr/bin/tee" };
};

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this to src/client/stdio.test.ts? It doesn't seem to be used outside of tests anywhere.

Comment on lines +46 to +48
const error = new Error("Not connected");
this.onerror?.(error);
throw error;
Copy link
Contributor

@felixweinberger felixweinberger Jun 27, 2025

Choose a reason for hiding this comment

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

Ditto regarding the inMemory test change - this seems unrelated so should ideally be in a different PR.

@@ -69,10 +69,43 @@ describe("InMemoryTransport", () => {
});

test("should throw error when sending after close", async () => {
await clientTransport.close();
const [client, server] = InMemoryTransport.createLinkedPair();
Copy link
Contributor

Choose a reason for hiding this comment

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

The changes in this file seem unrelated to anything in the PR description - were these accidentally included? If not, could you provide some color why they are needed and relevant to the windows compatibility change?

Could we make this a separate PR to isolate the windows change from this unrelated one? Happy to re-review when that is ready.

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.

3 participants