Skip to content
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

feat: MCP client sdk #488

Closed
wants to merge 12 commits into from
Closed

feat: MCP client sdk #488

wants to merge 12 commits into from

Conversation

salman1993
Copy link
Collaborator

@salman1993 salman1993 commented Dec 17, 2024

Provides a minimal MCP client sdk which will be used to write goose as an MCP client.
https://spec.modelcontextprotocol.io/specification/basic/

Methods we implemented:

  • initialize
  • list resources
  • read resource
  • list tools
  • call tool

@salman1993 salman1993 marked this pull request as ready for review December 17, 2024 23:39
@salman1993 salman1993 changed the title feat: MCP client sdk (draft) feat: MCP client sdk Dec 17, 2024
@salman1993 salman1993 requested a review from wendytang December 18, 2024 13:54
* origin/v1.0:
  stop bubbles filling screen (#495)
  chore: V1.0 release automation (#493)
  requires foreign architectures
  more xcompile deps
  x compilation tools
  chore: Cargo build tokenizers (#491)
  feat: build and release binaries to GH releases (#477)
  fix: width of bubbles and logging errors (#487)
  feat: add google provider (#489)
  feat: flappy goose easter egg (#479)
Copy link
Collaborator

@baxen baxen left a comment

Choose a reason for hiding this comment

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

left some comments about parallelism that i think we lost in this version

}

/// Send a JSON-RPC request and wait for a response.
async fn send_message<R>(&mut self, method: &str, params: Value) -> Result<R, Error>
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: send_request?

Box::pin(async move {
let transport = transport.lock().await;

// Initialize (start) transport on the first call.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: this might be surprising behavior, might make this more explicit by instead asserting initialization here and moving the start call to another method or maybe at instantiation?

Ok(response)
}
JsonRpcMessage::Request(request) => {
// Serialize request & wait for response
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see how this version works, but i might be missing something?

It definitely works if everything is used in serial, a request gets sent in, the next message to receive is the response to that request, this exits happily.

But if we send multiple requests in parallel, i don't see that there's any guarantee they come back in order?

I think we need something like the previous Session implementation where each outbound request goes with an attached response_tx, so that this can await the response_rx.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you're right! i rewrote this here: #505

/// - receiving JSON-RPC messages as strings
/// - closing the transport cleanly
#[async_trait]
pub trait Transport: Send + 'static {
Copy link
Collaborator

Choose a reason for hiding this comment

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

start/close make sense, but i think we want to have a Receiver and Sender so we can more carefully handle parallelism. there needs to be something polling these to route responses back to their originating requests, and implementing send/receive from scratch would mean we need to be more careful with that handling - i wouldn't want to have to reimplement the sleep vs close etc logic

salman1993 and others added 2 commits December 19, 2024 10:42
…ntation

* checks out the changes from 'kalvin/mcp-client-trait' branch

Co-authored-by: kalvinnchau <[email protected]>
@salman1993
Copy link
Collaborator Author

changes transferred over to this PR - #505

@salman1993 salman1993 closed this Dec 20, 2024
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.

2 participants