@@ -10,7 +10,7 @@ import { proxy } from "hono/proxy"
1010import { Session } from "../session"
1111import z from "zod"
1212import { Provider } from "../provider/provider"
13- import { filter , mapValues , sortBy , pipe } from "remeda"
13+ import { filter , mapValues , sortBy , pipe , mergeDeep } from "remeda"
1414import { NamedError } from "@opencode-ai/util/error"
1515import { ModelsDev } from "../provider/models"
1616import { Ripgrep } from "../file/ripgrep"
@@ -43,6 +43,7 @@ import { Ide } from "../ide"
4343import { Storage } from "../storage/storage"
4444import type { ContentfulStatusCode } from "hono/utils/http-status"
4545import { TuiEvent } from "@/cli/cmd/tui/event"
46+ import { Wildcard } from "@/util/wildcard"
4647import { Snapshot } from "@/snapshot"
4748import { SessionSummary } from "@/session/summary"
4849import { SessionStatus } from "@/session/status"
@@ -453,6 +454,52 @@ export namespace Server {
453454 return c . json ( config )
454455 } ,
455456 )
457+ . get (
458+ "/tool/list" ,
459+ describeRoute ( {
460+ summary : "List tools" ,
461+ description : "Get a list of all available tools with their enabled status." ,
462+ operationId : "tool.list" ,
463+ responses : {
464+ 200 : {
465+ description : "Tool list" ,
466+ content : {
467+ "application/json" : {
468+ schema : resolver (
469+ z . array (
470+ z . object ( {
471+ id : z . string ( ) ,
472+ enabled : z . boolean ( ) ,
473+ } ) ,
474+ ) ,
475+ ) ,
476+ } ,
477+ } ,
478+ } ,
479+ } ,
480+ } ) ,
481+ async ( c ) => {
482+ const builtinIds = await ToolRegistry . ids ( )
483+ const mcpTools = await MCP . tools ( )
484+ const mcpIds = Object . keys ( mcpTools )
485+ // Combine and filter out 'invalid' tool
486+ const allIds = [ ...builtinIds . filter ( ( id ) => id !== "invalid" ) , ...mcpIds ]
487+
488+ // Get enabled status based on agent tools config
489+ const defaultAgentName = await Agent . defaultAgent ( )
490+ const agent = await Agent . get ( defaultAgentName )
491+ const enabledTools = agent
492+ ? mergeDeep ( agent . tools , await ToolRegistry . enabled ( agent ) )
493+ : ( { } as Record < string , boolean > )
494+
495+ return c . json (
496+ allIds . map ( ( id ) => ( {
497+ id,
498+ enabled : Wildcard . all ( id , enabledTools ) !== false ,
499+ } ) ) ,
500+ )
501+ } ,
502+ )
456503 . get (
457504 "/experimental/tool/ids" ,
458505 describeRoute ( {
0 commit comments