@@ -4,6 +4,7 @@ import { McpTool, Metadata, ToolCallResult, asErrorResult, asTextContentResult }
44import { Tool } from '@modelcontextprotocol/sdk/types.js' ;
55import { readEnv } from './server' ;
66import { WorkerInput , WorkerOutput } from './code-tool-types' ;
7+ import { Finch } from '@tryfinch/finch-api' ;
78
89const prompt = `Runs JavaScript code to interact with the Finch API.
910
@@ -55,7 +56,7 @@ export function codeTool(): McpTool {
5556 required : [ 'code' ] ,
5657 } ,
5758 } ;
58- const handler = async ( _ : unknown , args : any ) : Promise < ToolCallResult > => {
59+ const handler = async ( client : Finch , args : any ) : Promise < ToolCallResult > => {
5960 const code = args . code as string ;
6061 const intent = args . intent as string | undefined ;
6162
@@ -71,10 +72,10 @@ export function codeTool(): McpTool {
7172 ...( stainlessAPIKey && { Authorization : stainlessAPIKey } ) ,
7273 'Content-Type' : 'application/json' ,
7374 client_envs : JSON . stringify ( {
74- FINCH_CLIENT_ID : readEnv ( 'FINCH_CLIENT_ID' ) ,
75- FINCH_CLIENT_SECRET : readEnv ( 'FINCH_CLIENT_SECRET' ) ,
76- FINCH_WEBHOOK_SECRET : readEnv ( 'FINCH_WEBHOOK_SECRET' ) ,
77- FINCH_BASE_URL : readEnv ( 'FINCH_BASE_URL' ) ,
75+ FINCH_CLIENT_ID : readEnv ( 'FINCH_CLIENT_ID' ) ?? client . clientID ?? undefined ,
76+ FINCH_CLIENT_SECRET : readEnv ( 'FINCH_CLIENT_SECRET' ) ?? client . clientSecret ?? undefined ,
77+ FINCH_WEBHOOK_SECRET : readEnv ( 'FINCH_WEBHOOK_SECRET' ) ?? client . webhookSecret ?? undefined ,
78+ FINCH_BASE_URL : readEnv ( 'FINCH_BASE_URL' ) ?? client . baseURL ?? undefined ,
7879 } ) ,
7980 } ,
8081 body : JSON . stringify ( {
0 commit comments