1
1
/* eslint-disable @typescript-eslint/no-explicit-any */
2
2
import { FastifyBaseLogger } from 'fastify' ;
3
3
import { HttpProxyManager } from './http-proxy-manager' ;
4
- import { RemoteToolDiscoveryManager } from './remote -tool-discovery-manager' ;
4
+ import { UnifiedToolDiscoveryManager } from './unified -tool-discovery-manager' ;
5
5
import { ProxyRequestContext } from '../types/mcp-server' ;
6
6
7
7
/**
@@ -11,9 +11,9 @@ import { ProxyRequestContext } from '../types/mcp-server';
11
11
export class McpProtocolHandler {
12
12
private logger : FastifyBaseLogger ;
13
13
private httpProxyManager : HttpProxyManager ;
14
- private toolDiscoveryManager : RemoteToolDiscoveryManager ;
14
+ private toolDiscoveryManager : UnifiedToolDiscoveryManager ;
15
15
16
- constructor ( httpProxyManager : HttpProxyManager , toolDiscoveryManager : RemoteToolDiscoveryManager , logger : FastifyBaseLogger ) {
16
+ constructor ( httpProxyManager : HttpProxyManager , toolDiscoveryManager : UnifiedToolDiscoveryManager , logger : FastifyBaseLogger ) {
17
17
this . httpProxyManager = httpProxyManager ;
18
18
this . toolDiscoveryManager = toolDiscoveryManager ;
19
19
this . logger = logger . child ( { component : 'McpProtocolHandler' } ) ;
@@ -126,14 +126,14 @@ export class McpProtocolHandler {
126
126
}
127
127
128
128
/**
129
- * Handle tools/list request - returns cached discovered tools from remote MCP servers
129
+ * Handle tools/list request - returns cached discovered tools from both stdio and remote MCP servers
130
130
*/
131
131
private async handleToolsList ( ) : Promise < any > {
132
132
this . logger . debug ( {
133
133
operation : 'mcp_tools_list'
134
- } , 'Listing cached discovered tools from remote MCP servers' ) ;
134
+ } , 'Listing cached discovered tools from stdio and remote MCP servers' ) ;
135
135
136
- const cachedTools = this . toolDiscoveryManager . getCachedTools ( ) ;
136
+ const cachedTools = this . toolDiscoveryManager . getAllTools ( ) ;
137
137
138
138
const tools = cachedTools . map ( tool => ( {
139
139
name : tool . namespacedName ,
@@ -149,7 +149,7 @@ export class McpProtocolHandler {
149
149
tools : tools . map ( t => t . name ) ,
150
150
discovery_ready : this . toolDiscoveryManager . isReady ( ) ,
151
151
result_object : result
152
- } , `Returning ${ tools . length } cached tools from remote MCP servers` ) ;
152
+ } , `Returning ${ tools . length } cached tools from stdio and remote MCP servers` ) ;
153
153
154
154
this . logger . debug ( {
155
155
operation : 'mcp_tools_list_debug' ,
@@ -188,11 +188,11 @@ export class McpProtocolHandler {
188
188
const serverSlug = namespacedToolName . substring ( 0 , dashIndex ) ;
189
189
190
190
// Find the cached tool to get the original tool name and verify it exists
191
- const cachedTools = this . toolDiscoveryManager . getCachedTools ( ) ;
192
- const cachedTool = cachedTools . find ( tool => tool . namespacedName === namespacedToolName ) ;
191
+ const cachedTool = this . toolDiscoveryManager . getTool ( namespacedToolName ) ;
193
192
194
193
if ( ! cachedTool ) {
195
- throw new Error ( `Tool not found: ${ namespacedToolName } . Available tools: ${ cachedTools . map ( t => t . namespacedName ) . join ( ', ' ) } ` ) ;
194
+ const allTools = this . toolDiscoveryManager . getAllTools ( ) ;
195
+ throw new Error ( `Tool not found: ${ namespacedToolName } . Available tools: ${ allTools . map ( t => t . namespacedName ) . join ( ', ' ) } ` ) ;
196
196
}
197
197
198
198
// Use OAuth team context to find the correct server instance
0 commit comments