Skip to content

Refactor in preparation for client support #27

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

Merged

Conversation

jcat4
Copy link
Contributor

@jcat4 jcat4 commented May 28, 2025

Motivation and Context

We want to implement client support for this lib. Currently, all the code isn't clearly organized between shared and server-specific code. To be more inline with other sdk's, I've organized the code into /server and /shared dirs.

Now we can relatively easily add a new /client dir and implement client support there.

How Has This Been Tested?

We tested on one of our internal applications, which has an MCP server. We used it from cursor using this version, and everything works just fine.

Breaking Changes

MCP::Transports::StdioTransport is now MCP::Server::Transports::StdioTransport

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

  • Did I miss anything?
  • Is the 1.0.0-preview appropriate? I was thinking the official 1.0.0 could be reserved for the client support. Or this could be 1.0.0 and the client support can be 1.1.0? Since there are technically breaking changes, I don't want to do a minor bump.

@jcat4 jcat4 marked this pull request as ready for review May 28, 2025 15:58
@jcat4
Copy link
Contributor Author

jcat4 commented May 28, 2025

Oops, forgot to move tests

@jcat4 jcat4 marked this pull request as draft May 28, 2025 16:11
@jcat4 jcat4 marked this pull request as ready for review May 28, 2025 16:24
@jcat4 jcat4 changed the title Refactor for client support Refactor in preparation for client support May 28, 2025
@jcat4 jcat4 mentioned this pull request May 28, 2025
9 tasks
@jcat4
Copy link
Contributor Author

jcat4 commented May 30, 2025

resolving merge conflicts 😰

@jcat4 jcat4 marked this pull request as draft May 30, 2025 15:51
@jcat4 jcat4 force-pushed the refactor-for-client-support branch from 2e101fd to ea7a23e Compare May 30, 2025 15:56
@jcat4 jcat4 force-pushed the refactor-for-client-support branch from ea7a23e to d80b137 Compare May 30, 2025 16:15
@jcat4 jcat4 marked this pull request as ready for review May 30, 2025 16:21
@topherbullock topherbullock self-requested a review May 30, 2025 17:36
topherbullock
topherbullock previously approved these changes May 30, 2025
@Ginja
Copy link

Ginja commented May 30, 2025

This has some changes that will cause conflicts for #33.

Not to imply the structure I have there should be the one we use going forward, but this PR is moving around the folder where transport implementations reside. We'll need to stick to one layout or the other. No strong opinions, and feel this decision is best made by @topherbullock and @atesgoral.

@topherbullock
Copy link
Contributor

Not to imply the structure I have there should be the one we use going forward, but this PR is moving around the folder where transport implementations reside.

the gem need to implement StreamableHTTP, stdio, and any other transports for both client and server, so splitting out into mcp/server/transports/ mcp/client/transports/ makes sense

@Ginja
Copy link

Ginja commented Jun 1, 2025

Makes sense to me! I didn't realized prior to my comment that this was fulfilling this issue ❤️

@topherbullock topherbullock merged commit dcc31ca into modelcontextprotocol:main Jun 3, 2025
5 checks passed
koic added a commit to koic/ruby-sdk that referenced this pull request Jun 4, 2025
Follow-up to modelcontextprotocol#27.

This PR fixes the following build error:

```console
$ bundle exec rake
/Users/koic/.rbenv/versions/3.5-dev/lib/ruby/3.5.0+1/bundled_gems.rb:59:in 'Kernel.require': cannot load such file -- mcp/transports/stdio (LoadError)
Did you mean?  mcp/transports/stdio_transport_test
        from /Users/koic/.rbenv/versions/3.5-dev/lib/ruby/3.5.0+1/bundled_gems.rb:59:in 'block (2 levels) in Kernel#replace_require'
        from /Users/koic/src/github.com/modelcontextprotocol/ruby-sdk/test/mcp/transports/stdio_transport_test.rb:4:in '<top (required)>'
        from /Users/koic/.rbenv/versions/3.5-dev/lib/ruby/3.5.0+1/bundled_gems.rb:59:in 'Kernel.require'
        from /Users/koic/.rbenv/versions/3.5-dev/lib/ruby/3.5.0+1/bundled_gems.rb:59:in 'block (2 levels) in Kernel#replace_require'
        from /Users/koic/.rbenv/versions/3.5-dev/lib/ruby/gems/3.5.0+1/gems/rake-13.3.0/lib/rake/rake_test_loader.rb:21:in 'block in <main>'
        from /Users/koic/.rbenv/versions/3.5-dev/lib/ruby/gems/3.5.0+1/gems/rake-13.3.0/lib/rake/rake_test_loader.rb:6:in 'Array#select'
        from /Users/koic/.rbenv/versions/3.5-dev/lib/ruby/gems/3.5.0+1/gems/rake-13.3.0/lib/rake/rake_test_loader.rb:6:in '<main>'
rake aborted!
Command failed with status (1)
/Users/koic/.rbenv/versions/3.5-dev/bin/bundle:25:in 'Kernel#load'
/Users/koic/.rbenv/versions/3.5-dev/bin/bundle:25:in '<main>'
Tasks: TOP => default => test
(See full trace by running task with --trace)
```

https://github.com/modelcontextprotocol/ruby-sdk/actions/runs/15428236624/job/43420346011

The following is stated in modelcontextprotocol#27.

> Breaking Changes
> `MCP::Transports::StdioTransport` is now `MCP::Server::Transports::StdioTransport`

What is shown here is the new name `MCP::Server::Transports::StdioTransport`, not `MCP::Server::Transports::Stdio`.

Therefore, the file path has been updated from `lib/mcp/server/transports/stdio.rb` to `lib/mcp/server/transports/stdio_transport.rb` to
match the module name. If `MCP::Server::Transports::Stdio` is preferred instead, please let me know and I will open a separate PR.
@koic koic mentioned this pull request Jun 4, 2025
9 tasks
koic added a commit to koic/ruby-sdk that referenced this pull request Jun 8, 2025
Follow-up to modelcontextprotocol#27.

This PR adds a migration path for `Server::Transports::StdioTransport`. e.g.,

```console
$ cat /tmp/example.rb
require "mcp/transports/stdio"

MCP::Transports::StdioTransport
```

This change displays the following warning instead of raising an error for such cases, allowing execution to proceed:

```console
$ bundle exec ruby /tmp/example.rb
/tmp/example.rb:1: warning: Use `require "mcp/server/transports/stdio"` instead of `require "mcp/transports/stdio"`.
Also use `MCP::Server::Transports::StdioTransport` instead of `MCP::Transports::StdioTransport`.
This API is deprecated and will be removed in a future release.
```

Currently (v0.1.0), it results in an error without any warning.
This MCP gem is not yet close to version 1.0, but introducing breaking changes to a published interface is undesirable.

This compatibility code should be removed at some point after a few releases.

Closes modelcontextprotocol#50.
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