VOOZH about

URL: https://deepwiki.com/ppl-ai/modelcontextprotocol/2.1-mcp-protocol-integration

⇱ MCP Protocol Integration | ppl-ai/modelcontextprotocol | DeepWiki


Loading...
Last indexed: 28 February 2026 (95c7a8)
Menu

MCP Protocol Integration

This document details how the @perplexity-ai/mcp-server implements the Model Context Protocol (MCP), including the server manifest specification, SDK usage, and tool registration mechanisms. For information about the dual transport modes (stdio and HTTP), see page 2.2. For details on the four exposed tools, see page 2.3.


MCP Server Manifest

The server declares its capabilities and metadata through a standardized server.json manifest file that conforms to the MCP server schema specification.

Manifest Structure




















































FieldValuePurpose
$schemaMCP server schema URLValidates manifest structure against official spec
nameai.perplexity/mcp-serverUnique identifier following domain/name convention
titlePerplexity API PlatformHuman-readable display name
descriptionBrief capability summaryDescribes core functionality
version0.8.3Semantic version matching package.json
packages[].registryTypenpmDistribution mechanism
packages[].identifier@perplexity-ai/mcp-servernpm package name
packages[].transport.typestdioPrimary transport protocol

Sources: server.json1-17


SDK Integration Architecture

The server uses the official @modelcontextprotocol/sdk package (v1.25.2) to implement the MCP protocol. The SDK provides the McpServer class and transport layer abstractions.

SDK Components Diagram

McpServer construction and tool registration flow


Sources: src/server.ts1 src/index.ts3 src/http.ts5


Server Initialization

The createPerplexityServer() factory function instantiates and configures the MCP server with metadata and instructions.

McpServer Construction

The McpServer constructor takes two arguments: a server identity object and an options object containing the instructions string.

src/server.ts298-313

Server Configuration Parameters

ParameterTypePurpose
namestring"ai.perplexity/mcp-server" — matches server.json
versionstring"0.8.3" — synchronized with package.json and server.json
instructionsstringNatural language tool-selection guidance sent to MCP clients

The instructions string describes all four tools and their recommended use cases. MCP clients surface this text to help LLMs decide which tool to invoke for a given user request.

Sources: src/server.ts298-313


Tool Registration Architecture

The server exposes four tools through the MCP protocol using the server.registerTool() method. Each tool registration includes metadata, schemas, and a handler function.

Tool Registration Flow

server.registerTool() call sequence inside createPerplexityServer()


Tool Registration Structure

Each call to server.registerTool() takes three arguments:

  1. Tool name — the string identifier exposed to MCP clients (e.g., "perplexity_ask")
  2. Metadata objecttitle, description, inputSchema, outputSchema, and annotations
  3. Async handler — validates arguments, calls performChatCompletion() or performSearch(), and returns the MCP response object

See src/server.ts361-399 for the perplexity_ask registration as a representative example.

Schema Definition Pattern

All input schemas use Zod for type-safe validation. The messageSchema and shared filter fields are defined once and reused across multiple tool schemas:

src/server.ts315-359

Sources: src/server.ts315-359 src/server.ts361-529


MCP Protocol Compliance

The server implements the MCP protocol through several key mechanisms that ensure compatibility with MCP clients.

Protocol Compliance Components


Tool Metadata Annotations

Each registered tool includes standardized annotations that inform MCP clients about tool behavior:

AnnotationValueMeaning
readOnlyHinttrueTool does not modify state
openWorldHinttrueTool accesses live external data (web)
idempotentHintfalseRepeated identical calls may return different results
destructiveHintfalseTool does not delete or mutate any data

The idempotentHint: false value reflects the live nature of web-grounded results — the same query can return different content over time.

Sources: src/server.ts373-378 src/server.ts412-417 src/server.ts450-455 src/server.ts505-510


Input and Output Schema Definitions

The server uses Zod schemas for runtime validation and automatic JSON Schema generation for MCP clients.

Schema Components

Zod schema composition inside createPerplexityServer()


Schema Reuse Pattern

Three input schema variants are composed from shared field definitions and assigned to tools as follows:

SchemaUsed byFields
messagesOnlyInputSchemaperplexity_askmessages, search_recency_filter, search_domain_filter, search_context_size
messagesWithStripThinkingInputSchemaperplexity_reasonabove + strip_thinking
researchInputSchemaperplexity_researchmessages, strip_thinking, reasoning_effort

perplexity_search uses its own inline schema (searchInputSchema) with query, max_results, max_tokens_per_page, and country fields.

All chat-completion tools share responseOutputSchema (a single response string field). perplexity_search uses searchOutputSchema with a results string field.

Sources: src/server.ts315-359 src/server.ts481-493


Return Value Structure

Tool handlers return a standardized structure that conforms to MCP protocol requirements:

src/server.ts394-398

FieldTypePurpose
contentArrayMCP protocol-required content array
content[].type"text"Content type indicator
content[].textstringResponse text with appended citations
structuredContentObjectTyped structured output matching outputSchema
structuredContent.responsestringSame content as text, for schema-aware clients

The dual content / structuredContent representation ensures compatibility with MCP clients regardless of whether they prefer unstructured text or schema-validated structured data.

Sources: src/server.ts394-398 src/server.ts432-436 src/server.ts473-478 src/server.ts523-527


Service Origin Tracking

The createPerplexityServer() function accepts an optional serviceOrigin parameter that propagates through all API calls for telemetry purposes.


This parameter is included in the X-Service header of Perplexity API requests, enabling the server to track which transport mode (stdio vs HTTP) initiated each request.

Sources: src/server.ts333 src/server.ts427 src/server.ts166-172