Skip to main content
Glama
rileyedwards77

Perplexity AI MCP Server

chat_perplexity

Send messages to Perplexity AI to maintain conversations with full history context, either starting new chats or continuing existing ones.

Instructions

Maintains ongoing conversations with Perplexity AI. Creates new chats or continues existing ones with full history context.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYesThe message to send to Perplexity AI
chat_idNoOptional: ID of an existing chat to continue. If not provided, a new chat will be created.

Implementation Reference

  • Handler for 'chat_perplexity' tool: retrieves chat history, appends user message, calls Perplexity /chat/completions API using 'sonar-reasoning-pro' model, saves assistant response, returns chat_id and response.
    case "chat_perplexity": {
        const { message, chat_id = crypto.randomUUID() } = request.params.arguments;
        // Get chat history
        const history = yield this.getMessagesForChat(chat_id);
        // Add new user message
        const userMessage = { role: "user", content: message };
        yield this.addMessageToChat(chat_id, userMessage);
        // Prepare messages array with history
        const messages = [...history, userMessage];
        // Call Perplexity API
        const response = yield this.axiosInstance.post("/chat/completions", {
            model: "sonar-reasoning-pro",
            messages,
        });
        // Save assistant's response
        const assistantMessage = {
            role: "assistant",
            content: response.data.choices[0].message.content,
        };
        yield this.addMessageToChat(chat_id, assistantMessage);
        return {
            content: [
                {
                    type: "text",
                    text: JSON.stringify({
                        chat_id,
                        response: assistantMessage.content,
                    }, null, 2),
                },
            ],
        };
    }
  • index.js:88-105 (registration)
    Tool registration in ListToolsRequestSchema handler, including name, description, and input schema definition.
    {
        name: "chat_perplexity",
        description: "Maintains ongoing conversations with Perplexity AI. Creates new chats or continues existing ones with full history context.",
        inputSchema: {
            type: "object",
            properties: {
                message: {
                    type: "string",
                    description: "The message to send to Perplexity AI",
                },
                chat_id: {
                    type: "string",
                    description: "Optional: ID of an existing chat to continue. If not provided, a new chat will be created.",
                },
            },
            required: ["message"],
        },
    },
  • Input schema for chat_perplexity tool defining required 'message' and optional 'chat_id'.
            type: "object",
            properties: {
                message: {
                    type: "string",
                    description: "The message to send to Perplexity AI",
                },
                chat_id: {
                    type: "string",
                    description: "Optional: ID of an existing chat to continue. If not provided, a new chat will be created.",
                },
            },
            required: ["message"],
        },
    },
  • Helper to append a message to a specific chat's history and persist to file.
    addMessageToChat(chatId, message) {
        return __awaiter(this, void 0, void 0, function* () {
            const history = yield this.getChatHistory();
            if (!history[chatId]) {
                history[chatId] = [];
            }
            history[chatId].push(message);
            yield this.saveChatHistory(history);
        });
  • Helper to load entire chat history from persistent JSON file, returns empty object if not exists.
    getChatHistory() {
        return __awaiter(this, void 0, void 0, function* () {
            try {
                const data = yield readFile(this.chatHistoryFile, "utf-8");
                return JSON.parse(data);
            }
            catch (error) {
                if (error.code === "ENOENT") {
                    // File does not exist, return empty history
                    return {};
                }
                throw error;
            }
        });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'maintains ongoing conversations' and 'full history context', which implies statefulness and persistence, but doesn't disclose critical behavioral traits such as authentication requirements, rate limits, conversation length limits, whether it's read-only or mutative, error handling, or what happens when chat_id is invalid. The description adds some context but leaves significant gaps for a tool that likely involves API calls and state management.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two concise sentences that are front-loaded with the main purpose. Every sentence earns its place: the first establishes the core functionality, and the second clarifies the chat creation/continuation behavior. There's no wasted verbiage or redundant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (managing conversational state with an external AI service), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., AI response format, chat_id for new chats), error conditions, authentication needs, or operational constraints. For a stateful chat tool with external dependencies, this minimal description leaves too many unknowns for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description doesn't explicitly mention or explain any parameters. However, with 100% schema description coverage, the input schema already provides clear documentation for both parameters (message and chat_id). The description's mention of 'creates new chats or continues existing ones' aligns with the chat_id parameter's semantics, but adds no additional meaning beyond what the schema already states. This meets the baseline of 3 when schema coverage is high.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('maintains', 'creates', 'continues') and resources ('ongoing conversations with Perplexity AI', 'new chats', 'existing ones'). It distinguishes from siblings by focusing on conversational AI interactions rather than code analysis, API discovery, documentation retrieval, or general search. However, it doesn't explicitly differentiate from potential sibling tools that might also involve chat interactions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context for maintaining conversations with Perplexity AI, but provides no explicit guidance on when to use this tool versus the sibling tools (check_deprecated_code, find_apis, get_documentation, search). It mentions the ability to create new chats or continue existing ones, which gives some implied usage scenarios, but lacks clear when/when-not instructions or alternative recommendations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rileyedwards77/perplexity-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server