使用说明
困惑MCP服务器
由Perplexity的专业人工智能模型驱动的智能研究助理。具有自动查询复杂性检测功能,可将请求路由到最合适的模型以获得最佳结果。与官方服务器不同,它具有对每项任务的搜索功能,本质上
它还迫使使用MCP的代理具有特定性
工具
1.搜索(Sonar Pro)
快速搜索简单查询和基本信息查找。最适合需要简洁、直接答案的直截了当的问题。
const result = await use_mcp_tool({
server_name: "perplexity",
tool_name: "search",
arguments: {
query: "What is the capital of France?",
force_model: false // Optional: force using this model even if query seems complex
}
});
2.原因(Sonar Reasoning Pro)
处理需要详细分析的复杂、多步骤任务。非常适合解释、比较和解决问题。
const result = await use_mcp_tool({
server_name: "perplexity",
tool_name: "reason",
arguments: {
query: "Compare and contrast REST and GraphQL APIs, explaining their pros and cons",
force_model: false // Optional: force using this model even if query seems simple
}
});
3.深度研究(声纳深度研究)
进行全面的研究并生成详细的报告。非常适合对复杂主题进行深入分析。
const result = await use_mcp_tool({
server_name: "perplexity",
tool_name: "deep_research",
arguments: {
query: "The impact of quantum computing on cryptography",
focus_areas: [
"Post-quantum cryptographic algorithms",
"Timeline for quantum threats",
"Practical mitigation strategies"
],
force_model: false // Optional: force using this model even if query seems simple
}
});
设置
-
先决条件
- Node.js(来自 nodejs.org)
- 困惑API密钥(来自 困惑.ai/settings/api)
- 将repo克隆到某个地方
-
配置MCP设置
添加到MCP设置文件中(位置因平台而异):
{
"mcpServers": {
"perplexity": {
"command": "node",
"args": ["/path/to/perplexity-server/build/index.js"],
"env": {
"PERPLEXITY_API_KEY": "YOUR_API_KEY_HERE"
},
"disabled": false,
"autoApprove": []
}
}
}
或者使用NPX不必在本地安装(建议用于macos):
{
"mcpServers": {
"perplexity": {
"command": "npx",
"args": [
"-y",
"perplexity-mcp"
],
"env": {
"PERPLEXITY_API_KEY": "your_api_key"
}
}
}
}
如果MCP客户端无法从
使用以下方法的环境 "${env:PERPLEXITY_API_KEY}" 现代常见
AI编码代理(例如Kiro),有两种后备解决方案:
命令行参数:直接将API键作为命令行参数传递,您甚至可以尝试查看“${env:PERPLEXITY_API_key}”是否在其中工作。
{
"mcpServers": {
"perplexity": {
"command": "node",
"args": [
"/path/to/perplexity-server/build/index.js",
"--api-key",
"your_api_key_here"
],
"disabled": false,
"autoApprove": []
}
}
}
阅读明确的 .env 文件:指定项目的位置 .env 带有环境变量和当前项目的API键的文件 --cwd 命令行参数,MCP服务器将读取 .env 从目录中找到Perplexity API密钥。
{
"mcpServers": {
"perplexity": {
"command": "node",
"args": [
"/path/to/perplexity-server/build/index.js",
"--cwd",
"/path/to/your/project"
],
"disabled": false,
"autoApprove": []
}
}
}
优先顺序:命令行参数>环境变量>.env文件 --cwd (需要路径)