Skip to content

Commit 5233088

Browse files
committed
Fix clientStdio.ts for win
1 parent 1e7d6f8 commit 5233088

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/examples/clientStdio.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@
66
*/
77

88
import { execSync } from 'child_process';
9+
import path from 'path';
10+
import { fileURLToPath } from 'url';
911

1012
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
1113
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
1214
import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';
13-
import path from 'path';
1415
import dotenv from 'dotenv';
1516

16-
dotenv.config({ path: path.resolve(__dirname, '../../.env') });
17+
// Resolve dirname equivalent in ES module
18+
const filename = fileURLToPath(import.meta.url);
19+
const dirname = path.dirname(filename);
1720

18-
const SERVER_PATH = path.resolve(__dirname, '../../dist/index.js');
21+
dotenv.config({ path: path.resolve(dirname, '../../.env') });
22+
const SERVER_PATH = path.resolve(dirname, '../../dist/index.js');
1923
const NODE_PATH = execSync(process.platform === 'win32' ? 'where node' : 'which node').toString().trim();
2024

2125
const TOOLS = 'apify/rag-web-browser,lukaskrivka/google-maps-with-contact-details';
22-
const SELECTED_TOOL = 'apify/rag-web-browser';
26+
const SELECTED_TOOL = 'apify_rag-web-browser'; // We need to change / to _ in the tool name
2327

2428
if (!process.env.APIFY_API_TOKEN) {
2529
console.error('APIFY_API_TOKEN is required but not set in the environment variables.');
@@ -65,7 +69,7 @@ async function run() {
6569
// Call a tool
6670
console.log('Calling actor ...');
6771
const result = await client.callTool(
68-
{ name: 'apify/rag-web-browser', arguments: { query: 'web browser for Anthropic' } },
72+
{ name: SELECTED_TOOL, arguments: { query: 'web browser for Anthropic' } },
6973
CallToolResultSchema,
7074
);
7175
console.log('Tool result:', JSON.stringify(result));

0 commit comments

Comments
 (0)