logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

mcp-perplexity-ai-gateway

A Model Context Protocol (MCP) implementation leveraging the Perplexity AI service for advanced, context-aware conversational completions, featuring configurable prompt strategies for diverse application requirements.

Author

mcp-perplexity-ai-gateway logo

spences10

MIT License

Quick Info

GitHub GitHub Stars 8
NPM Weekly Downloads 0
Tools 1
Last Updated 2026-02-19

Tags

apisrequestsapichat completionai apiperplexity ai

mcp-perplexity-ai-gateway


🛑 Maintenance Status Alert

This project is officially deprecated and no longer actively developed.

All established functionalities are now consolidated within the successor package, mcp-omnisearch, which serves as a unified interface for multiple MCP tools.

Please migrate your setup to utilize mcp-omnisearch moving forward.


This server component adheres to the Model Context Protocol (MCP) standard, facilitating deep integration of Perplexity's proprietary AI engine with various Large Language Models (LLMs). It exposes sophisticated chat completion endpoints enhanced by specialized, pre-optimized template structures designed for specific operational contexts.

badge

Core Capabilities

  • 🧠 Utilization of Perplexity's state-of-the-art AI inference models for dialogue generation.
  • 📜 A curated library of intrinsic prompt blueprints addressing frequent tasks:
  • Drafting comprehensive technical specifications and code snippets
  • Evaluating and recommending security posture enhancements
  • Performing detailed code critiques and suggesting optimizations
  • Structuring API documentation output into standardized formats
  • 🛠️ Extensibility for defining bespoke prompt configurations to meet unique workflow demands
  • 📦 Versatile output serialization supporting plain text, Markdown rendering, and structured JSON payloads
  • 🔗 Option to embed retrieved source material citations directly into the response body
  • ⚙️ Fine-grained control over generation hyperparameters (e.g., thermal sampling, maximum token allocation)
  • 🚀 Native support for Perplexity's cutting-edge models, including Sonar and LLaMA variants.

Deployment & Setup Instructions

Integration requires configuration passed through the consuming MCP client environment. Configuration examples for common deployment scenarios are provided below:

Cline Client Configuration

Incorporate the following object into your Cline MCP configuration file:

{ "mcpServers": { "mcp-perplexity-search": { "command": "npx", "args": ["-y", "mcp-perplexity-search"], "env": { "PERPLEXITY_API_KEY": "your-secret-key-here" } } } }

Claude Desktop (WSL Integration)

For environments utilizing Windows Subsystem for Linux (WSL), adjust your Claude Desktop configuration as follows:

{ "mcpServers": { "mcp-perplexity-search": { "command": "wsl.exe", "args": [ "bash", "-c", "source ~/.nvm/nvm.sh && PERPLEXITY_API_KEY=your-secret-key-here /home/username/.nvm/versions/node/v20.12.1/bin/npx mcp-perplexity-search" ] } } }

Required Environmental Variables

The execution environment mandates the setting of this credential:

  • PERPLEXITY_API_KEY: The authenticated access token for the Perplexity API (Mandatory).

Tool Interface Specification

The server exposes a singular MCP utility function with dynamic parameter mapping:

chat_completion

Facilitates the generation of dialogue responses by querying the Perplexity endpoint, accommodating predefined template injection.

Parameters:

  • messages (array, mandatory): A sequence of conversation turns, each structured as:
  • role (string): Must be one of 'system', 'user', or 'assistant'
  • content (string): The textual payload of the message
  • prompt_template (string, optional): Identifier for a built-in strategic prompt:
  • technical_docs: Template optimized for generating technical write-ups including requisite code samples
  • security_practices: Template focused on deriving robust security implementation guidance
  • code_review: Template for systematic code analysis, suggesting structural and efficiency improvements
  • api_docs: Template tailored for outputting API documentation strictly in JSON structure
  • custom_template (object, optional): Allows overriding system behavior with a user-defined structure:
  • system (string): The foundational instruction set defining the assistant's persona/role
  • format (string): Preferred output serialization schema
  • include_sources (boolean): Flag to mandate source citation inclusion
  • format (string, optional): Desired response serialization ('text', 'markdown', or 'json'). Defaults to 'text'.
  • include_sources (boolean, optional): Boolean flag to enable source material citations. Defaults to false.
  • model (string, optional): Selection of the Perplexity model engine (e.g., 'sonar'). Defaults to 'sonar'.
  • temperature (number, optional): Controls stochasticity of output (range 0.0 to 1.0). Default is 0.7.
  • max_tokens (number, optional): Cap on the length of the generated reply. Default is 1024.

