feat: filter tools by MCP Apps visibility metadata (#8022)

Signed-off-by: Andrew Harvard <aharvard@squareup.com>
Co-authored-by: Goose <opensource@block.xyz>
This commit is contained in:
Andrew Harvard
2026-03-20 08:28:45 -04:00
committed by GitHub
parent e2fc8ddb80
commit b7615938bc
5 changed files with 164 additions and 4 deletions
+13
View File
@@ -14,6 +14,7 @@ use goose::agents::{Container, ExtensionLoadResult};
use goose::goose_apps::{fetch_mcp_apps, GooseApp, McpAppCache};
use base64::Engine;
use goose::agents::reply_parts::is_tool_visible_to_app;
use goose::agents::ExtensionConfig;
use goose::config::resolve_extensions_for_new_session;
use goose::config::{Config, GooseMode};
@@ -1047,6 +1048,18 @@ async fn call_tool(
.get_agent_for_route(payload.session_id.clone())
.await?;
// Check app-side visibility: reject calls to tools that exclude "app"
let tools = agent.list_tools(&payload.session_id, None).await;
if let Some(tool) = tools.iter().find(|t| *t.name == payload.name) {
if !is_tool_visible_to_app(tool) {
warn!(
tool = %payload.name,
"Rejected app call to model-only tool"
);
return Err(StatusCode::FORBIDDEN);
}
}
let arguments = match payload.arguments {
Value::Object(map) => Some(map),
_ => None,