Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ WORKDIR /app

# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1
ARG PERPLEXITY_URL_ARG=https://api.perplexity.ai/chat/completions
ENV PERPLEXITY_URL=$PERPLEXITY_URL_ARG

# Copy the pyproject.toml to install dependencies
COPY pyproject.toml /app/pyproject.toml
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Optional environment variables:
- `sonar`: 128k context - Default model
- `r1-1776`: 128k context - Alternative architecture

- `PERPLEXITY_URL`: Allows overriding the default Perplexity API URL. If not set, the server will use `https://api.perplexity.ai/chat/completions`. Set this variable if you need to use a different API endpoint.
And updated list of models is avaiable (here)[https://docs.perplexity.ai/guides/model-cards]

### Cursor & Claude Desktop Installation
Expand Down
6 changes: 5 additions & 1 deletion smithery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ startCommand:
type: object
required:
- perplexityApiKey
# PERPLEXITY_URL is optional, so not adding to required.
properties:
perplexityApiKey:
type: string
description: The API key for the Perplexity AI server.
perplexityUrl:
type: string
description: The URL for the Perplexity AI server. Defaults to https://api.perplexity.ai/chat/completions if not provided.
commandFunction:
# A function that produces the CLI command to start the MCP on stdio.
|-
config => ({ command: 'uv', args: ['run', 'perplexity-mcp'], env: { PERPLEXITY_API_KEY: config.perplexityApiKey } })
config => ({ command: 'uv', args: ['run', 'perplexity-mcp'], env: { PERPLEXITY_API_KEY: config.perplexityApiKey, PERPLEXITY_URL: config.perplexityUrl } })
3 changes: 2 additions & 1 deletion src/perplexity_mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ async def call_tool(

async def call_perplexity(query: str, recency: str) -> str:

url = "https://api.perplexity.ai/chat/completions"
# Get the PERPLEXITY_URL from environment variable or use default
url = os.getenv("PERPLEXITY_URL", "https://api.perplexity.ai/chat/completions")

# Get the model from environment variable or use "sonar" as default
model = os.getenv("PERPLEXITY_MODEL", "sonar")
Expand Down