Skip to content

Conversation

@twishabansal
Copy link
Contributor

@twishabansal twishabansal commented Aug 26, 2025

In this PR, the MCP protocol does not yet support Auth related functionality such as Authorized Invocations and Authenticated Parameters.

Therefore, the default is still the Toolbox Protocol here.

@twishabansal twishabansal changed the base branch from main to mcp-restructure August 26, 2025 10:06
@twishabansal twishabansal changed the title Mcp transport implement feat: Add mcp transport protocol Aug 26, 2025
@twishabansal twishabansal force-pushed the mcp-transport-implement branch from 7e58222 to 78014d7 Compare September 1, 2025 10:56
@twishabansal twishabansal changed the base branch from mcp-restructure to client-transport-decouple September 2, 2025 07:33
@twishabansal twishabansal changed the base branch from client-transport-decouple to mcp-restructure September 2, 2025 07:47
@twishabansal twishabansal requested a review from Yuan325 November 19, 2025 17:12
@twishabansal
Copy link
Contributor Author

Have you thought of creating a schema file for each protocol version (/mcp_transport/v20241105/types.py):

class InitializeRequest(BaseModel):
    protocolVersion: str
    capabilities: ...

And then use InitializeRequest.model_json_schema() to convert it to json before sending it to the server. I think hardcode json schema into the code itself might be tougher to maintain and track as we add more capabilities and support more versions.

Something like this: https://github.com/modelcontextprotocol/python-sdk/blob/9724ad1ce66c2a4f18c7539ef589d4d3b9aebd82/src/mcp/types.py#L83

Official schema could be found here: https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/2024-11-05/schema.ts

I have refactored the code accordingly. Please have a look and let me know what you think!

Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

self,
url: str,
method: str,
params: dict,
Copy link
Contributor

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.)

Copy link
Contributor Author

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!

@twishabansal twishabansal requested a review from Yuan325 December 8, 2025 08:44
Copy link
Contributor

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.

@twishabansal
Copy link
Contributor Author

@Yuan325 I have added mcp e2e tests for all versions.

@twishabansal twishabansal merged commit cb97f35 into feat-mcp Dec 9, 2025
16 checks passed
twishabansal added a commit that referenced this pull request Dec 10, 2025
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants