Skip to content

Commit b28bd14

Browse files
committed
feat: add HTTP transport support with McpServer API
- Migrate from Server class to modern McpServer - Add StreamableHTTP transport with session management and SSE support - Maintain backward compatibility for existing STDIO users - Preserve all tool annotations
1 parent ab3fbf4 commit b28bd14

File tree

16 files changed

+1775
-846
lines changed

16 files changed

+1775
-846
lines changed

.claude-plugin/marketplace.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
},
77
"metadata": {
88
"description": "Official Perplexity AI plugin providing real-time web search, reasoning, and research capabilities",
9-
"version": "0.4.1"
9+
"version": "0.5.0"
1010
},
1111
"plugins": [
1212
{
1313
"name": "perplexity",
1414
"source": "./",
1515
"description": "Real-time web search, reasoning, and research through Perplexity's API",
16-
"version": "0.4.1",
16+
"version": "0.5.0",
1717
"author": {
1818
"name": "Perplexity AI",
1919
"email": "[email protected]"

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ jobs:
2222
run: npm ci
2323

2424
- name: Run tests
25+
env:
26+
PERPLEXITY_API_KEY: test-api-key
2527
run: npm test

DOCKER.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,22 @@ docker build -t perplexity-mcp-server .
1717

1818
## Running the Container
1919

20-
### Basic Usage
20+
### HTTP Mode (Default)
2121

22-
Run the container with your API key:
22+
The Docker container runs in HTTP mode by default, making it accessible via HTTP requests:
2323

2424
```bash
25-
docker run --rm -e PERPLEXITY_API_KEY=your_key_here perplexity-mcp-server
25+
docker run --rm -p 8080:8080 -e PERPLEXITY_API_KEY=your_key_here perplexity-mcp-server
2626
```
2727

28+
The server will be accessible at `http://localhost:8080/mcp`
29+
2830
### With Custom Timeout
2931

3032
Set a custom timeout for requests (default is 5 minutes):
3133

3234
```bash
33-
docker run --rm \
35+
docker run --rm -p 8080:8080 \
3436
-e PERPLEXITY_API_KEY=your_key_here \
3537
-e PERPLEXITY_TIMEOUT_MS=600000 \
3638
perplexity-mcp-server
@@ -41,7 +43,7 @@ docker run --rm \
4143
If you're behind a corporate proxy, configure it:
4244

4345
```bash
44-
docker run --rm \
46+
docker run --rm -p 8080:8080 \
4547
-e PERPLEXITY_API_KEY=your_key_here \
4648
-e PERPLEXITY_PROXY=https://your-proxy-host:8080 \
4749
perplexity-mcp-server
@@ -50,7 +52,7 @@ docker run --rm \
5052
Or with authentication:
5153

5254
```bash
53-
docker run --rm \
55+
docker run --rm -p 8080:8080 \
5456
-e PERPLEXITY_API_KEY=your_key_here \
5557
-e PERPLEXITY_PROXY=https://username:password@your-proxy-host:8080 \
5658
perplexity-mcp-server
@@ -64,34 +66,38 @@ Create a `.env` file:
6466
PERPLEXITY_API_KEY=your_key_here
6567
PERPLEXITY_TIMEOUT_MS=600000
6668
PERPLEXITY_PROXY=https://your-proxy-host:8080
69+
PORT=8080
6770
```
6871

6972
Then run:
7073

7174
```bash
72-
docker run --rm --env-file .env perplexity-mcp-server
75+
docker run --rm -p 8080:8080 --env-file .env perplexity-mcp-server
7376
```
7477

7578
## Integration with MCP Clients
7679

77-
When using Docker with MCP clients, configure them to run the Docker container. For example, in Cursor/VS Code's `mcp.json`:
80+
When using the HTTP Docker server, configure your MCP client to connect to the HTTP endpoint:
7881

7982
```json
8083
{
8184
"mcpServers": {
8285
"perplexity": {
83-
"command": "docker",
84-
"args": [
85-
"run",
86-
"--rm",
87-
"-i",
88-
"-e", "PERPLEXITY_API_KEY=your_key_here",
89-
"perplexity-mcp-server"
90-
]
86+
"url": "http://localhost:8080/mcp"
9187
}
9288
}
9389
}
9490
```
9591

96-
> **Note**: Docker-based MCP server configuration may have limitations compared to direct `npx` usage. For most use cases, the `npx` method documented in the main README is recommended.
92+
## STDIO Mode (Local Development)
93+
94+
For local development with STDIO transport, you can still run the server locally without Docker:
95+
96+
```bash
97+
npm install
98+
npm run build
99+
PERPLEXITY_API_KEY=your_key_here npm start
100+
```
101+
102+
> **Note**: The Docker image is optimized for HTTP mode deployment. For local STDIO usage, the `npx` method documented in the main README is recommended.
97103

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ COPY tsconfig.json ./
77

88
RUN --mount=type=cache,target=/root/.npm npm install --ignore-scripts
99

10-
COPY . .
10+
COPY src/ ./src/
1111

1212
RUN npm run build
1313

@@ -23,4 +23,6 @@ ENV NODE_ENV=production
2323

2424
RUN npm ci --ignore-scripts --omit-dev
2525

26-
ENTRYPOINT ["node", "dist/index.js"]
26+
EXPOSE 8080
27+
28+
ENTRYPOINT ["node", "dist/http.js"]

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,31 @@ If you'd rather use the standard variables, we support `HTTPS_PROXY` and `HTTP_P
167167
> The server checks proxy settings in this order: `PERPLEXITY_PROXY``HTTPS_PROXY``HTTP_PROXY`. If none are set, it connects directly to the internet.
168168
> URLs must include `https://`. Typical ports are `8080`, `3128`, and `80`.
169169
170+
171+
### HTTP Server Deployment
172+
173+
For cloud or shared deployments, you can run the server in HTTP mode:
174+
175+
#### Using Docker
176+
177+
```bash
178+
docker build -t perplexity-mcp-server .
179+
docker run -p 8080:8080 -e PERPLEXITY_API_KEY=your_key_here perplexity-mcp-server
180+
```
181+
182+
The server will be accessible at `http://localhost:8080/mcp`
183+
184+
#### Using Node.js Directly
185+
186+
```bash
187+
npm install
188+
npm run build
189+
PORT=8080 npm run start:http
190+
```
191+
192+
Connect your MCP client to: `http://localhost:8080/mcp`
193+
194+
170195
## Troubleshooting
171196

172197
- **API Key Issues**: Ensure `PERPLEXITY_API_KEY` is set correctly

0 commit comments

Comments
 (0)