import { config } from 'dotenv';
import { ChatOpenAI } from '@langchain/openai';
import { MCPAgent, MCPClient } from 'easy-mcp-use';
async function main() {
config();
const mcpConfig = {
mcpServers: {
playwright: {
command: 'npx',
args: ['@playwright/mcp@latest'],
env: {
DISPLAY: ':1'
},
allowedTools: ['navigate', 'click'] // Only allow these tools
}
}
};
const client = MCPClient.fromDict(mcpConfig);
const llm = new ChatOpenAI({ modelName: 'gpt-4' });
const agent = new MCPAgent({ llm, client });
const result = await agent.run(
'Navigate to example.com and click the first link'
);
console.log('\nResult:', result);
}
main().catch(console.error);