Skip to content

Commit ba6dffe

Browse files
committed
add perplexity-ask
1 parent d3b9c8c commit ba6dffe

9 files changed

Lines changed: 533 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ MCP 协议中有 STDIO 与 SSE 两种传输机制,大致如下:
4040
- quickchart: [start-mcp-quickchart](./start-mcp-quickchart/src)
4141
- firecrawl: [start-mcp-firecrawl](./start-mcp-firecrawl/src)
4242
- agentql: [start-mcp-agentql](./start-mcp-agentql/src)
43+
- Perplexity Ask: [start-mcp-perplexity-ask](./start-mcp-perplexity-ask/src)
4344

4445
其中有 hello-world 示例:
4546

start-mcp-perplexity-ask/README.md

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
2+
> 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验)
3+
4+
# start-mcp-perplexity-ask 帮助文档
5+
6+
<description>
7+
8+
Perplexity Ask MCP Server
9+
10+
</description>
11+
12+
13+
## 资源准备
14+
15+
使用该项目,您需要有开通以下服务并拥有对应权限:
16+
17+
<service>
18+
19+
20+
21+
| 服务/业务 | 权限 | 相关文档 |
22+
| --- | --- | --- |
23+
| 函数计算 | AliyunFCFullAccess | [帮助文档](https://help.aliyun.com/product/2508973.html) [计费文档](https://help.aliyun.com/document_detail/2512928.html) |
24+
25+
</service>
26+
27+
<remark>
28+
29+
30+
31+
</remark>
32+
33+
<disclaimers>
34+
35+
36+
37+
</disclaimers>
38+
39+
## 部署 & 体验
40+
41+
<appcenter>
42+
43+
- :fire: 通过 [云原生应用开发平台 CAP](https://cap.console.aliyun.com/template-detail?template=start-mcp-perplexity-ask)[![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://cap.console.aliyun.com/template-detail?template=start-mcp-perplexity-ask) 该应用。
44+
45+
</appcenter>
46+
<deploy>
47+
48+
49+
</deploy>
50+
51+
## 案例介绍
52+
53+
<appdetail id="flushContent">
54+
55+
# Perplexity Ask MCP Server
56+
57+
An MCP server implementation that integrates the Sonar API to provide Claude with unparalleled real-time, web-wide research.
58+
59+
60+
## Tools
61+
62+
- **perplexity_ask**
63+
- Engage in a conversation with the Sonar API for live web searches.
64+
- **Inputs:**
65+
- `messages` (array): An array of conversation messages.
66+
- Each message must include:
67+
- `role` (string): The role of the message (e.g., `system`, `user`, `assistant`).
68+
- `content` (string): The content of the message.
69+
70+
## Configuration
71+
72+
### Step 1:
73+
74+
Clone this repository:
75+
76+
```bash
77+
git clone git@github.com:ppl-ai/modelcontextprotocol.git
78+
```
79+
80+
Navigate to the `perplexity-ask` directory and install the necessary dependencies:
81+
82+
```bash
83+
cd modelcontextprotocol/perplexity-ask && npm install
84+
```
85+
86+
### Step 2: Get a Sonar API Key
87+
88+
1. Sign up for a [Sonar API account](https://docs.perplexity.ai/guides/getting-started).
89+
2. Follow the account setup instructions and generate your API key from the developer dashboard.
90+
3. Set the API key in your environment as `PERPLEXITY_API_KEY`.
91+
92+
### Step 3: Configure Claude Desktop
93+
94+
1. Download Claude desktop [here](https://claude.ai/download).
95+
96+
2. Add this to your `claude_desktop_config.json`:
97+
98+
```json
99+
{
100+
"mcpServers": {
101+
"perplexity-ask": {
102+
"command": "docker",
103+
"args": [
104+
"run",
105+
"-i",
106+
"--rm",
107+
"-e",
108+
"PERPLEXITY_API_KEY",
109+
"mcp/perplexity-ask"
110+
],
111+
"env": {
112+
"PERPLEXITY_API_KEY": "YOUR_API_KEY_HERE"
113+
}
114+
}
115+
}
116+
}
117+
```
118+
119+
### NPX
120+
121+
```json
122+
{
123+
"mcpServers": {
124+
"perplexity-ask": {
125+
"command": "npx",
126+
"args": [
127+
"-y",
128+
"server-perplexity-ask"
129+
],
130+
"env": {
131+
"PERPLEXITY_API_KEY": "YOUR_API_KEY_HERE"
132+
}
133+
}
134+
}
135+
}
136+
```
137+
138+
You can access the file using:
139+
140+
```bash
141+
vim ~/Library/Application\ Support/Claude/claude_desktop_config.json
142+
```
143+
144+
### Step 4: Build the Docker Image
145+
146+
Docker build:
147+
148+
```bash
149+
docker build -t mcp/perplexity-ask:latest -f Dockerfile .
150+
```
151+
152+
### Step 5: Testing
153+
154+
Let's make sure Claude for Desktop is picking up the two tools we've exposed in our `perplexity-ask` server. You can do this by looking for the hammer icon:
155+
156+
![Claude Visual Tools](perplexity-ask/assets/visual-indicator-mcp-tools.png)
157+
158+
After clicking on the hammer icon, you should see the tools that come with the Filesystem MCP Server:
159+
160+
![Available Integration](perplexity-ask/assets/available_tools.png)
161+
162+
If you see both of these this means that the integration is active. Congratulations! This means Claude can now ask Perplexity. You can then simply use it as you would use the Perplexity web app.
163+
164+
### Step 6: Advanced parameters
165+
166+
Currently, the search parameters used are the default ones. You can modify any search parameter in the API call directly in the `index.ts` script. For this, please refer to the official [API documentation](https://docs.perplexity.ai/api-reference/chat-completions).
167+
168+
### Troubleshooting
169+
170+
The Claude documentation provides an excellent [troubleshooting guide](https://modelcontextprotocol.io/docs/tools/debugging) you can refer to. However, you can still reach out to us at api@perplexity.ai for any additional support or [file a bug](https://github.com/ppl-ai/api-discussion/issues).
171+
172+
173+
## License
174+
175+
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
176+
177+
</appdetail>
178+
179+
180+
181+
182+
183+
184+
185+
## 使用流程
186+
187+
<usedetail id="flushContent">
188+
189+
部署完成拿到 URL 后,准备好支持 SSE 的 MCP Client,通过 SSETransport 进行连接。
190+
191+
</usedetail>
192+
193+
194+
195+
196+
197+
198+
199+
200+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
async function preInit(inputObj) {
2+
3+
}
4+
5+
async function postInit(inputObj) {
6+
7+
}
8+
9+
module.exports = {
10+
postInit,
11+
preInit
12+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Edition: 3.0.0
2+
Type: Project
3+
Name: start-mcp-perplexity-ask
4+
Version: dev
5+
Provider:
6+
- 阿里云 # 取值内容参考:https://api.devsapp.cn/v3/common/args.html
7+
Description: Perplexity Ask MCP Server
8+
HomePage: https://github.com/ppl-ai/modelcontextprotocol
9+
Tags: #标签详情
10+
- MCP
11+
- Serverless Devs
12+
Category: Others # 取值内容参考:https://api.devsapp.cn/v3/common/args.html
13+
Service: # 使用的服务
14+
函数计算: # 取值内容参考:https://api.devsapp.cn/v3/common/args.html
15+
Authorities: #权限描述
16+
- AliyunFCFullAccess # 所需要的权限,例如AliyunFCFullAccess
17+
Organization: 阿里云函数计算(FC) # 所属组织
18+
Effective: Public # 是否公开,取值:Public,Private,Organization
19+
Parameters:
20+
type: object
21+
additionalProperties: false # 不允许增加其他属性
22+
required: # 必填项
23+
- region
24+
- functionName
25+
- PERPLEXITY_API_KEY
26+
properties:
27+
region:
28+
title: 地域
29+
type: string
30+
default: cn-hangzhou
31+
description: 创建应用所在的地区
32+
enum:
33+
- cn-beijing
34+
- cn-hangzhou
35+
- cn-shanghai
36+
- cn-shenzhen
37+
- ap-southeast-1
38+
functionName:
39+
title: 函数名
40+
type: string
41+
default: mcp-server-${default-suffix}
42+
pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$"
43+
description: 应用的函数名称, 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间
44+
PERPLEXITY_API_KEY:
45+
title: PERPLEXITY_API_KEY
46+
type: string
47+
default: ''
48+
sensitive: 'true'
49+
description: 获取 Sonar API Key,请参考 https://docs.perplexity.ai/guides/getting-started
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
start-mcp-server:
2+
default:
3+
languages:
4+
- nodejs20
5+
cache:
6+
paths:
7+
- "~/.npm"
8+
steps:
9+
- run: npm install
10+
path: ./code
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"server-perplexity-ask": "^0.1.3"
4+
}
5+
}

0 commit comments

Comments
 (0)