使用说明
MCP人工智能代理
一个使用模型上下文协议(MCP)的AI代理,该代理将Google Gemini与外部工具(如Twitter发帖和计算功能)连接起来。
特点/特性
- 与Gemini AI进行自然语言交互
- 通过对话指令发布推文
- 数学运算
- 通过MCP轻松扩展工具
快速入门
安装依赖项
npm install
配置环境
创建 .env:
GENAI_API_KEY=your_google_ai_api_key
TWITTER_API_KEY=your_api_key
TWITTER_API_SECRET=your_api_secret
TWITTER_ACCESS_TOKEN=your_access_token
TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret
跑
# Terminal 1 - Start server
node server/index.js
# Terminal 2 - Start client
node client/index.js
使用方法
You: What is 25 plus 17?
AI: The sum of 25 and 17 is 42.
You: Tweet "Hello from my AI agent!"
AI: Successfully posted! Tweet ID: 1234567890
项目结构
├── client/index.js # MCP Client + Gemini
├── server/index.js # MCP Server + Tools
└── server/mcp.tool.js # Twitter integration
添加工具
server.tool("toolName", "Description", { param: z.string() }, async (args) => {
// Your logic here
return { content: [{ type: "text", text: "Result" }] };
});
