-
Notifications
You must be signed in to change notification settings - Fork 644
feat - incorporated mcp server request configs for cli mode #373
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
base: main
Are you sure you want to change the base?
feat - incorporated mcp server request configs for cli mode #373
Conversation
synced the PR @olaservo @cliffhall @pulkitsharma07 |
Hi @Kavyapriya-1804 I think one way we can run tests on these changes is to add a script similar to this one: If you look at the package.json for the cli folder, the I created an example here. The only issue I had with this example is that I can't get the I was running the above example script by adding it to the package.json in the cli folder, eg |
ec4fb9d
to
b1110c4
Compare
Hi @olaservo, I was able to run them successfully. But wasn't able to get 2/ 9 test cases right ( Kindly suggest further.. |
@Kavyapriya-1804 Maybe this suggests we need to add those features to the CLI? What would that look like? |
Hi @cliffhall , @olaservo, @pulkitsharma07 ![]() Implementing this feature could be helpful to receive updates likes Would you like to have them implemented as part of this PR ? |
I think the CLI should handle logs and notifications in some way, but I'm not sure how. Presumably they would be well identifiable and parsable from the STDOUT/STDERR of the CLI, so that tests can verify that they appear there and are correct. Play with what they might look like in the output and make a proposal here for that. Let us see some mockups of an output stream with these notifications mixed in. |
Sure @cliffhall. cc: @olaservo |
Hi @Kavyapriya-1804 , just wanted to mention I think we can leave out the notifications piece and just focus on the supported features + configs for now since it probably made these changes a lot bigger. What do you think? |
Hi @olaservo, yeah sure. Would work on the notifications part in a separate issue.
Please merge if it looks good to you. Thanks ! |
Hi @olaservo @cliffhall |
@Kavyapriya-1804 With the everything server running in SSE mode, the command you included, I get the following: ![]() Could you please give a clear and complete set of instructions for testing against server-everything ? I.e., setup and test cases for stdio, streamableHttp, and sse, with the various settings and whether failure or success is expected? I don't want to have to guess about this. It would be good if you included screenshots of the results of each test on your system, so that we can compare our results to yours in each case. |
@cliffhall here's the original suggestion I made for testing that we were referencing for this PR:
As long as we're OK with waiting on the timeout support for progress notifications, I think we could add a modified version of this ^^ script to the repo and/or modify the existing to include these cases? |
@Kavyapriya-1804 could you look at incorporating the script @olaservo mentioned above into the existing tests? |
Sure, will add @cliffhall |
Hi @cliffhall , ![]() |
Hi @Kavyapriya-1804 , apologies but it looks like the other changes for http support created some conflicts here - let me know if you want me to resolve them, I know this has been pending a while and this probably should have gone first. Thanks! |
Hi @olaservo, |
@Kavyapriya-1804 all the tests are running and I think the changes look good, but one outstanding thing is:
|
Hi @cliffhall, Please let me know if we need something else in this regard. |
Updated this branch with latest from main. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use some documentation of how to set these request configs in the README.md.
Documentation updated @cliffhall 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation tweak and questions about missing tests.
# With request timeout configs (in milliseconds) - max total timeout | ||
npx modelcontextprotocol/inspector --cli node build/index.js --method tools/call --tool-name longRunningOperation --tool-arg duration=15 steps=5 --max-total-timeout 30000 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--max-total-timeout
really only makes sense when combined with --request-timeout
and --reset-timeout-on-progress
# With request timeout configs (in milliseconds) - max total timeout | |
npx modelcontextprotocol/inspector --cli node build/index.js --method tools/call --tool-name longRunningOperation --tool-arg duration=15 steps=5 --max-total-timeout 30000 | |
# With request timeout configs (in milliseconds) - max total timeout (used with request timeout and reset timeout on progress) | |
npx modelcontextprotocol/inspector --cli node build/index.js --method tools/call --tool-name longRunningOperation --tool-arg duration=35 steps=5 --reset-timeout-on-progress true --request-timeout 7000 --max-total-timeout 35000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. This can be done.
// console.log( | ||
// `\n${colors.YELLOW}=== Running Progress-Related Timeout Tests ===${colors.NC}`, | ||
// ); | ||
|
||
// // Test 32: Reset timeout on progress disabled - should fail with timeout | ||
// await runErrorTest( | ||
// "reset_timeout_disabled", | ||
// "should_timeout_quickly", | ||
// TEST_CMD, | ||
// ...TEST_ARGS, | ||
// "--cli", | ||
// "--method", | ||
// "tools/call", | ||
// "--tool-name", | ||
// "longRunningOperation", | ||
// "--tool-arg", | ||
// "duration=15", // Same configuration as above | ||
// "steps=5", | ||
// "--request-timeout", | ||
// "2000", | ||
// "--reset-timeout-on-progress", | ||
// "false", // Only difference is here | ||
// "--max-total-timeout", | ||
// "30000", | ||
// ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the gap on getting this test to work? And will we have a test of --reset-timeout-on-progress true
combined with --max-total-timeout
? The PR description says you're not able to test the failure scenarios, but can you test for success?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not able to get the test implementations right for these 2 params which I have been informing right from the initial days of this PR. It has been 2 months and a lot of code changes, so I am not sure of the current progress for this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really appreciate your hanging in there @Kavyapriya-1804!
It would be good to see a test that shows --request-timeout
and --reset-timeout-on-progress true
combined with --max-total-timeout
actually works. It's the key to managing long running operations.
This PR implements the feature requested by #330
Motivation and Context
When using the Inspector in
CLI mode
, there's currently no way to configure Inspector-specific settings likeMCP_SERVER_REQUEST_TIMEOUT
. This limitation forces users to work with default timeout values, which may not be suitable for all use cases, especially when dealing with slower MCP servers or long-running operations. This PR adds support to accept the mcp server request's configs to be set from CLI in form of flags and values.The below configs have been added
MCP_SERVER_REQUEST_TIMEOUT
MCP_REQUEST_TIMEOUT_RESET_ON_PROGRESS
MCP_REQUEST_MAX_TOTAL_TIMEOUT
Sample usage for a remote everything-server:
mcp-inspector-cli --cli http://localhost:3001/sse --method tools/list --request-timeout 1 --reset-timeout-on-progress true --max-total-timeout 5000
How Has This Been Tested?
MCP_SERVER_REQUEST_TIMEOUT
with listing tools as below. Successfully passes or fails according to the timeout duration given.MCP_REQUEST_MAX_TOTAL_TIMEOUT
with calling a tool (longRunningOperation
) fromeverything-server
as below. But not able to test the failure case for this.MCP_REQUEST_TIMEOUT_RESET_ON_PROGRESS
has been implemented the same way but not able to test the failure scenariosBreaking Changes
This PR does not introduce any breaking changes
Types of changes
Checklist
Additional context
The implementation of passing the 3 server configurations has been done like how its done for the mcp web mode. Checked the implementation of
connect
(classProtocol
) andrequest
(classClient
) methods intypescript-sdk
repo of mcp as well. In both casesRequestOptions
are accepted the same way.Could you please suggest further ways to test
MCP_REQUEST_MAX_TOTAL_TIMEOUT
andMCP_REQUEST_TIMEOUT_RESET_ON_PROGRESS
?