-
Notifications
You must be signed in to change notification settings - Fork 31
feat: Add mcp transport protocol #345
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
Conversation
7e58222 to
78014d7
Compare
I have refactored the code accordingly. Please have a look and let me know what you think! |
packages/toolbox-core/src/toolbox_core/mcp_transport/v20241105/mcp.py
Outdated
Show resolved
Hide resolved
packages/toolbox-core/src/toolbox_core/mcp_transport/v20241105/mcp.py
Outdated
Show resolved
Hide resolved
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.
correct me if i'm wrong but here we're only running e2e with the latest version right?
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.
Correct. I thought running E2E only on the latest version would save us some time, given that the legacy versions are already covered by transport tests. Do you think we should expand E2E to include all versions?
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.
Ideally we might want to cover all versions since we wanna make sure any code addition/update does not break previous versions. But if we're confident that the transport tests coverage covers everything, it might be okay to omit those.
In case we want to add e2e to all versions, we can use python's parametrized tests.
packages/toolbox-core/src/toolbox_core/mcp_transport/v20241105/mcp.py
Outdated
Show resolved
Hide resolved
| self, | ||
| url: str, | ||
| method: str, | ||
| params: dict, |
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.
might wanna use type check here rather than a general dict. (something like this? https://github.com/modelcontextprotocol/python-sdk/blob/c51936f61f35a15f0b1f8fb6887963e5baee1506/src/mcp/shared/session.py#L36) but for ClientRequest that could be either a InitializeRequest or ListToolRequest etc.)
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 have refactored all versions. I have directly tied the Response types to the request types in types.py as in here to ensure that our transport code is more clean. Let me know what you think!
This reverts commit bc6da15.
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.
Ideally we might want to cover all versions since we wanna make sure any code addition/update does not break previous versions. But if we're confident that the transport tests coverage covers everything, it might be okay to omit those.
In case we want to add e2e to all versions, we can use python's parametrized tests.
|
@Yuan325 I have added mcp e2e tests for all versions. |
* feat: Add mcp transport protocol (#345) * add basic code * fixes * test fix * new unit tests * rename ToolboxTransport * add py3.9 support * fix langchain tool tests * test fix * lint * fix tests * move manage session into transport * move warning to diff file * avoid code duplication * fix tests * lint * remove redundant tests * make invoke method return str * lint * fix return type * small refactor * refactor: remove transport logic from client tests * try * version negotiation * small changes * lint * fix endpoint * add some todos * lint * initialise in init * lint * add support for 'Mcp-session-id' * lint * add todo * add mcp protocol version to the latest protocol * add test coverage * small fix * small fix * small fix * thread fixes * try * add tests * lint * change small * nit * small debugging * add todos * small bug fixes * add todo * remove id field from notifications * refactor * preprocess tools with empty params * fix types * fix bugs * better error log * small cleanup * handle notifications * fix unit tests * lint * decouple client from transport * lint * use toolbox protocol for e2e tests * add e2e tests for mcp * lint * remove mcp as default protocol * remove auth tests from mcp * remove redundant lines * remove redundant lines * lint * revert some changes * initialise session in a better way * small fix * added more test cov * lint * rename private method * Made methods private * lint * rename base url * resolve comment * better readability * fix tests * lint * fix tests * lint * refactor mcp versions * lint * added test coverage * refactor mcp * lint * improve cov * lint * removed process id * Update class name * remove mcp latest * rename mcp.py * have a single method for session init * lint * better type checks for v20241105 * Revert "better type checks for v20241105" This reverts commit bc6da15. * update type checking * lint * clean file * refactor files * refactor all versions * fix mypy errors * refactor properly * lint * run mcp e2e tests on all versions * feat: Add support for auth related features (#363) * test fix * lint * make invoke method return str * lint * try * version negotiation * small changes * lint * fix endpoint * add some todos * lint * initialise in init * lint * add support for 'Mcp-session-id' * lint * add todo * add mcp protocol version to the latest protocol * small fix * small fix * small fix * thread fixes * try * add tests * lint * change small * small debugging * add todos * small bug fixes * add todo * remove id field from notifications * refactor * preprocess tools with empty params * fix types * fix bugs * better error log * small cleanup * handle notifications * fix unit tests * lint * decouple client from transport * lint * use toolbox protocol for e2e tests * lint * remove mcp as default protocol * remove redundant lines * remove redundant lines * lint * revert some changes * initialise session in a better way * small fix * Made methods private * lint * rename base url * resolve comment * better readability * add auth tests * lint * fix test * rename authParam to authParams * refactor mcp versions * fix tests * lint * add auth param support code * lint * add unit test * lint * test fix * lint * fix test * better error handling * fix test * add debug statement * add debug statement * add debug statement * remove debug * remove not needed files * refactor mcp * lint * improve cov * lint * add feat files * small fix * small fix * Update test_e2e_mcp.py * add new tests * add more test cases * remove files * remove rebase changes * fix rebase issues * lint * fix rebase issues * add test case * fix test * fix convert schema logic * lint * feat: Make mcp the default protocol (#364) * add basic code * fixes * test fix * new unit tests * rename ToolboxTransport * add py3.9 support * fix langchain tool tests * test fix * lint * fix tests * move manage session into transport * move warning to diff file * avoid code duplication * fix tests * lint * remove redundant tests * make invoke method return str * lint * fix return type * small refactor * refactor: remove transport logic from client tests * try * version negotiation * small changes * lint * fix endpoint * add some todos * lint * initialise in init * lint * add support for 'Mcp-session-id' * lint * add todo * add mcp protocol version to the latest protocol * add test coverage * small fix * small fix * small fix * thread fixes * try * add tests * lint * change small * nit * small debugging * add todos * small bug fixes * add todo * remove id field from notifications * refactor * preprocess tools with empty params * fix types * fix bugs * better error log * small cleanup * handle notifications * fix unit tests * lint * decouple client from transport * lint * use toolbox protocol for e2e tests * add e2e tests for mcp * lint * remove mcp as default protocol * remove auth tests from mcp * remove redundant lines * remove redundant lines * lint * revert some changes * initialise session in a better way * small fix * added more test cov * lint * rename private method * Made methods private * lint * rename base url * resolve comment * better readability * add auth tests * lint * fix test * make mcp the default protocol * lint * rename authParam to authParams * fix tests * lint * fix tests * lint * refactor mcp versions * lint * added test coverage * add auth param support code * lint * add unit test * lint * lint * test fix * lint * fix test * better error handling * fix test * add debug statement * add debug statement * Update integration.cloudbuild.yaml * add debug statement * remove debug * update server version * Update test_sync_e2e.py * Update test_e2e.py * Update test_e2e.py * refactor mcp * lint * improve cov * lint * removed process id * remove not needed files * add feat files * small fix * small fix * Update test_e2e_mcp.py * add new tests * add more test cases * fix tests * remove unwanted files
In this PR, the MCP protocol does not yet support Auth related functionality such as
Authorized InvocationsandAuthenticated Parameters.Therefore, the default is still the Toolbox Protocol here.