11import { basename } from 'node:path'
22import { Client } from '@modelcontextprotocol/sdk/client/index.js'
33import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'
4- import {
5- CallToolResultSchema ,
6-
7- } from '@modelcontextprotocol/sdk/types.js'
4+ import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js'
85import type {
96 Item ,
107 ItemsParams ,
@@ -94,12 +91,12 @@ class MCPToolsProxy implements Provider {
9491 for ( const tool of tools ) {
9592 // Store the schema in the Map using tool name as key
9693 this . toolSchemas . set ( tool . name , JSON . stringify ( tool . inputSchema ) )
97-
94+
9895 const r = {
9996 uri : tool . uri ,
10097 title : tool . name ,
10198 description : tool . description ,
102- data : ( tool . inputSchema ) ,
99+ data : tool . inputSchema ,
103100 } as Mention
104101 mentions . push ( r )
105102 }
@@ -147,7 +144,9 @@ class MCPToolsProxy implements Provider {
147144 const isValid = this . ajv . validate ( schema , toolInput )
148145 if ( ! isValid ) {
149146 console . error ( 'Invalid tool input:' , this . ajv . errors )
150- throw new Error ( `Invalid input for tool ${ toolName } : ${ JSON . stringify ( this . ajv . errors ) } ` )
147+ throw new Error (
148+ `Invalid input for tool ${ toolName } : ${ JSON . stringify ( this . ajv . errors ) } ` ,
149+ )
151150 }
152151 }
153152 }
@@ -156,14 +155,14 @@ class MCPToolsProxy implements Provider {
156155 const response = await mcpClient . request (
157156 {
158157 method : 'tools/call' as const ,
159- params : {
158+ params : {
160159 name : toolName ,
161- arguments : toolInput
160+ arguments : toolInput ,
162161 } ,
163162 } ,
164163 CallToolResultSchema ,
165164 )
166-
165+
167166 const contents = response . content
168167 const items : Item [ ] = [ ]
169168 for ( const content of contents ) {
@@ -190,6 +189,5 @@ class MCPToolsProxy implements Provider {
190189 }
191190}
192191
193-
194192const proxy = new MCPToolsProxy ( )
195193export default proxy
0 commit comments