@@ -4,6 +4,7 @@ import { McpTool, Metadata, ToolCallResult, asErrorResult, asTextContentResult }
44import { Tool } from '@modelcontextprotocol/sdk/types.js' ;
55import { readEnv , readEnvOrError } from './server' ;
66import { WorkerInput , WorkerOutput } from './code-tool-types' ;
7+ import { ImageKit } from '@imagekit/nodejs' ;
78
89const prompt = `Runs JavaScript code to interact with the Image Kit API.
910
@@ -54,7 +55,7 @@ export function codeTool(): McpTool {
5455 required : [ 'code' ] ,
5556 } ,
5657 } ;
57- const handler = async ( _ : unknown , args : any ) : Promise < ToolCallResult > => {
58+ const handler = async ( client : ImageKit , args : any ) : Promise < ToolCallResult > => {
5859 const code = args . code as string ;
5960 const intent = args . intent as string | undefined ;
6061
@@ -70,10 +71,11 @@ export function codeTool(): McpTool {
7071 ...( stainlessAPIKey && { Authorization : stainlessAPIKey } ) ,
7172 'Content-Type' : 'application/json' ,
7273 client_envs : JSON . stringify ( {
73- IMAGEKIT_PRIVATE_KEY : readEnvOrError ( 'IMAGEKIT_PRIVATE_KEY' ) ,
74- OPTIONAL_IMAGEKIT_IGNORES_THIS : readEnv ( 'OPTIONAL_IMAGEKIT_IGNORES_THIS' ) ,
75- IMAGEKIT_WEBHOOK_SECRET : readEnv ( 'IMAGEKIT_WEBHOOK_SECRET' ) ,
76- IMAGE_KIT_BASE_URL : readEnv ( 'IMAGE_KIT_BASE_URL' ) ,
74+ IMAGEKIT_PRIVATE_KEY : readEnvOrError ( 'IMAGEKIT_PRIVATE_KEY' ) ?? client . privateKey ?? undefined ,
75+ OPTIONAL_IMAGEKIT_IGNORES_THIS :
76+ readEnv ( 'OPTIONAL_IMAGEKIT_IGNORES_THIS' ) ?? client . password ?? undefined ,
77+ IMAGEKIT_WEBHOOK_SECRET : readEnv ( 'IMAGEKIT_WEBHOOK_SECRET' ) ?? client . webhookSecret ?? undefined ,
78+ IMAGE_KIT_BASE_URL : readEnv ( 'IMAGE_KIT_BASE_URL' ) ?? client . baseURL ?? undefined ,
7779 } ) ,
7880 } ,
7981 body : JSON . stringify ( {
0 commit comments