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: adds default tools that can use MCP resources #619

Merged
merged 15 commits into from
Jan 20, 2025

Conversation

salman1993
Copy link
Collaborator

@salman1993 salman1993 commented Jan 16, 2025

  • adds 2 default "platform" tools to list and read MCP resources
  • dynamically added when any of the connected extensions have resource capabilities

@salman1993 salman1993 changed the base branch from main to v1.0 January 16, 2025 00:11
Copy link

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

Copy link

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

Copy link

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

@kalvinnchau kalvinnchau force-pushed the sm/read-resource-tool branch from f936f67 to 06388d2 Compare January 17, 2025 17:56
Copy link

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

Copy link

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

The format of a tool is "{system_name}__{tool_name}", i.e. the system
name followed by the tool name with '__' as the separator.

By default, we add a tool called "platform__read_resource", which can
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

can briefly describe platform__list_resources here

@kalvinnchau kalvinnchau marked this pull request as ready for review January 17, 2025 20:07
@salman1993
Copy link
Collaborator Author

this looks good to me but i think we should test this out a bit more with MCP servers that have resources, after merging in #636

curious how you've found this so far for gdrive?

@kalvinnchau
Copy link
Collaborator

curious how you've found this so far for gdrive?

only a tiny useful for gdrive imo, the list returns the last 10 most recently viewed files.
the search + read workflow works well for me

depending on how other mcp servers implement resources, since we don't do pagination could be hit or miss

@kalvinnchau kalvinnchau force-pushed the sm/read-resource-tool branch from c52b367 to 03fe456 Compare January 17, 2025 22:04
@salman1993
Copy link
Collaborator Author

salman1993 commented Jan 17, 2025

lgtm - github won't let me approve it since i am a co-author. @baxen can you do a quick skim on this one?

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.

Looks good! I would do the conditional enable though if possible

}),
);

tools.push(read_resource_tool);
Copy link
Collaborator

Choose a reason for hiding this comment

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

i would conditionally append these tools only if one of the systems has a resource capability. I'd also update the tooltip to include which systems have resources

@@ -10,6 +10,14 @@ to interactions with sytems that are not currently active. The currently
active systems are below. Each of these systems provides tools that are
in your tool specification.

The format of a tool is "{system_name}__{tool_name}", i.e. the system
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: i think these additions are excludable? not sure if you saw any performance issues with this but i have not seen any problems or a need to warn it about tools beyond the tool descriptions

// If system name is not provided, we need to search for the resource across all systems
// Loop through each system and try to read the resource, don't raise an error if the resource is not found
for system_name in self.clients.keys() {
let result = self.read_resource_from_system(uri, system_name).await;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: either make a note that we assume no risk of collision for generic names or ensure num_matches == 1 before proceeding?

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm good point, if two systems have the same resource uri, it would find the first match and exit the loop
i'll put a TODO comment, not sure if we'd want to find the uri across all systems or not

Copy link
Collaborator

@wendytang wendytang left a comment

Choose a reason for hiding this comment

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

one interesting follow up idea would be to append some metadata about the resources like token count or file size and make that transparent to the user

@kalvinnchau
Copy link
Collaborator

kalvinnchau commented Jan 18, 2025

@baxen added the conditional adding of the tools, I removed the with_resource(false, false) from the developer2 system, since that reported that it supports resources but just returns an empty Vec all the time.

@kalvinnchau kalvinnchau force-pushed the sm/read-resource-tool branch from 4b1425f to 00b4203 Compare January 18, 2025 00:34
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.

Looks good! Let's try this out with some real mcp servers before merging i think

let mut futures = FuturesUnordered::new();

// Create futures for each system
for (system_name, client) in &self.clients {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can skip some steps by iterating over self.resource_capable_systems instead here now?

// Loop through each system and try to read the resource, don't raise an error if the resource is not found
// TODO: do we want to find if a provided uri is in multiple systems?
// currently it will reutrn the first match and skip any systems
for system_name in self.clients.keys() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can skip some steps by searching only self.resource_capable_system (like below)

@@ -10,12 +10,21 @@ to interactions with sytems that are not currently active. The currently
active systems are below. Each of these systems provides tools that are
in your tool specification.

When a system is added that supports Resources,, we add two tools,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: i think we can just delete this entirely. the tool descriptions and the below hint per system should cover this i think!

resource URI in the provided system, and reads in the resource content. If no system
is provided, the tool will search all systems for the resource.

The read_resource tool is typically used with a search query (can be before or after). Here are two examples:
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: i'd remove these extra tips unless we find they are needed tips? not sure if it was tested. i've been noticing these specific examples don't necessarily make it better at using the tools but can confuse it into hallucinating usage that isn't relevant, with frontier models at least

in the provided system, and returns a list for the user to browse. If no system
is provided, the tool will search all systems for the resource.

The list_resources tool is typically used before a read_resource tool call. Here are two examples:
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: i'd remove these extra tips unless we find they are needed tips? not sure if it was tested. i've been noticing these specific examples don't necessarily make it better at using the tools but can confuse it into hallucinating usage that isn't relevant, with frontier models at least

reuse list_resources_from_system instead of reimplmenting it for
iterating over all systems
@@ -15,7 +15,10 @@ in your tool specification.

## {{system.name}}
{{system.description}}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

does the description get populated anywhere? i think we can remove this

@salman1993 salman1993 changed the title feat: add read_resource tool which is always present in reference agent feat: adds default tools that can use MCP resources Jan 20, 2025
@salman1993 salman1993 merged commit a22daca into v1.0 Jan 20, 2025
michaelneale added a commit that referenced this pull request Jan 21, 2025
* v1.0:
  fix: add missing type param, separate block for signed/unsigned (#661)
  feat: adds default tools that can use MCP resources (#619)
michaelneale added a commit that referenced this pull request Jan 21, 2025
* v1.0:
  use an npx and uvx shim with hermit for MCPs (#655)
  fix: add missing type param, separate block for signed/unsigned (#661)
  feat: adds default tools that can use MCP resources (#619)
acekyd pushed a commit that referenced this pull request Jan 21, 2025
* adds 2 default "platform" tools to list and read MCP resources

* dynamically added when any of the connected extensions have resource capabilities

Co-authored-by: Kalvin Chau <[email protected]>
@yingjiehe-xyz yingjiehe-xyz deleted the sm/read-resource-tool branch February 5, 2025 21:06
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.

4 participants