Project Lifecycle Management

Initial Setup

  1. Clone the source repository.
  2. Install required dependencies:

bash pnpm install

  1. Execute the build process:

bash pnpm build

  1. Initiate local development execution:

bash pnpm dev

Deployment Workflow

This package utilizes the changesets utility for version control synchronization. To release a new version:

  1. Generate a changeset record:

bash pnpm changeset

  1. Update package versions based on recorded changesets:

bash pnpm changeset version

  1. Publish the updated package to the registry:

bash pnpm release

Collaboration Guidelines

We actively encourage community contributions! Feel encouraged to submit any relevant Pull Requests.

Licensing

Distributed under the terms of the MIT License. Refer to the LICENSE file for comprehensive details.

Credits

WIKIPEDIA: XMLHttpRequest (XHR) represents an API instantiated as a JavaScript object, facilitating the transmission of HTTP requests from a client-side web application to a remote web server. Its methods enable post-load interaction with the server, allowing asynchronous reception of data. XHR is fundamental to the architecture known as Ajax. Prior to this paradigm, server communication relied predominantly on standard hyperlink navigation and form submissions, typically resulting in a full page refresh.

== Historical Context == The underlying concept for XMLHttpRequest was pioneered in the year 2000 by the development team behind Microsoft Outlook. This idea was subsequently realized within the Internet Explorer 5 browser release (1999). However, the initial implementation did not utilize the standardized XMLHttpRequest identifier. Instead, developers relied on the COM-based ActiveXObject("Msxml2.XMLHTTP") and ActiveXObject("Microsoft.XMLHTTP") constructors. By the release of Internet Explorer 7 (2006), universal support for the XMLHttpRequest identifier had been achieved across all major browser engines. The XMLHttpRequest identifier has since established itself as the ubiquitous standard across all principal web browsers, including Mozilla's Gecko engine (adopted in 2002), Safari 1.2 (2004), and Opera 8.0 (2005).

=== Standardization Efforts === The World Wide Web Consortium (W3C) published the initial Working Draft specification for the XMLHttpRequest object on April 5, 2006. A subsequent Working Draft, Level 2, was finalized on February 25, 2008. The Level 2 revision introduced crucial enhancements such as mechanisms for tracking event progress, enabling cross-origin resource sharing (CORS), and facilities for handling raw byte streams. By the close of 2011, the Level 2 specification features were integrated back into the primary specification document. In late 2012, development responsibility transitioned to the WHATWG, which now maintains the living document using Web IDL definitions.

== Operational Usage Pattern == The process of dispatching a request using XMLHttpRequest generally involves a sequence of programmatic steps.

  1. Object Instantiation: Create an instance of the XMLHttpRequest object via its constructor.
  2. Connection Setup: Invoke the "open" method to define the request method (GET/POST, etc.), specify the target resource URI, and declare whether the operation will be synchronous or asynchronous.
  3. Event Registration: For asynchronous operations, establish an event listener callback function to process state transitions upon response arrival.
  4. Transmission Initiation: Trigger the request payload transfer by executing the "send" method.
  5. Response Handling: Monitor the state changes via the registered listener. Server response content, by default, populates the "responseText" property. Upon completion of processing, the object transitions to state 4 (the 'done' state). Beyond these fundamental steps, XMLHttpRequest provides extensive configurability for request control and response parsing. Custom request headers can be injected to guide server behavior, and data payloads can be transferred to the server via the argument supplied to the "send" call. Responses can be natively deserialized from JSON into usable JavaScript structures or processed incrementally as data streams in, bypassing the need to wait for the full response body. Furthermore, requests can be actively terminated mid-flight or configured with a timeout threshold to enforce failure policies.

== Inter-Domain Communication (Cross-domain) ==

Early in the evolution of the World Wide Web, limitations became apparent regarding the ability to breach security restrictions that prevented scripts on one domain from accessing resources hosted on another, a hurdle XMLHttpRequest initially inherited.

See Also

`