File size: 1,476 Bytes
668d995 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | /**
* Automation script to navigate to Messenger and GitHub and list tabs
*/
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const serverPath = join(__dirname, 'dist', 'index.js');
async function automate() {
const transport = new StdioClientTransport({
command: 'node',
args: [serverPath],
});
const client = new Client(
{
name: 'automation-client',
version: '1.0.0',
},
{
capabilities: {},
}
);
await client.connect(transport);
console.log('Navigating to Messenger...');
await client.callTool({
name: 'web_navigate',
arguments: { url: 'https://www.messenger.com' },
});
console.log('Opening GitHub in a new tab...');
await client.callTool({
name: 'web_new_tab',
arguments: { url: 'https://github.com' },
});
console.log('Listing tabs...');
const result = await client.callTool({
name: 'web_list_tabs',
arguments: {},
});
console.log('RESULT:' + result.content[0].text);
await transport.close();
}
automate().catch((err) => {
console.error(err);
process.exit(1);
});
|