translation/translated/documents/course/02-agent-tools-mcp/20-updating-mcp-config-hack...

27 lines
969 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 更新您的 MCP 配置
与使用 URL 的前一个 MCP 服务器不同Hacker News MCP 服务器可以直接使用 NPX 运行。这意味着我们不需要设置任何外部服务或身份验证。
让我们更新 `src/mastra/agents/index.ts` 中的 MCP 配置以包含 Hacker News 服务器:
```typescript
const mcp = new MCPClient({
servers: {
zapier: {
url: new URL(process.env.ZAPIER_MCP_URL || ""),
},
github: {
url: new URL(process.env.COMPOSIO_MCP_GITHUB || ""),
},
hackernews: {
command: "npx",
args: ["-y", "@devabdultech/hn-mcp-server"],
},
},
});
```
此配置告诉 MCP 在需要时使用 NPX 运行 Hacker News 服务器。`-y` 标志自动确认任何提示,使其使用无缝。
与通过 URL 连接到外部服务的 Zapier 和 GitHub 服务器不同Hacker News 服务器使用 NPX 在本地运行。这种方法更简单,因为它不需要任何身份验证或外部服务设置。