Skip to content

Conversation

jcat4
Copy link
Contributor

@jcat4 jcat4 commented May 28, 2025

Motivation and Context

Closes #3

Follow-up to #27

This adds the ability to build MCP clients with the ruby sdk. I've started with just a basic HTTP transport layer. We can add other things (i.e. streamable HTTP) later.

Per this comment, we've decided to go with a pluggable approach where:

  • You create an instance of the transport layer you want to use
  • A Client is initialized with that transport layer
  • The client receives messages (i.e. tools or call_tool)
  • The client builds a JSON-RPC request object
  • The JSON-RPC request object is passed to the transport layer's send_request method to communicate with the server
  • The transport returns a JSON-RPC response object
  • The client then parses the response and does whatever it needs to with it

For simplicity, I'm just allowing custom headers to specify auth. I didn't want to build an abstraction around different auth types prematurely. I've made authentication the responsibility of the transport layer, since that's what is responsible for communication with the server.

How Has This Been Tested?

The local gem build has been tested in 2 different internal repositories and is working as expected so far.

Breaking Changes

Just the stuff from #27

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

@jcat4 jcat4 marked this pull request as ready for review May 29, 2025 16:22
@jcat4 jcat4 marked this pull request as draft May 29, 2025 17:54
@jcat4
Copy link
Contributor Author

jcat4 commented May 29, 2025

Decided to build in auth, going to draft to test it

@jcat4
Copy link
Contributor Author

jcat4 commented May 29, 2025

Auth is tested and working

@jcat4 jcat4 marked this pull request as ready for review May 29, 2025 19:47
@topherbullock
Copy link
Contributor

@jcat4 can you rebase on main and resolve conflicts? seems to be largely the model_context_protocol => mcp rename

@atesgoral atesgoral mentioned this pull request Jun 15, 2025
@vickyonit
Copy link

Thank you for your work on this, @jcat4. We're looking forward to seeing it merged. Is there an expected timeline for this?

@jcat4
Copy link
Contributor Author

jcat4 commented Jun 19, 2025

@jcat4 can you rebase on main and resolve conflicts? seems to be largely the model_context_protocol => mcp rename

Sorry, lost track of this.

I thought we wanted to go with the pluggable approach? If so, I can close this

Or I can try to rework this to be closer to what y'all envisioned!

@atesgoral
Copy link
Contributor

@jcat4 @topherbullock Now that #27 is in, could we revisit this and get a client in there? 🙏

@jcat4
Copy link
Contributor Author

jcat4 commented Jul 29, 2025

@jcat4 @topherbullock Now that #27 is in, could we revisit this and get a client in there? 🙏

I'll make some time this week to knock this out

@jcat4 jcat4 marked this pull request as draft July 30, 2025 16:25
@jcat4 jcat4 force-pushed the add-basic-http-client-support branch from e72bcfa to 3a0b9b8 Compare July 30, 2025 16:30
```

## Configuration
### Configuration
Copy link
Contributor Author

@jcat4 jcat4 Jul 31, 2025

Choose a reason for hiding this comment

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

At the moment, this is server-specific. If we have this patch a client config too (or stop having the config scoped to just the server), we can move this somewhere else in the README

@jcat4
Copy link
Contributor Author

jcat4 commented Jul 31, 2025

Unsure if we still feel strongly about going with a pluggable approach, and haven't had any feedback on that yet. Will put this as-is in for review

But please let me know if we should go somewhere else with the interface! I want us to get as close to right as possible on our first release

@jcat4 jcat4 marked this pull request as ready for review July 31, 2025 19:41
@jcat4
Copy link
Contributor Author

jcat4 commented Jul 31, 2025

I've tested the new code in one of our local apps, and it's working as expected.

@jcat4 jcat4 requested review from atesgoral and juharris July 31, 2025 19:42
@jcat4
Copy link
Contributor Author

jcat4 commented Jul 31, 2025

Spoke with @juharris, and we decided a pluggable approach would probably be better. The primary reason is it will allow folks to implement and pass their own custom transport layers (and open the door for other gems to add more, too!). The first step might be a bit manual (create your transport, create your client by passing your transport, send messages to your client), but we can iterate later with convenience wrappers that won't break existing code

Overall, it seems like the safer bet. What we have is functional, but maybe not flexible enough for a public gem. Will begin work on this again next week when I have time, I think I can knock something out relatively quickly

@atesgoral
Copy link
Contributor

@jcat4 Thanks for doing this!

@jcat4
Copy link
Contributor Author

jcat4 commented Aug 28, 2025

Because these are specific to the user's development environment (such as OS or editor) and not specific to the Ruby SDK. For more details, please refer to the discussion in the following closed PRs: https://github.com/rails/rails/pulls?q=is%3Apr+.DS_Store+is%3Aclosed+

Thanks for this! Hmmm... I do see that's how rails operates. If this is commonly how other open source ruby repos operate, I can make this change to be more inline.

But I do wanna say, I still personally disagree, as I think this change could avoid friction. Those 14 PRs in rails where this convo had to happen are examples of friction that could be avoided.

If you have any docs or anything on hand, would love to know more about why we want to have a platform-agnostic .gitignore!

@jcat4 jcat4 force-pushed the add-basic-http-client-support branch from 972b985 to 03c492d Compare August 28, 2025 15:24
@jcat4 jcat4 requested a review from koic August 28, 2025 15:28
@koic
Copy link
Member

koic commented Aug 28, 2025

I'm personally convinced by the reasoning in the Rails repository, so I don't have any additional documentation beyond that. In any case, this doesn't seem to be the main focus of this PR. This point can serve as a starting place for the PR itself. I do have a bit of feedback, so I'll leave some additional comments.

@jcat4 jcat4 force-pushed the add-basic-http-client-support branch 2 times, most recently from e9461d9 to 91d3327 Compare August 28, 2025 16:46
@jcat4 jcat4 requested a review from koic August 28, 2025 16:46
koic
koic previously approved these changes Aug 30, 2025
@jcat4 jcat4 force-pushed the add-basic-http-client-support branch 2 times, most recently from b3813a6 to 774a3af Compare September 4, 2025 14:18
@jcat4 jcat4 requested a review from koic September 4, 2025 14:19
@jcat4
Copy link
Contributor Author

jcat4 commented Sep 4, 2025

I had merge conflicts, had to rebase, resolve, and squash. Nothing of substance changed since last approval

EDIT: nvm, this part of the README changed, and found some stale YARD docs in the client

@jcat4 jcat4 force-pushed the add-basic-http-client-support branch 2 times, most recently from 6604a48 to 79a7127 Compare September 4, 2025 14:30
@dsp-ant dsp-ant requested review from dsp-ant and removed request for juharris September 4, 2025 15:10
@jcat4 jcat4 force-pushed the add-basic-http-client-support branch from c501942 to 8b76442 Compare September 8, 2025 20:52
@jcat4 jcat4 requested a review from koic September 8, 2025 20:52
@koic
Copy link
Member

koic commented Sep 9, 2025

This MCP client implementation can serve as a starting point and be improved as needed. In any case, no further conflicts should arise with this PR. Thank you for working on it!

@koic koic merged commit 97640ed into modelcontextprotocol:main Sep 9, 2025
5 checks passed
@atesgoral atesgoral mentioned this pull request Sep 14, 2025
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.

client implementation
6 participants