import { Agent } from '@agenite/agent';
import { OllamaProvider } from '@agenite/ollama';
import { MCPClient } from '@agenite/mcp';
import { prettyLogger } from '@agenite/pretty-logger';
async function main() {
// Initialize MCP client
const mcpClient = new MCPClient({
name: 'web-research-agent',
mcpServers: {
fetch: {
url: 'https://router.mcp.so/sse/rrrcnqm8s6mf5l',
},
},
});
try {
// Get all tools from MCP servers
console.log('Fetching tools from MCP servers...');
const tools = await mcpClient.getAllTools();
console.log(`Found ${tools.length} tools`);
// Create the agent
const agent = new Agent({
name: 'web-research-agent',
provider: new OllamaProvider({
model: 'llama3.2',
baseURL: 'http://localhost:11434',
}),
tools: tools,
instructions: `
You are a web research assistant that can search and retrieve information from the web.
When asked about current events, facts, or online content, use the fetch tools to get accurate information.
Always cite your sources by providing the URLs you retrieved information from.
For complex queries, break down your research into multiple steps and explain your approach.
`,
middlewares: [prettyLogger()],
});
// Example research question
const result = await agent.execute({
messages: [
{
role: 'user',
content: [
{
type: 'text',
text: 'What is Agenite and what are its main features? Please research and provide a summary.'
},
],
},
],
});
// Print the result
if (result.messages.length > 0) {
const lastMessage = result.messages[result.messages.length - 1];
if (lastMessage) {
console.log('Research results:', lastMessage.content);
}
}
} catch (error) {
console.error('Error during research:', error);
}
}
main().catch((error) => {
console.error('Error:', error);
process.exit(1);
});