使用说明
困惑mcp
一个模型上下文协议(MCP)服务器,为网络搜索、推理和深入研究提供困惑人工智能工具。
特性
工具
5个用于直接访问API的困惑人工智能工具:
- 困惑_问题 -带引文的快速网络搜索
- 困惑原因 -逐步推理和解决问题
- 困惑_搜索_开始 -启动异步深度研究(返回request_id)
- 困惑_搜索_结果 -检查异步研究状态
- 困惑_搜索_等待 -阻止等待异步研究完成
提示
10个内置最佳实践的现成提示:
研究
- 研究 -深度研究,广度优先
- 比较 -功能对比与权衡
- 验证 -多视角分析的事实核查
- 状态 -现状及近期发展
技术的
- 文档 -图书馆文件和示例
- 错误 -错误解决方案和解决方法
- 安全 -CVE和漏洞检查
实用
- 如何 -循序渐进的程序指南
- 新闻 -最近的事态发展和公告
- 学术 -同行评审的研究结果
安装
Kubernetes/Helm
通过Helm安装用于生产部署:
# Add the Helm repository (OCI-based)
helm install perplexity-mcp oci://ghcr.io/mikluko/helm-charts/perplexity-mcp \
--version 0.2.1 \
--set perplexity.apiKey="pplx-xxxxxxxxxxxx"
使用基本身份验证
启用内置Traefik sidecar进行基本身份验证保护:
helm install perplexity-mcp oci://ghcr.io/mikluko/helm-charts/perplexity-mcp \
--set perplexity.apiKey="pplx-xxxxxxxxxxxx" \
--set auth.enabled=true \
--set auth.username=admin \
--set auth.password="your-secure-password"
或者使用预先生成的htpasswd条目(建议用于GitOps):
# Generate htpasswd entry
HTPASSWD=$(docker run --rm httpd:alpine htpasswd -nbB admin your-password)
# Install with htpasswd entry
helm install perplexity-mcp oci://ghcr.io/mikluko/helm-charts/perplexity-mcp \
--set perplexity.apiKey="pplx-xxxxxxxxxxxx" \
--set auth.enabled=true \
--set-string auth.htpasswd="$HTPASSWD"
外部秘密
将现有的Kubernetes机密用于API密钥:
# Create secret separately
kubectl create secret generic my-perplexity-secret \
--from-literal=api-key="pplx-xxxxxxxxxxxx"
# Install referencing the secret
helm install perplexity-mcp oci://ghcr.io/mikluko/helm-charts/perplexity-mcp \
--set perplexity.existingSecret.name=my-perplexity-secret \
--set perplexity.existingSecret.key=api-key
与Ingress
启用外部访问入口:
helm install perplexity-mcp oci://ghcr.io/mikluko/helm-charts/perplexity-mcp \
--set perplexity.apiKey="pplx-xxxxxxxxxxxx" \
--set auth.enabled=true \
--set auth.password="your-secure-password" \
--set ingress.enabled=true \
--set ingress.className=nginx \
--set ingress.hosts[0].host=perplexity-mcp.example.com \
--set ingress.hosts[0].paths[0].path=/ \
--set ingress.hosts[0].paths[0].pathType=Prefix
二进制安装
在本地安装以进行开发或stdio模式:
go install github.com/mikluko/perplexity-mcp@latest
或者从源代码构建:
git clone https://github.com/mikluko/perplexity-mcp.git
cd perplexity-mcp
go build -o perplexity-mcp .
配置
将您的困惑API键设置为环境变量:
export PERPLEXITY_API_KEY=pplx-xxxxxxxxxxxx
从获取API密钥 困惑AI.
用法
标准模式(本地)
用于Claude Desktop、Cursor或其他本地MCP客户端:
perplexity-mcp -mode stdio
HTTP模式(远程)
对于通过HTTP进行远程访问:
perplexity-mcp -mode http -listen :8080
默认监听地址为 :8080。服务器不包括身份验证-部署在具有适当安全控制的反向代理后面。
客户端配置
克劳德桌面
增添 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"perplexity": {
"command": "perplexity-mcp",
"args": ["-mode", "stdio"],
"env": {
"PERPLEXITY_API_KEY": "pplx-xxxxxxxxxxxx"
}
}
}
}
光标
添加到光标设置→ MCP服务器:
{
"mcpServers": {
"perplexity": {
"command": "perplexity-mcp",
"args": ["-mode", "stdio"],
"env": {
"PERPLEXITY_API_KEY": "pplx-xxxxxxxxxxxx"
}
}
}
}
远程HTTP服务器
要访问远程HTTP服务器,请使用以下配置MCP客户端:
{
"mcpServers": {
"perplexity": {
"url": "http://your-server:8080"
}
}
}
安全说明:部署HTTP服务器时:
- 对于Kubernetes部署:使用内置的Traefik sidecar
auth.enabled=true - 对于独立部署:使用网络级控制(防火墙、VPN)或反向代理身份验证进行保护
- 在生产环境中始终使用TLS/HTTPS
该二进制文件故意不包含内置身份验证,以保持轻量级。Helm chart通过Traefik sidecar提供可选的基本身份验证。
工具参考
困惑_问题
使用Sonar型号进行快速网络搜索。
输入:
{
"query": "What is the latest news about AI?"
}
输出: 引用答案
困惑原因
使用声纳推理模型进行逐步推理。
输入:
{
"query": "How do I solve this math problem: ..."
}
输出: 带有结论的推理链
困惑_搜索_开始
开始异步深入研究。
输入:
{
"query": "Comprehensive analysis of renewable energy trends"
}
输出: 用于跟踪的请求ID
困惑_搜索_结果
检查异步研究的状态。
输入:
{
"request_id": "req_xxxxxxxxxxxx"
}
输出: 状态和结果(如果已完成)
困惑_搜索_等待
等待异步研究完成(阻塞,超时)。
输入:
{
"request_id": "req_xxxxxxxxxxxx",
"timeout": 300
}
输出: 研究成果完成时
提示参考
提示提供具有最佳提示模式的现成模板。所有提示都使用最少的系统指令,并将上下文放入用户消息中。
研究
深度研究,广度优先。
论据:
topic(必填)-研究主题timeframe(可选)-时间段,默认为“过去12个月”
例子:
topic: "quantum computing advances"
timeframe: "last 6 months"
比较
通过特征分析比较两个项目。
论据:
item_a(必填)-第一项item_b(必填)-第二项use_case(可选)-特定用例上下文
例子:
item_a: "PostgreSQL"
item_b: "MySQL"
use_case: "high-traffic web applications"
验证
用支持和反驳的证据对索赔进行事实核查。
论据:
claim(必填)-要求核实
例子:
claim: "Coffee consumption reduces risk of type 2 diabetes"
错误
查找错误消息的解决方案。
论据:
error_message(必填)-错误文本technology(必填)-技术/框架背景
例子:
error_message: "ECONNREFUSED connect ECONNREFUSED 127.0.0.1:5432"
technology: "Node.js PostgreSQL"
安全
检查CVE漏洞。
论据:
package(必填)-包名称date(可选)-开始日期(YYYY-MM-DD),默认为1年前
例子:
package: "log4j"
date: "2024-01-01"
查看所有10个提示 mcp list-prompts 或者在MCP客户端的提示选择器中。
发展
运行测试
# Run all tests
go test ./...
# Run tests with verbose output
go test ./... -v
# Run tests with coverage
go test ./... -cover
测试覆盖范围包括:
- 配置加载和验证
- 服务器初始化
- 客户端设置和状态处理
- 缺少API键和无效模式的错误处理
建筑
# Build for current platform
go build -o perplexity-mcp .
# Build for Linux
GOOS=linux GOARCH=amd64 go build -o perplexity-mcp .
# Build for macOS
GOOS=darwin GOARCH=arm64 go build -o perplexity-mcp .
本地运行
# Stdio mode (for testing with MCP clients)
export PERPLEXITY_API_KEY=pplx-xxxxxxxxxxxx
./perplexity-mcp -mode stdio
# HTTP mode (for testing HTTP interface)
export PERPLEXITY_API_KEY=pplx-xxxxxxxxxxxx
./perplexity-mcp -mode http -listen localhost:8080