@perplexity-ai/mcp-server 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,14 +6,14 @@
6
6
  },
7
7
  "metadata": {
8
8
  "description": "Official Perplexity AI plugin providing real-time web search, reasoning, and research capabilities",
9
- "version": "0.4.0"
9
+ "version": "0.5.0"
10
10
  },
11
11
  "plugins": [
12
12
  {
13
13
  "name": "perplexity",
14
14
  "source": "./",
15
15
  "description": "Real-time web search, reasoning, and research through Perplexity's API",
16
- "version": "0.4.0",
16
+ "version": "0.5.0",
17
17
  "author": {
18
18
  "name": "Perplexity AI",
19
19
  "email": "api@perplexity.ai"
package/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Perplexity API Platform MCP Server
2
2
 
3
- The official MCP server implementation for the Perplexity API Platform, providing AI assistants with real-time web search, reasoning, and research capabilities through Sonar models and the Search API.
3
+ [![Install in Cursor](https://custom-icon-badges.demolab.com/badge/Install_in_Cursor-000000?style=for-the-badge&logo=cursor-ai-white)](https://cursor.com/en/install-mcp?name=perplexity&config=eyJ0eXBlIjoic3RkaW8iLCJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBwZXJwbGV4aXR5LWFpL21jcC1zZXJ2ZXIiXX0=)
4
+  
5
+ [![Install in VS Code](https://custom-icon-badges.demolab.com/badge/Install_in_VS_Code-007ACC?style=for-the-badge&logo=vsc&logoColor=white)](https://vscode.dev/redirect/mcp/install?name=perplexity&config=%7B%22type%22%3A%22stdio%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40perplexity-ai%2Fmcp-server%22%5D%7D)
6
+  
7
+ [![npm version](https://img.shields.io/npm/v/%40perplexity-ai%2Fmcp-server?style=for-the-badge&logo=npm&logoColor=white&color=CB3837)](https://www.npmjs.com/package/@perplexity-ai/mcp-server)
4
8
 
5
- Please refer to the official [DeepWiki page](https://deepwiki.com/ppl-ai/modelcontextprotocol) for assistance with implementation.
9
+ The official MCP server implementation for the Perplexity API Platform, providing AI assistants with real-time web search, reasoning, and research capabilities through Sonar models and the Search API.
6
10
 
7
11
  ## Available Tools
8
12
 
@@ -34,9 +38,15 @@ Advanced reasoning and problem-solving using the `sonar-reasoning-pro` model. Pe
34
38
 
35
39
  #### Option 1: Install via Plugin (Recommended)
36
40
 
37
- The easiest way to get started with Perplexity in Claude Code:
38
-
41
+ The easiest way to get started with Perplexity in Claude Code, set your API key:
42
+ ```bash
43
+ export PERPLEXITY_API_KEY="your_key_here"
44
+ ```
45
+ Then:
39
46
  ```bash
47
+ # Open Claude Code
48
+ claude
49
+
40
50
  # Add the Perplexity marketplace
41
51
  /plugin marketplace add perplexityai/modelcontextprotocol
42
52
 
@@ -44,11 +54,6 @@ The easiest way to get started with Perplexity in Claude Code:
44
54
  /plugin install perplexity
45
55
  ```
46
56
 
47
- Then set your API key:
48
- ```bash
49
- export PERPLEXITY_API_KEY="your_key_here"
50
- ```
51
-
52
57
  #### Option 2: Manual Configuration
53
58
 
54
59
  Run in your terminal:
@@ -76,9 +81,9 @@ Or add to your `claude.json`:
76
81
  }
77
82
  ```
78
83
 
79
- ### Cursor
84
+ ### Cursor / VS Code
80
85
 
81
- Add to your `mcp.json`:
86
+ Add to your `mcp.json` (Cursor) or `.vscode/mcp.json` (VS Code):
82
87
 
83
88
  ```json
84
89
  {
@@ -95,6 +100,8 @@ Add to your `mcp.json`:
95
100
  }
96
101
  ```
97
102
 
103
+ Or use the one-click install badges at the top of this README.
104
+
98
105
  ### Codex
99
106
 
100
107
  Run in your terminal:
@@ -136,7 +143,7 @@ If you are running this server at work—especially behind a company firewall or
136
143
 
137
144
  **1. Get your proxy details**
138
145
 
139
- - Ask your IT department for your HTTP(S) proxy address and port.
146
+ - Ask your IT department for your HTTPS proxy address and port.
140
147
  - You may also need a username and password.
141
148
 
142
149
  **2. Set the proxy environment variable**
@@ -144,20 +151,56 @@ If you are running this server at work—especially behind a company firewall or
144
151
  The easiest and most reliable way for Perplexity MCP is to use `PERPLEXITY_PROXY`. For example:
145
152
 
146
153
  ```bash
147
- export PERPLEXITY_PROXY=http://your-proxy-host:8080
154
+ export PERPLEXITY_PROXY=https://your-proxy-host:8080
148
155
  ```
149
156
 
150
- - If your proxy needs a username and password, use:
151
- ```bash
152
- export PERPLEXITY_PROXY=http://username:password@your-proxy-host:8080
153
- ```
157
+ If your proxy needs a username and password, use:
158
+
159
+ ```bash
160
+ export PERPLEXITY_PROXY=https://username:password@your-proxy-host:8080
161
+ ```
154
162
 
155
163
  **3. Alternate: Standard environment variables**
156
164
 
157
165
  If you'd rather use the standard variables, we support `HTTPS_PROXY` and `HTTP_PROXY`.
158
166
 
159
167
  > [!NOTE]
160
- >The server checks proxy settings in this order: `PERPLEXITY_PROXY` → `HTTPS_PROXY` → `HTTP_PROXY`. If none are set, it connects directly to the internet.
168
+ > The server checks proxy settings in this order: `PERPLEXITY_PROXY` → `HTTPS_PROXY` → `HTTP_PROXY`. If none are set, it connects directly to the internet.
169
+ > URLs must include `https://`. Typical ports are `8080`, `3128`, and `80`.
170
+
171
+
172
+ ### HTTP Server Deployment
173
+
174
+ For cloud or shared deployments, you can run the server in HTTP mode:
175
+
176
+ #### Environment Variables
177
+
178
+ The HTTP server supports these configuration options:
179
+
180
+ - **`PORT`** - HTTP server port (default: `8080`)
181
+ - **`BIND_ADDRESS`** - Network interface to bind to (default: `127.0.0.1` for local, use `0.0.0.0` for hosted)
182
+ - **`ALLOWED_ORIGINS`** - Comma-separated list of allowed CORS origins (default: `http://localhost:3000,http://127.0.0.1:3000`, use `*` for public service)
183
+ - **`PERPLEXITY_API_KEY`** - Your Perplexity API key (required)
184
+
185
+ #### Using Docker
186
+
187
+ ```bash
188
+ docker build -t perplexity-mcp-server .
189
+ docker run -p 8080:8080 -e PERPLEXITY_API_KEY=your_key_here perplexity-mcp-server
190
+ ```
191
+
192
+ The server will be accessible at `http://localhost:8080/mcp`
193
+
194
+ #### Using Node.js Directly
195
+
196
+ ```bash
197
+ npm install
198
+ npm run build
199
+ npm run start:http
200
+ ```
201
+
202
+ Connect your MCP client to: `http://localhost:8080/mcp`
203
+
161
204
 
162
205
  ## Troubleshooting
163
206
 
@@ -165,16 +208,7 @@ If you'd rather use the standard variables, we support `HTTPS_PROXY` and `HTTP_P
165
208
  - **Connection Errors**: Check your internet connection and API key validity
166
209
  - **Tool Not Found**: Make sure the package is installed and the command path is correct
167
210
  - **Timeout Errors**: For very long research queries, set `PERPLEXITY_TIMEOUT_MS` to a higher value
168
- - **Proxy Issues**: If you're behind a corporate firewall and experience connection errors, you likely need to set up a proxy:
169
- - Obtain your proxy server address and port from your IT department.
170
- - Set the environment variable before running the server, e.g.:
171
- - `export PERPLEXITY_PROXY=http://proxy-address:port`
172
- - If authentication is needed: `export PERPLEXITY_PROXY=http://username:password@proxy-address:port`
173
- - Typical proxy ports include 8080, 3128, or 80.
174
- - The format for authenticated proxies is:
175
- `http://username:password@proxy-host:port`
176
- - Double-check the address, port, and credentials if connections fail or time out.
177
- - If you continue to have issues, your firewall may be blocking traffic; ask IT if traffic for `api.perplexity.ai` is being restricted.
211
+ - **Proxy Issues**: Verify your `PERPLEXITY_PROXY` or `HTTPS_PROXY` setup and ensure `api.perplexity.ai` isn't blocked by your firewall.
178
212
 
179
213
  For support, visit [community.perplexity.ai](https://community.perplexity.ai) or [file an issue](https://github.com/perplexityai/modelcontextprotocol/issues).
180
214
 
package/dist/http.js ADDED
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env node
2
+ import express from "express";
3
+ import cors from "cors";
4
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
5
+ import { createPerplexityServer } from "./server.js";
6
+ // Check for required API key
7
+ const PERPLEXITY_API_KEY = process.env.PERPLEXITY_API_KEY;
8
+ if (!PERPLEXITY_API_KEY) {
9
+ console.error("Error: PERPLEXITY_API_KEY environment variable is required");
10
+ process.exit(1);
11
+ }
12
+ const app = express();
13
+ const PORT = parseInt(process.env.PORT || "8080", 10);
14
+ const BIND_ADDRESS = process.env.BIND_ADDRESS || "127.0.0.1";
15
+ const ALLOWED_ORIGINS = process.env.ALLOWED_ORIGINS?.split(",") || [
16
+ "http://localhost:3000",
17
+ "http://127.0.0.1:3000",
18
+ ];
19
+ // CORS configuration for browser-based MCP clients
20
+ app.use(cors({
21
+ origin: (origin, callback) => {
22
+ if (!origin)
23
+ return callback(null, true);
24
+ if (ALLOWED_ORIGINS.includes("*")) {
25
+ return callback(null, true);
26
+ }
27
+ if (ALLOWED_ORIGINS.includes(origin)) {
28
+ callback(null, true);
29
+ }
30
+ else {
31
+ callback(new Error(`Origin ${origin} not allowed by CORS`));
32
+ }
33
+ },
34
+ exposedHeaders: ["Mcp-Session-Id", "mcp-protocol-version"],
35
+ allowedHeaders: ["Content-Type", "mcp-session-id"],
36
+ }));
37
+ app.use(express.json());
38
+ const mcpServer = createPerplexityServer();
39
+ /**
40
+ * POST: client-to-server messages (requests, responses, notifications)
41
+ * GET: SSE stream for server-to-client messages (notifications, requests)
42
+ */
43
+ app.all("/mcp", async (req, res) => {
44
+ try {
45
+ const transport = new StreamableHTTPServerTransport({
46
+ sessionIdGenerator: undefined,
47
+ enableJsonResponse: true,
48
+ });
49
+ res.on('close', () => {
50
+ transport.close();
51
+ });
52
+ await mcpServer.connect(transport);
53
+ await transport.handleRequest(req, res, req.body);
54
+ }
55
+ catch (error) {
56
+ console.error("Error handling MCP request:", error);
57
+ if (!res.headersSent) {
58
+ res.status(500).json({
59
+ jsonrpc: "2.0",
60
+ error: { code: -32603, message: "Internal server error" },
61
+ id: null,
62
+ });
63
+ }
64
+ }
65
+ });
66
+ /**
67
+ * Health check endpoint
68
+ */
69
+ app.get("/health", (req, res) => {
70
+ res.json({ status: "ok", service: "perplexity-mcp-server" });
71
+ });
72
+ /**
73
+ * Start the HTTP server
74
+ */
75
+ app.listen(PORT, BIND_ADDRESS, () => {
76
+ console.log(`Perplexity MCP Server listening on http://${BIND_ADDRESS}:${PORT}/mcp`);
77
+ console.log(`Allowed origins: ${ALLOWED_ORIGINS.join(", ")}`);
78
+ }).on("error", (error) => {
79
+ console.error("Server error:", error);
80
+ process.exit(1);
81
+ });