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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ If you see both of these this means that the integration is active. Congratulati

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).

If you need to go through a web proxy to reach Perplexity API, add `HTTPS_PROXY` environment variable to the `env` section.

### Troubleshooting

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).
Expand Down
12 changes: 12 additions & 0 deletions perplexity-ask/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ import {
Tool,
} from "@modelcontextprotocol/sdk/types.js";

// Configure proxy for fetch using undici if proxy environment variables are set
const proxyUrl = process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy;
if (proxyUrl) {
try {
const { setGlobalDispatcher, ProxyAgent } = await import('undici');
setGlobalDispatcher(new ProxyAgent(proxyUrl));
console.error(`Configured proxy: ${proxyUrl}`);
} catch (error) {
console.error('Warning: Could not configure proxy for fetch:', error);
}
}

/**
* Definition of the Perplexity Ask Tool.
* This tool accepts an array of messages and returns a chat completion response
Expand Down
Loading