|
| 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) ,[](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 | + |
| 157 | + |
| 158 | +After clicking on the hammer icon, you should see the tools that come with the Filesystem MCP Server: |
| 159 | + |
| 160 | + |
| 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 | + |
0 commit comments