Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/examples/clientStdio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ async function run() {
CallToolResultSchema,
);
console.log('Tool result:', JSON.stringify(result));

await client.close();
} catch (error) {
console.error('Error:', error);
}
}

run().catch((error) => {
console.error('Unhandled error:', error);
console.error(`Error running MCP client: ${error as Error}`);
process.exit(1);
});
6 changes: 4 additions & 2 deletions src/examples/clientStreamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {

import log from '@apify/log';

import { HelperTools } from '../const.js';

log.setLevel(log.LEVELS.DEBUG);

async function main(): Promise<void> {
Expand Down Expand Up @@ -65,7 +67,7 @@ async function callSearchTool(client: Client): Promise<void> {
const searchRequest: CallToolRequest = {
method: 'tools/call',
params: {
name: 'search',
name: HelperTools.SEARCH_ACTORS,
arguments: { search: 'rag web browser', limit: 1 },
},
};
Expand Down Expand Up @@ -104,6 +106,6 @@ async function callActor(client: Client): Promise<void> {
}

main().catch((error: unknown) => {
log.error('Error running MCP client:', error as Error);
log.error(`Error running MCP client: ${error as Error}`);
process.exit(1);
});