@@ -169,20 +169,31 @@ func capabilityAllowed(id string, context capabilityAccessContext) bool {
169169 return currentCapabilityAuthorizer .Allows (id , context )
170170}
171171
172+ func capabilityOwnerAvailable (source , runtime , ownerID string ) bool {
173+ if source != "mcp" && runtime != "mcp" {
174+ return true
175+ }
176+ if ownerID == "" {
177+ return true
178+ }
179+ if kernelModel .Conf == nil || kernelModel .Conf .AI == nil || kernelModel .Conf .AI .MCP == nil {
180+ return false
181+ }
182+ for _ , server := range kernelModel .Conf .AI .MCP .Servers {
183+ if server .ID == ownerID {
184+ return server .Enabled
185+ }
186+ }
187+ return false
188+ }
189+
172190func buildCapabilitySet (frontendCapabilities []FrontendCapability , accessContext capabilityAccessContext ) (* capabilitySet , error ) {
173191 set := & capabilitySet {
174192 registrations : map [string ]* capabilityRegistration {},
175193 ids : map [string ]* capabilityRegistration {},
176194 }
177195 for _ , tool := range tools .GetAllTools () {
178196 id := tools .CapabilityIDForTool (tool )
179- if id == "" || ! capabilityAllowed (id , accessContext ) {
180- continue
181- }
182- registered , validator := tools .LookupToolWithValidator (tool .Name )
183- if registered != tool || validator == nil {
184- continue
185- }
186197 runtime := tool .Runtime
187198 if runtime == "" {
188199 runtime = "kernel"
@@ -191,6 +202,14 @@ func buildCapabilitySet(frontendCapabilities []FrontendCapability, accessContext
191202 if source == "" {
192203 source = "native"
193204 }
205+ if id == "" || ! capabilityOwnerAvailable (source , runtime , tool .OwnerID ) ||
206+ ! capabilityAllowed (id , accessContext ) {
207+ continue
208+ }
209+ registered , validator := tools .LookupToolWithValidator (tool .Name )
210+ if registered != tool || validator == nil {
211+ continue
212+ }
194213 registration := & capabilityRegistration {
195214 ID : id ,
196215 ModelName : tool .Name ,
@@ -335,7 +354,12 @@ func capabilityStillExecutable(registration *capabilityRegistration, args map[st
335354 }
336355 accessContext := registration .AccessContext
337356 accessContext .Arguments = args
338- if ! capabilityAllowed (registration .ID , accessContext ) {
357+ ownerID := registration .OwnerID
358+ if ownerID == "" && registration .Tool != nil {
359+ ownerID = registration .Tool .OwnerID
360+ }
361+ if ! capabilityOwnerAvailable (registration .Source , registration .Runtime , ownerID ) ||
362+ ! capabilityAllowed (registration .ID , accessContext ) {
339363 return false
340364 }
341365 if registration .isBrowser () {
0 commit comments