@@ -25,10 +25,7 @@ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"
2525
2626const dbg = genaiscriptDebug ( "mcp:client" ) ;
2727
28- export interface McpClientProxy extends McpClient {
29- listToolCallbacks ( ) : Promise < ToolCallback [ ] > ;
30- }
31-
28+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3229function toolResultContentToText ( res : any ) {
3330 const content = res . content as ( TextContent | ImageContent | EmbeddedResource ) [ ] ;
3431 let text = arrayify ( content )
@@ -56,24 +53,24 @@ function resolveMcpEnv(_env: Record<string, string>) {
5653 if ( ! _env ) return _env ;
5754 const res = structuredClone ( _env ) ;
5855 Object . entries ( res )
59- . filter ( ( [ k , v ] ) => v === "" )
60- . forEach ( ( [ key , value ] ) => {
56+ . filter ( ( [ , v ] ) => v === "" )
57+ . forEach ( ( [ key ] ) => {
6158 dbg ( `filling env var: %s` , key ) ;
6259 res [ key ] = process . env [ key ] || "" ;
6360 } ) ;
6461 return res ;
6562}
6663
6764export class McpClientManager extends EventTarget implements AsyncDisposable {
68- private _clients : McpClientProxy [ ] = [ ] ;
65+ private _clients : McpClient [ ] = [ ] ;
6966 constructor ( ) {
7067 super ( ) ;
7168 }
7269
7370 async startMcpServer (
7471 serverConfig : McpServerConfig ,
7572 options : Required < TraceOptions > & CancellationOptions ,
76- ) : Promise < McpClientProxy > {
73+ ) : Promise < McpClient > {
7774 const { cancellationToken } = options || { } ;
7875 logVerbose ( `mcp: starting ` + serverConfig . id ) ;
7976 const signal = toSignal ( cancellationToken ) ;
@@ -137,11 +134,12 @@ export class McpClientManager extends EventTarget implements AsyncDisposable {
137134 ( {
138135 name : t . name ,
139136 description : t . description ,
137+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
140138 inputSchema : t . inputSchema as any ,
141139 } ) satisfies McpToolReference ,
142140 ) ;
143141 } ;
144- const listToolCallbacks : McpClientProxy [ "listToolCallbacks" ] = async ( ) => {
142+ const listToolCallbacks : McpClient [ "listToolCallbacks" ] = async ( ) => {
145143 // list tools
146144 dbgc ( `listing tools` ) ;
147145 let { tools : toolDefinitions } = await client . listTools (
@@ -207,11 +205,13 @@ export class McpClientManager extends EventTarget implements AsyncDisposable {
207205 spec : {
208206 name : `${ id } _${ name } ` ,
209207 description,
208+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
210209 parameters : inputSchema as any ,
211210 } ,
212211 options : toolOptions ,
213212 generator,
214- impl : async ( args : any ) => {
213+ impl : async ( args ) => {
214+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
215215 const { context, ...restArgs } = args ;
216216 const res = await client . callTool (
217217 {
@@ -251,7 +251,8 @@ export class McpClientManager extends EventTarget implements AsyncDisposable {
251251 content : content . text
252252 ? String ( content . text )
253253 : content . blob
254- ? Buffer . from ( content . blob as any ) . toString ( "base64" )
254+ ? // eslint-disable-next-line @typescript-eslint/no-explicit-any
255+ Buffer . from ( content . blob as any ) . toString ( "base64" )
255256 : undefined ,
256257 encoding : content . blob ? "base64" : undefined ,
257258 filename : content . uri ,
@@ -297,6 +298,7 @@ export class McpClientManager extends EventTarget implements AsyncDisposable {
297298 name : toolId ,
298299 arguments : args ,
299300 } ,
301+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
300302 responseSchema as any ,
301303 {
302304 signal,
@@ -320,15 +322,15 @@ export class McpClientManager extends EventTarget implements AsyncDisposable {
320322 readResource,
321323 dispose,
322324 [ Symbol . asyncDispose ] : dispose ,
323- } satisfies McpClientProxy ) ;
325+ } satisfies McpClient ) ;
324326 this . _clients . push ( res ) ;
325327 return res ;
326328 } finally {
327329 trace ?. endDetails ( ) ;
328330 }
329331 }
330332
331- get clients ( ) : McpClientProxy [ ] {
333+ get clients ( ) : McpClient [ ] {
332334 return this . _clients . slice ( 0 ) ;
333335 }
334336
0 commit comments