@@ -31,6 +31,7 @@ import {
3131 canLoadServer ,
3232} from '../../config/mcp/mcpServerEnablement.js' ;
3333import { loadSettings } from '../../config/settings.js' ;
34+ import { parseSlashCommand } from '../../utils/commands.js' ;
3435
3536const authCommand : SlashCommand = {
3637 name : 'auth' ,
@@ -177,6 +178,7 @@ const listAction = async (
177178 context : CommandContext ,
178179 showDescriptions = false ,
179180 showSchema = false ,
181+ serverNameFilter ?: string ,
180182) : Promise < void | MessageActionReturn > => {
181183 const agentContext = context . services . agentContext ;
182184 const config = agentContext ?. config ;
@@ -199,11 +201,25 @@ const listAction = async (
199201 } ;
200202 }
201203
202- const mcpServers = config . getMcpClientManager ( ) ?. getMcpServers ( ) || { } ;
203- const serverNames = Object . keys ( mcpServers ) ;
204+ let mcpServers = config . getMcpClientManager ( ) ?. getMcpServers ( ) || { } ;
204205 const blockedMcpServers =
205206 config . getMcpClientManager ( ) ?. getBlockedMcpServers ( ) || [ ] ;
206207
208+ if ( serverNameFilter ) {
209+ const filter = serverNameFilter . trim ( ) . toLowerCase ( ) ;
210+ if ( filter ) {
211+ mcpServers = Object . fromEntries (
212+ Object . entries ( mcpServers ) . filter (
213+ ( [ name ] ) =>
214+ name . toLowerCase ( ) . includes ( filter ) ||
215+ normalizeServerId ( name ) . includes ( filter ) ,
216+ ) ,
217+ ) ;
218+ }
219+ }
220+
221+ const serverNames = Object . keys ( mcpServers ) ;
222+
207223 const connectingServers = serverNames . filter (
208224 ( name ) => getMCPServerStatus ( name ) === MCPServerStatus . CONNECTING ,
209225 ) ;
@@ -306,7 +322,7 @@ const listCommand: SlashCommand = {
306322 description : 'List configured MCP servers and tools' ,
307323 kind : CommandKind . BUILT_IN ,
308324 autoExecute : true ,
309- action : ( context ) => listAction ( context ) ,
325+ action : ( context , args ) => listAction ( context , false , false , args ) ,
310326} ;
311327
312328const descCommand : SlashCommand = {
@@ -315,7 +331,7 @@ const descCommand: SlashCommand = {
315331 description : 'List configured MCP servers and tools with descriptions' ,
316332 kind : CommandKind . BUILT_IN ,
317333 autoExecute : true ,
318- action : ( context ) => listAction ( context , true ) ,
334+ action : ( context , args ) => listAction ( context , true , false , args ) ,
319335} ;
320336
321337const schemaCommand : SlashCommand = {
@@ -324,7 +340,7 @@ const schemaCommand: SlashCommand = {
324340 'List configured MCP servers and tools with descriptions and schemas' ,
325341 kind : CommandKind . BUILT_IN ,
326342 autoExecute : true ,
327- action : ( context ) => listAction ( context , true , true ) ,
343+ action : ( context , args ) => listAction ( context , true , true , args ) ,
328344} ;
329345
330346const reloadCommand : SlashCommand = {
@@ -333,6 +349,7 @@ const reloadCommand: SlashCommand = {
333349 description : 'Reloads MCP servers' ,
334350 kind : CommandKind . BUILT_IN ,
335351 autoExecute : true ,
352+ takesArgs : false ,
336353 action : async (
337354 context : CommandContext ,
338355 ) : Promise < void | SlashCommandActionReturn > => {
@@ -530,5 +547,18 @@ export const mcpCommand: SlashCommand = {
530547 enableCommand ,
531548 disableCommand ,
532549 ] ,
533- action : async ( context : CommandContext ) => listAction ( context ) ,
550+ action : async (
551+ context : CommandContext ,
552+ args : string ,
553+ ) : Promise < void | SlashCommandActionReturn > => {
554+ if ( args ) {
555+ const parsed = parseSlashCommand ( `/${ args } ` , mcpCommand . subCommands ! ) ;
556+ if ( parsed . commandToExecute ?. action ) {
557+ return parsed . commandToExecute . action ( context , parsed . args ) ;
558+ }
559+ // If no subcommand matches, treat the whole args as a filter for list
560+ return listAction ( context , false , false , args ) ;
561+ }
562+ return listAction ( context ) ;
563+ } ,
534564} ;
0 commit comments