1.1 KiB
1.1 KiB
更新你的 MCP 配置
现在,让我们在 src/mastra/agents/index.ts 中更新你的 MCP 配置,以包含 Filesystem 服务器:
import path from "path";
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"],
},
textEditor: {
command: "pnpx",
args: [
`@modelcontextprotocol/server-filesystem`,
path.join(process.cwd(), "..", "..", "notes"), // relative to output directory
],
},
},
});
此配置告诉 MCP 使用 PNPX 运行 Filesystem 服务器,指向我们创建的 "notes" 目录。path.join(process.cwd(), "notes") 确保无论从何处运行应用程序,路径都是正确的。
textEditor 键是此服务器在你的配置中的唯一标识符。command 属性指定我们想要使用 PNPX 来运行服务器,args 属性提供传递给 PNPX 的参数,包括包名和笔记目录的路径。