Repository navigation
let agents refresh a custom MCP server's tools, and refresh them when stale - #380
Merged
Merged
Conversation
…emselves when the list is stale pap.refreshTools(connection), and `pap tools <connection> --refresh` from a sandbox, asks a custom MCP server for its tools now and keeps the new list, as the connection page's button does, for an open task on a connection the agent can use. It answers with the tools the agent has and the names of the ones the person hasn't turned on, so an agent can say which to allow. The list is also asked for again without anyone asking: by an agent reading it once it is an hour old, and, at most once a minute, by a call naming a tool the list lacks or one the server says it no longer has, which is then not found rather than failing as the server's error. Asking that fails leaves the kept list to read. The page's button goes through the same code, and updateConnectionTools only writes while the connection is still a custom one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Agents can now ask a custom MCP server for its tools again with
pap.refreshTools(connection)(pap tools <connection> --refreshin a sandbox), as the connection page's button does. It needs an open task and a connection the agent can use. It answers with the tools the agent has and the names of those the person hasn't turned on, so an agent can say which tool to allow instead of guessing.The list is also refreshed automatically: when an agent reads it and it is over an hour old, and, at most once a minute, when a call names a tool the list lacks or one the server says it no longer has. In that last case the agent gets "No tool X" instead of the server's error. Before this, a server that removed or added tools left agents calling dead tools until the person clicked refresh.
Refresh times are kept in memory per instance (no migration), concurrent refreshes of one connection share a request, and a refresh that fails leaves the saved list in use. New tools stay off until the person turns them on, and settings for tools the server no longer lists are dropped, as with the button.
updateConnectionToolsnow only writes while the connection is still a custom MCP one, so a refresh racing a move to a built-in integration can't delete that integration's settings.Open workspace in Conductor