Skip to content

Commit 8d58bfa

Browse files
authored
fix: stdio and streamable http client examples (#106)
fix stdio and streamable http client examples
1 parent 33ead78 commit 8d58bfa

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/examples/clientStdio.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@ async function run() {
7676
CallToolResultSchema,
7777
);
7878
console.log('Tool result:', JSON.stringify(result));
79+
80+
await client.close();
7981
} catch (error) {
8082
console.error('Error:', error);
8183
}
8284
}
8385

8486
run().catch((error) => {
85-
console.error('Unhandled error:', error);
87+
console.error(`Error running MCP client: ${error as Error}`);
8688
process.exit(1);
8789
});

src/examples/clientStreamableHttp.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99

1010
import log from '@apify/log';
1111

12+
import { HelperTools } from '../const.js';
13+
1214
log.setLevel(log.LEVELS.DEBUG);
1315

1416
async function main(): Promise<void> {
@@ -65,7 +67,7 @@ async function callSearchTool(client: Client): Promise<void> {
6567
const searchRequest: CallToolRequest = {
6668
method: 'tools/call',
6769
params: {
68-
name: 'search',
70+
name: HelperTools.SEARCH_ACTORS,
6971
arguments: { search: 'rag web browser', limit: 1 },
7072
},
7173
};
@@ -104,6 +106,6 @@ async function callActor(client: Client): Promise<void> {
104106
}
105107

106108
main().catch((error: unknown) => {
107-
log.error('Error running MCP client:', error as Error);
109+
log.error(`Error running MCP client: ${error as Error}`);
108110
process.exit(1);
109111
});

0 commit comments

Comments
 (0)