mcp-perplexity-pro 1.1.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.
- package/README.md +638 -0
- package/bin/mcp-perplexity-pro +8 -0
- package/bin/mcp-perplexity-pro-stdio +9 -0
- package/dist/claude-code-bridge.d.ts +3 -0
- package/dist/claude-code-bridge.d.ts.map +1 -0
- package/dist/claude-code-bridge.js +111 -0
- package/dist/claude-code-bridge.js.map +1 -0
- package/dist/http-index.d.ts +3 -0
- package/dist/http-index.d.ts.map +1 -0
- package/dist/http-index.js +38 -0
- package/dist/http-index.js.map +1 -0
- package/dist/http-server.d.ts +33 -0
- package/dist/http-server.d.ts.map +1 -0
- package/dist/http-server.js +362 -0
- package/dist/http-server.js.map +1 -0
- package/dist/http-streaming-server.d.ts +4 -0
- package/dist/http-streaming-server.d.ts.map +1 -0
- package/dist/http-streaming-server.js +514 -0
- package/dist/http-streaming-server.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/launcher.d.ts +3 -0
- package/dist/launcher.d.ts.map +1 -0
- package/dist/launcher.js +209 -0
- package/dist/launcher.js.map +1 -0
- package/dist/mcp-server.d.ts +5 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +329 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/models.d.ts +45 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +284 -0
- package/dist/models.js.map +1 -0
- package/dist/perplexity-api.d.ts +59 -0
- package/dist/perplexity-api.d.ts.map +1 -0
- package/dist/perplexity-api.js +455 -0
- package/dist/perplexity-api.js.map +1 -0
- package/dist/port-utils.d.ts +31 -0
- package/dist/port-utils.d.ts.map +1 -0
- package/dist/port-utils.js +114 -0
- package/dist/port-utils.js.map +1 -0
- package/dist/project-manager.d.ts +91 -0
- package/dist/project-manager.d.ts.map +1 -0
- package/dist/project-manager.js +422 -0
- package/dist/project-manager.js.map +1 -0
- package/dist/simple-streaming.d.ts +26 -0
- package/dist/simple-streaming.d.ts.map +1 -0
- package/dist/simple-streaming.js +75 -0
- package/dist/simple-streaming.js.map +1 -0
- package/dist/sse-index.d.ts +3 -0
- package/dist/sse-index.d.ts.map +1 -0
- package/dist/sse-index.js +38 -0
- package/dist/sse-index.js.map +1 -0
- package/dist/sse-server.d.ts +4 -0
- package/dist/sse-server.d.ts.map +1 -0
- package/dist/sse-server.js +208 -0
- package/dist/sse-server.js.map +1 -0
- package/dist/stdio-bridge.d.ts +21 -0
- package/dist/stdio-bridge.d.ts.map +1 -0
- package/dist/stdio-bridge.js +157 -0
- package/dist/stdio-bridge.js.map +1 -0
- package/dist/stdio-server.d.ts +7 -0
- package/dist/stdio-server.d.ts.map +1 -0
- package/dist/stdio-server.js +396 -0
- package/dist/stdio-server.js.map +1 -0
- package/dist/storage.d.ts +65 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +328 -0
- package/dist/storage.js.map +1 -0
- package/dist/streaming-wrapper.d.ts +63 -0
- package/dist/streaming-wrapper.d.ts.map +1 -0
- package/dist/streaming-wrapper.js +452 -0
- package/dist/streaming-wrapper.js.map +1 -0
- package/dist/tools/async.d.ts +28 -0
- package/dist/tools/async.d.ts.map +1 -0
- package/dist/tools/async.js +167 -0
- package/dist/tools/async.js.map +1 -0
- package/dist/tools/chat.d.ts +29 -0
- package/dist/tools/chat.d.ts.map +1 -0
- package/dist/tools/chat.js +233 -0
- package/dist/tools/chat.js.map +1 -0
- package/dist/tools/projects.d.ts +19 -0
- package/dist/tools/projects.d.ts.map +1 -0
- package/dist/tools/projects.js +219 -0
- package/dist/tools/projects.js.map +1 -0
- package/dist/tools/query.d.ts +13 -0
- package/dist/tools/query.d.ts.map +1 -0
- package/dist/tools/query.js +178 -0
- package/dist/tools/query.js.map +1 -0
- package/dist/types.d.ts +330 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +90 -0
- package/dist/types.js.map +1 -0
- package/package.json +89 -0
package/README.md
ADDED
|
@@ -0,0 +1,638 @@
|
|
|
1
|
+
# MCP Perplexity Pro
|
|
2
|
+
|
|
3
|
+
A comprehensive Model Context Protocol (MCP) server for the Perplexity API, featuring intelligent model selection, conversation management, and project-aware storage.
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/mcp-perplexity-pro)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](http://www.typescriptlang.org/)
|
|
8
|
+
|
|
9
|
+
## ✨ Features
|
|
10
|
+
|
|
11
|
+
- **🧠 Intelligent Model Selection**: Automatically chooses the optimal Perplexity model based on query analysis
|
|
12
|
+
- **💬 Conversation Management**: Stateful chat sessions with full conversation history
|
|
13
|
+
- **🔍 Comprehensive Search**: Access to all Perplexity models (sonar, sonar-pro, sonar-reasoning, sonar-reasoning-pro, sonar-deep-research)
|
|
14
|
+
- **📊 Async Operations**: Support for long-running research tasks
|
|
15
|
+
- **🗂️ Project-Aware Storage**: Conversations and reports stored in your project directory
|
|
16
|
+
- **🔒 Thread-Safe**: Concurrent access with file locking
|
|
17
|
+
- **🐳 Docker Ready**: Full Docker and Docker Compose support
|
|
18
|
+
- **📈 Production Ready**: Comprehensive error handling, logging, and monitoring
|
|
19
|
+
- **🧪 Well Tested**: Extensive unit and integration test coverage
|
|
20
|
+
|
|
21
|
+
## 🚀 Quick Start
|
|
22
|
+
|
|
23
|
+
### Prerequisites
|
|
24
|
+
|
|
25
|
+
- Node.js 20+
|
|
26
|
+
- Perplexity API key ([Get one here](https://perplexity.ai/))
|
|
27
|
+
|
|
28
|
+
### Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install -g mcp-perplexity-pro
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 🚀 Deployment Options
|
|
35
|
+
|
|
36
|
+
### 1. NPX Deployment (stdio-npx)
|
|
37
|
+
|
|
38
|
+
The simplest way to use the MCP server with stdio transport:
|
|
39
|
+
|
|
40
|
+
**For Claude Desktop** (`claude_desktop_config.json`):
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"mcpServers": {
|
|
45
|
+
"perplexity": {
|
|
46
|
+
"command": "npx",
|
|
47
|
+
"args": ["mcp-perplexity-pro-stdio"],
|
|
48
|
+
"env": {
|
|
49
|
+
"PERPLEXITY_API_KEY": "your-api-key-here"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**For Claude Code** (`.mcp.json`):
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"mcpServers": {
|
|
61
|
+
"perplexity": {
|
|
62
|
+
"command": "npx",
|
|
63
|
+
"args": ["mcp-perplexity-pro-stdio"],
|
|
64
|
+
"env": {
|
|
65
|
+
"PERPLEXITY_API_KEY": "your-api-key-here"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 2. Docker Deployment (stdio-docker)
|
|
73
|
+
|
|
74
|
+
Run the MCP server in a Docker container with stdio transport:
|
|
75
|
+
|
|
76
|
+
**Using Docker Compose:**
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Set your API key
|
|
80
|
+
export PERPLEXITY_API_KEY="your-api-key-here"
|
|
81
|
+
|
|
82
|
+
# Start the stdio service
|
|
83
|
+
docker-compose --profile stdio up -d mcp-perplexity-pro-stdio
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**For Claude Desktop** (`claude_desktop_config.json`):
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"mcpServers": {
|
|
91
|
+
"perplexity": {
|
|
92
|
+
"command": "docker",
|
|
93
|
+
"args": ["exec", "-i", "mcp-perplexity-pro-stdio", "node", "/app/dist/stdio-server.js"],
|
|
94
|
+
"env": {
|
|
95
|
+
"PERPLEXITY_API_KEY": "your-api-key-here"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Direct Docker Run:**
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
docker run -it --rm \
|
|
106
|
+
-e PERPLEXITY_API_KEY="your-api-key-here" \
|
|
107
|
+
-v "$(pwd)/data:/app/data" \
|
|
108
|
+
mcp-perplexity-pro:stdio
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 3. HTTP Transport (Legacy)
|
|
112
|
+
|
|
113
|
+
**For Claude Code** (`.mcp.json`):
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"mcpServers": {
|
|
118
|
+
"perplexity": {
|
|
119
|
+
"command": "node",
|
|
120
|
+
"args": ["dist/launcher.js", "--http-port=8124"],
|
|
121
|
+
"env": {
|
|
122
|
+
"PERPLEXITY_API_KEY": "your-api-key-here"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**For Claude Desktop** (`claude_desktop_config.json`):
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"mcpServers": {
|
|
134
|
+
"perplexity": {
|
|
135
|
+
"command": "node",
|
|
136
|
+
"args": ["dist/launcher.js", "--http-port=8125"],
|
|
137
|
+
"env": {
|
|
138
|
+
"PERPLEXITY_API_KEY": "your-api-key-here"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Default Ports:**
|
|
146
|
+
|
|
147
|
+
- Claude Code: 8124 (default when no port specified)
|
|
148
|
+
- Claude Desktop: 8125 (recommended)
|
|
149
|
+
|
|
150
|
+
**Environment Variables:**
|
|
151
|
+
|
|
152
|
+
- `PERPLEXITY_API_KEY` (required): Your Perplexity API key
|
|
153
|
+
- `DEFAULT_MODEL` (optional): Default model (default: sonar-reasoning-pro)
|
|
154
|
+
- `PROJECT_ROOT` (optional): Project root directory for storage
|
|
155
|
+
- `STORAGE_PATH` (optional): Storage subdirectory (default: .perplexity)
|
|
156
|
+
|
|
157
|
+
The launcher automatically:
|
|
158
|
+
|
|
159
|
+
- Detects if a build is needed and rebuilds if necessary
|
|
160
|
+
- Starts HTTP server with streamable transport
|
|
161
|
+
- No manual build or start commands required
|
|
162
|
+
|
|
163
|
+
## 📋 Available Tools
|
|
164
|
+
|
|
165
|
+
### Query Tools
|
|
166
|
+
|
|
167
|
+
#### `ask_perplexity`
|
|
168
|
+
|
|
169
|
+
Ask questions with intelligent model selection based on query type.
|
|
170
|
+
|
|
171
|
+
**Parameters:**
|
|
172
|
+
|
|
173
|
+
- `query` (required): Your question or prompt
|
|
174
|
+
- `model` (optional): Specific model to use
|
|
175
|
+
- `temperature` (optional): Response creativity (0.0-2.0)
|
|
176
|
+
- `max_tokens` (optional): Maximum response length
|
|
177
|
+
|
|
178
|
+
**Example:**
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
Ask Perplexity: "What are the latest developments in quantum computing?"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### `research_perplexity`
|
|
185
|
+
|
|
186
|
+
Conduct comprehensive research with detailed reports saved to your project.
|
|
187
|
+
|
|
188
|
+
**Parameters:**
|
|
189
|
+
|
|
190
|
+
- `query` (required): Research topic or question
|
|
191
|
+
- `model` (optional): Defaults to `sonar-deep-research`
|
|
192
|
+
- `save_report` (optional): Save detailed report to project
|
|
193
|
+
|
|
194
|
+
**Example:**
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
Research: "Market analysis of renewable energy trends in 2024"
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Chat Tools
|
|
201
|
+
|
|
202
|
+
#### `chat_perplexity`
|
|
203
|
+
|
|
204
|
+
Start or continue conversations with full context.
|
|
205
|
+
|
|
206
|
+
**Parameters:**
|
|
207
|
+
|
|
208
|
+
- `message` (required): Your message
|
|
209
|
+
- `chat_id` (optional): Continue existing conversation
|
|
210
|
+
- `title` (optional): Title for new conversation
|
|
211
|
+
- `model` (optional): Model selection
|
|
212
|
+
|
|
213
|
+
**Example:**
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
Chat: "Hello, I'd like to discuss AI ethics" (title: "AI Ethics Discussion")
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
#### `list_chats_perplexity`
|
|
220
|
+
|
|
221
|
+
List all conversations in your project.
|
|
222
|
+
|
|
223
|
+
#### `read_chat_perplexity`
|
|
224
|
+
|
|
225
|
+
Retrieve full conversation history.
|
|
226
|
+
|
|
227
|
+
**Parameters:**
|
|
228
|
+
|
|
229
|
+
- `chat_id` (required): Conversation ID
|
|
230
|
+
|
|
231
|
+
### Async Tools
|
|
232
|
+
|
|
233
|
+
#### `async_perplexity`
|
|
234
|
+
|
|
235
|
+
Create long-running research jobs for complex queries.
|
|
236
|
+
|
|
237
|
+
**Parameters:**
|
|
238
|
+
|
|
239
|
+
- `query` (required): Research question
|
|
240
|
+
- `model` (optional): Defaults to `sonar-deep-research`
|
|
241
|
+
|
|
242
|
+
#### `check_async_perplexity`
|
|
243
|
+
|
|
244
|
+
Check status of async research job.
|
|
245
|
+
|
|
246
|
+
**Parameters:**
|
|
247
|
+
|
|
248
|
+
- `job_id` (required): Job identifier
|
|
249
|
+
|
|
250
|
+
#### `list_async_jobs`
|
|
251
|
+
|
|
252
|
+
List all async jobs in your project.
|
|
253
|
+
|
|
254
|
+
### Utility Tools
|
|
255
|
+
|
|
256
|
+
#### `storage_stats_perplexity`
|
|
257
|
+
|
|
258
|
+
Get storage statistics and usage information.
|
|
259
|
+
|
|
260
|
+
#### `model_info_perplexity`
|
|
261
|
+
|
|
262
|
+
Get information about available models and their capabilities.
|
|
263
|
+
|
|
264
|
+
## 🧠 Intelligent Model Selection
|
|
265
|
+
|
|
266
|
+
The server automatically selects the optimal model based on query analysis:
|
|
267
|
+
|
|
268
|
+
| Query Type | Selected Model | Use Case |
|
|
269
|
+
| ----------------- | --------------------- | ----------------------------------------------------------- |
|
|
270
|
+
| Research requests | `sonar-deep-research` | "I need comprehensive research on..." |
|
|
271
|
+
| Real-time queries | `sonar-pro` | "What's the current price of...", "Latest news..." |
|
|
272
|
+
| Complex reasoning | `sonar-reasoning-pro` | "Analyze the implications of...", "Compare and contrast..." |
|
|
273
|
+
| Simple questions | `sonar-reasoning` | General questions |
|
|
274
|
+
| Default | `sonar-reasoning-pro` | Fallback for all other queries |
|
|
275
|
+
|
|
276
|
+
### Model Capabilities
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
{
|
|
280
|
+
"sonar": {
|
|
281
|
+
search: true, reasoning: false, realTime: false, research: false
|
|
282
|
+
},
|
|
283
|
+
"sonar-pro": {
|
|
284
|
+
search: true, reasoning: false, realTime: true, research: false
|
|
285
|
+
},
|
|
286
|
+
"sonar-reasoning": {
|
|
287
|
+
search: true, reasoning: true, realTime: false, research: false
|
|
288
|
+
},
|
|
289
|
+
"sonar-reasoning-pro": {
|
|
290
|
+
search: true, reasoning: true, realTime: true, research: false
|
|
291
|
+
},
|
|
292
|
+
"sonar-deep-research": {
|
|
293
|
+
search: true, reasoning: true, realTime: false, research: true
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## 🗂️ Project-Aware Storage
|
|
299
|
+
|
|
300
|
+
All conversations and research reports are stored in your project directory:
|
|
301
|
+
|
|
302
|
+
```
|
|
303
|
+
your-project/
|
|
304
|
+
├── .perplexity/
|
|
305
|
+
│ ├── chats/
|
|
306
|
+
│ │ ├── chat-uuid-1.json
|
|
307
|
+
│ │ └── chat-uuid-2.json
|
|
308
|
+
│ ├── reports/
|
|
309
|
+
│ │ ├── research-report-1.json
|
|
310
|
+
│ │ └── research-report-2.json
|
|
311
|
+
│ └── async-jobs/
|
|
312
|
+
│ ├── job-uuid-1.json
|
|
313
|
+
│ └── job-uuid-2.json
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Storage Features
|
|
317
|
+
|
|
318
|
+
- **Thread-safe**: File locking prevents concurrent access issues
|
|
319
|
+
- **Session-aware**: Multiple sessions can work with the same project
|
|
320
|
+
- **Organized**: Separate directories for different content types
|
|
321
|
+
- **Persistent**: All data survives server restarts
|
|
322
|
+
- **Portable**: Easy to backup, move, or version control
|
|
323
|
+
|
|
324
|
+
## 🐳 Docker Deployment
|
|
325
|
+
|
|
326
|
+
### Development
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
# Clone repository
|
|
330
|
+
git clone https://github.com/cfdude/mcp-perplexity-pro.git
|
|
331
|
+
cd mcp-perplexity-pro
|
|
332
|
+
|
|
333
|
+
# Start development environment
|
|
334
|
+
docker-compose --profile dev up -d
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Production
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
# Set environment variables
|
|
341
|
+
export PROJECT_ROOT=/path/to/your/project
|
|
342
|
+
|
|
343
|
+
# Start production environment
|
|
344
|
+
docker-compose up -d
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Custom Docker
|
|
348
|
+
|
|
349
|
+
```dockerfile
|
|
350
|
+
FROM mcp-perplexity-pro:latest
|
|
351
|
+
|
|
352
|
+
# Custom configuration
|
|
353
|
+
COPY my-config.json /app/config.json
|
|
354
|
+
|
|
355
|
+
# Custom entrypoint
|
|
356
|
+
CMD ["node", "dist/index.js", "--config", "config.json"]
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## ⚙️ Configuration
|
|
360
|
+
|
|
361
|
+
### Environment Variables
|
|
362
|
+
|
|
363
|
+
| Variable | Description | Default |
|
|
364
|
+
| -------------------- | -------------------- | --------------------- |
|
|
365
|
+
| `NODE_ENV` | Environment mode | `development` |
|
|
366
|
+
| `PERPLEXITY_API_KEY` | Your API key | Required |
|
|
367
|
+
| `PROJECT_ROOT` | Project directory | Current directory |
|
|
368
|
+
| `STORAGE_PATH` | Storage subdirectory | `.perplexity` |
|
|
369
|
+
| `DEFAULT_MODEL` | Default model | `sonar-reasoning-pro` |
|
|
370
|
+
| `SESSION_ID` | Session identifier | Auto-generated |
|
|
371
|
+
|
|
372
|
+
### Advanced Configuration
|
|
373
|
+
|
|
374
|
+
```json
|
|
375
|
+
{
|
|
376
|
+
"api_key": "your-key",
|
|
377
|
+
"default_model": "sonar-reasoning-pro",
|
|
378
|
+
"project_root": "/workspace",
|
|
379
|
+
"storage_path": ".perplexity",
|
|
380
|
+
"session_id": "unique-session",
|
|
381
|
+
"request_timeout": 30000,
|
|
382
|
+
"max_retries": 3,
|
|
383
|
+
"rate_limit": {
|
|
384
|
+
"requests_per_minute": 60,
|
|
385
|
+
"concurrent_requests": 5
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
## 🧪 Development
|
|
391
|
+
|
|
392
|
+
### Setup
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
# Clone and install
|
|
396
|
+
git clone https://github.com/cfdude/mcp-perplexity-pro.git
|
|
397
|
+
cd mcp-perplexity-pro
|
|
398
|
+
npm install
|
|
399
|
+
|
|
400
|
+
# Development mode
|
|
401
|
+
npm run dev
|
|
402
|
+
|
|
403
|
+
# Run tests
|
|
404
|
+
npm test
|
|
405
|
+
npm run test:coverage
|
|
406
|
+
|
|
407
|
+
# Linting and formatting
|
|
408
|
+
npm run lint
|
|
409
|
+
npm run format
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### Project Structure
|
|
413
|
+
|
|
414
|
+
```
|
|
415
|
+
src/
|
|
416
|
+
├── index.ts # Main MCP server
|
|
417
|
+
├── types.ts # TypeScript definitions
|
|
418
|
+
├── models.ts # Model registry & selection
|
|
419
|
+
├── perplexity-api.ts # API client wrapper
|
|
420
|
+
├── storage.ts # Storage management
|
|
421
|
+
└── tools/
|
|
422
|
+
├── query.ts # Query tools
|
|
423
|
+
├── chat.ts # Chat tools
|
|
424
|
+
└── async.ts # Async tools
|
|
425
|
+
|
|
426
|
+
tests/
|
|
427
|
+
├── models.test.ts # Model selection tests
|
|
428
|
+
├── storage.test.ts # Storage tests
|
|
429
|
+
├── perplexity-api.test.ts # API tests
|
|
430
|
+
└── integration.test.ts # End-to-end tests
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Testing
|
|
434
|
+
|
|
435
|
+
```bash
|
|
436
|
+
# Run all tests
|
|
437
|
+
npm test
|
|
438
|
+
|
|
439
|
+
# Watch mode
|
|
440
|
+
npm run test:watch
|
|
441
|
+
|
|
442
|
+
# Coverage report
|
|
443
|
+
npm run test:coverage
|
|
444
|
+
|
|
445
|
+
# Specific test file
|
|
446
|
+
npm test -- models.test.ts
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
## 📊 API Usage Examples
|
|
450
|
+
|
|
451
|
+
### Basic Query
|
|
452
|
+
|
|
453
|
+
```javascript
|
|
454
|
+
// Simple question
|
|
455
|
+
const result = await askPerplexity({
|
|
456
|
+
query: 'What is machine learning?',
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
// With specific model
|
|
460
|
+
const result = await askPerplexity({
|
|
461
|
+
query: 'Current Bitcoin price',
|
|
462
|
+
model: 'sonar-pro',
|
|
463
|
+
});
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### Conversation
|
|
467
|
+
|
|
468
|
+
```javascript
|
|
469
|
+
// Start new conversation
|
|
470
|
+
const chat = await chatPerplexity({
|
|
471
|
+
message: 'Hello!',
|
|
472
|
+
title: 'General Discussion',
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
// Continue conversation
|
|
476
|
+
const response = await chatPerplexity({
|
|
477
|
+
chat_id: chat.id,
|
|
478
|
+
message: 'Tell me about quantum computing',
|
|
479
|
+
});
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
### Research
|
|
483
|
+
|
|
484
|
+
```javascript
|
|
485
|
+
// Comprehensive research
|
|
486
|
+
const research = await researchPerplexity({
|
|
487
|
+
query: 'Impact of AI on healthcare industry',
|
|
488
|
+
save_report: true,
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
// Async research for complex topics
|
|
492
|
+
const job = await asyncPerplexity({
|
|
493
|
+
query: 'Detailed analysis of climate change solutions',
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
// Check job status
|
|
497
|
+
const status = await checkAsync({
|
|
498
|
+
job_id: job.id,
|
|
499
|
+
});
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
## 🔒 Security
|
|
503
|
+
|
|
504
|
+
### API Key Management
|
|
505
|
+
|
|
506
|
+
- Store API keys securely using environment variables
|
|
507
|
+
- Never commit API keys to version control
|
|
508
|
+
- Rotate keys regularly
|
|
509
|
+
- Use different keys for different environments
|
|
510
|
+
|
|
511
|
+
### Network Security
|
|
512
|
+
|
|
513
|
+
- HTTPS in production
|
|
514
|
+
- Rate limiting implemented
|
|
515
|
+
- Input validation and sanitization
|
|
516
|
+
- Error handling without information leakage
|
|
517
|
+
|
|
518
|
+
### Container Security
|
|
519
|
+
|
|
520
|
+
- Non-root user execution
|
|
521
|
+
- Minimal base images
|
|
522
|
+
- Regular security updates
|
|
523
|
+
- Vulnerability scanning
|
|
524
|
+
|
|
525
|
+
## 📈 Monitoring
|
|
526
|
+
|
|
527
|
+
### Health Checks
|
|
528
|
+
|
|
529
|
+
```bash
|
|
530
|
+
# Basic health check
|
|
531
|
+
curl http://localhost:3000/health
|
|
532
|
+
|
|
533
|
+
# Detailed status
|
|
534
|
+
curl http://localhost:3000/status
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
### Metrics
|
|
538
|
+
|
|
539
|
+
The server exposes Prometheus-compatible metrics:
|
|
540
|
+
|
|
541
|
+
- Request count and duration
|
|
542
|
+
- Error rates by endpoint
|
|
543
|
+
- Storage usage statistics
|
|
544
|
+
- Model usage distribution
|
|
545
|
+
|
|
546
|
+
### Logging
|
|
547
|
+
|
|
548
|
+
Structured JSON logging with configurable levels:
|
|
549
|
+
|
|
550
|
+
```json
|
|
551
|
+
{
|
|
552
|
+
"timestamp": "2024-08-20T19:00:00.000Z",
|
|
553
|
+
"level": "info",
|
|
554
|
+
"message": "Query processed successfully",
|
|
555
|
+
"model": "sonar-reasoning-pro",
|
|
556
|
+
"duration": 1250,
|
|
557
|
+
"session_id": "session-123"
|
|
558
|
+
}
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
## 🚨 Troubleshooting
|
|
562
|
+
|
|
563
|
+
### Common Issues
|
|
564
|
+
|
|
565
|
+
**API Key Errors**
|
|
566
|
+
|
|
567
|
+
```bash
|
|
568
|
+
Error: Invalid API key
|
|
569
|
+
Solution: Verify PERPLEXITY_API_KEY is set correctly
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
**Storage Permission Errors**
|
|
573
|
+
|
|
574
|
+
```bash
|
|
575
|
+
Error: EACCES: permission denied
|
|
576
|
+
Solution: Ensure storage directory is writable
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
**Model Selection Issues**
|
|
580
|
+
|
|
581
|
+
```bash
|
|
582
|
+
Error: Model not available
|
|
583
|
+
Solution: Check model name spelling and availability
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
### Debug Mode
|
|
587
|
+
|
|
588
|
+
```bash
|
|
589
|
+
DEBUG=mcp-perplexity:* npm start
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
### Support
|
|
593
|
+
|
|
594
|
+
- 📚 [Documentation](https://github.com/cfdude/mcp-perplexity-pro/wiki)
|
|
595
|
+
- 🐛 [Issues](https://github.com/cfdude/mcp-perplexity-pro/issues)
|
|
596
|
+
- 💬 [Discussions](https://github.com/cfdude/mcp-perplexity-pro/discussions)
|
|
597
|
+
|
|
598
|
+
## 🤝 Contributing
|
|
599
|
+
|
|
600
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
601
|
+
|
|
602
|
+
### Development Workflow
|
|
603
|
+
|
|
604
|
+
1. Fork the repository
|
|
605
|
+
2. Create a feature branch
|
|
606
|
+
3. Make your changes
|
|
607
|
+
4. Add tests for new functionality
|
|
608
|
+
5. Ensure all tests pass
|
|
609
|
+
6. Submit a pull request
|
|
610
|
+
|
|
611
|
+
### Code Standards
|
|
612
|
+
|
|
613
|
+
- TypeScript with strict mode
|
|
614
|
+
- ESLint + Prettier formatting
|
|
615
|
+
- 100% test coverage for new features
|
|
616
|
+
- Conventional commit messages
|
|
617
|
+
|
|
618
|
+
## 📄 License
|
|
619
|
+
|
|
620
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
621
|
+
|
|
622
|
+
## 🙏 Acknowledgments
|
|
623
|
+
|
|
624
|
+
- [Perplexity AI](https://perplexity.ai/) for providing the excellent API
|
|
625
|
+
- [Model Context Protocol](https://github.com/modelcontextprotocol) for the MCP specification
|
|
626
|
+
- [Smithery](https://smithery.ai/) for MCP development tools
|
|
627
|
+
- The open-source community for inspiration and contributions
|
|
628
|
+
|
|
629
|
+
## 📊 Project Stats
|
|
630
|
+
|
|
631
|
+

|
|
632
|
+

|
|
633
|
+

|
|
634
|
+

|
|
635
|
+
|
|
636
|
+
---
|
|
637
|
+
|
|
638
|
+
**Built with ❤️ for the MCP community**
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Simple launcher that imports the compiled TypeScript launcher
|
|
4
|
+
import('../dist/launcher.js').catch((error) => {
|
|
5
|
+
console.error('[mcp-perplexity-pro] Failed to load launcher:', error.message);
|
|
6
|
+
console.error('[mcp-perplexity-pro] Make sure the package is built with: npm run build');
|
|
7
|
+
process.exit(1);
|
|
8
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Stdio-only launcher for MCP Perplexity Pro
|
|
4
|
+
// This bypasses HTTP transport and connects directly via stdio
|
|
5
|
+
import('../dist/stdio-server.js').catch((error) => {
|
|
6
|
+
console.error('[mcp-perplexity-pro-stdio] Failed to load stdio server:', error.message);
|
|
7
|
+
console.error('[mcp-perplexity-pro-stdio] Make sure the package is built with: npm run build');
|
|
8
|
+
process.exit(1);
|
|
9
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code-bridge.d.ts","sourceRoot":"","sources":["../src/claude-code-bridge.ts"],"names":[],"mappings":""}
|