import { Agent } from "@mastra/core/agent";
import { openai } from "@ai-sdk/openai";
import { twexapiMcp } from "./mcp";
const tools = await twexapiMcp.listTools();
export const twexapiAgent = new Agent({
name: "twexapi-agent",
instructions: `
You help users interact with X/Twitter through Twexapi MCP.
Always call explore before twexapi_request.
Preserve tweet_id, user_id, route_used, has_more, and next_cursor.
Ask for approval before read_only: false actions.
`,
model: openai("gpt-4o-mini"),
tools,
});
const result = await twexapiAgent.generate(
"Search recent X posts about AI infrastructure. Return compact JSON with route_used, tweets, has_more, and next_cursor."
);
console.log(result.text);