Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
},
"metadata": {
"description": "Official Perplexity AI plugin providing real-time web search, reasoning, and research capabilities",
"version": "1.2.0"
"version": "1.2.1"
},
"plugins": [
{
"name": "perplexity",
"source": "./",
"description": "Real-time web search, reasoning, and research through Perplexity's API",
"version": "1.2.0",
"version": "1.2.1",
"author": {
"name": "Perplexity AI",
"email": "api@perplexity.ai"
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@perplexity-ai/mcp-server",
"version": "1.2.0",
"version": "1.2.1",
"mcpName": "ai.perplexity/mcp-server",
"description": "Real-time web search, reasoning, and research through Perplexity's API",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
"name": "perplexity",
"version": "1.2.0",
"version": "1.2.1",
"description": "Real-time web search, reasoning, and research through Perplexity's API",
"author": {
"name": "Perplexity AI",
Expand Down
4 changes: 2 additions & 2 deletions server.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"name": "ai.perplexity/mcp-server",
"title": "Perplexity API Platform",
"description": "Real-time web search, reasoning, and research through Perplexity's API",
"version": "1.2.0",
"version": "1.2.1",
"packages": [
{
"registryType": "npm",
"identifier": "@perplexity-ai/mcp-server",
"version": "1.2.0",
"version": "1.2.1",
"transport": {
"type": "stdio"
}
Expand Down
4 changes: 2 additions & 2 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ describe("Perplexity MCP Server", () => {
headers: {
"Content-Type": "application/json",
Authorization: "Bearer test-api-key",
"User-Agent": "perplexity-mcp/1.2.0",
"User-Agent": "perplexity-mcp/1.2.1",
"X-Source": "pplx-mcp-server",
"X-Pplx-Integration": "perplexity-mcp/1.2.0",
"X-Pplx-Integration": "perplexity-mcp/1.2.1",
},
body: JSON.stringify({
preset: "fast",
Expand Down
28 changes: 28 additions & 0 deletions src/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,31 @@ describe("Server Utility Functions", () => {
});
});
});

describe("createPerplexityServer tools/list schemas", () => {
it("advertises JSON Schema 2020-12 on every input and output schema", async () => {
vi.stubEnv("PERPLEXITY_API_KEY", "pplx-test");
const { Client } = await import("@modelcontextprotocol/sdk/client/index.js");
const { InMemoryTransport } = await import("@modelcontextprotocol/sdk/inMemory.js");
const { createPerplexityServer } = await import("./server.js");

const server = createPerplexityServer();
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
await server.connect(serverTransport);
const client = new Client({ name: "test", version: "0.0.0" });
await client.connect(clientTransport);

const { tools } = await client.listTools();
expect(tools.length).toBeGreaterThan(0);
for (const tool of tools) {
expect(tool.inputSchema.$schema, `${tool.name} inputSchema`).toBe(
"https://json-schema.org/draft/2020-12/schema"
);
expect(tool.outputSchema?.$schema, `${tool.name} outputSchema`).toBe(
"https://json-schema.org/draft/2020-12/schema"
);
}
await client.close();
await server.close();
});
});
39 changes: 38 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type { ApiKeyProvider, PerplexityServerOptions } from "./types.js";

const PERPLEXITY_API_KEY = process.env.PERPLEXITY_API_KEY;
const PERPLEXITY_BASE_URL = process.env.PERPLEXITY_BASE_URL || "https://api.perplexity.ai";
const VERSION = "1.2.0";
const VERSION = "1.2.1";

// Agent API presets backing each tool: https://docs.perplexity.ai/docs/agent-api/presets
export const ASK_PRESET = "fast";
Expand Down Expand Up @@ -776,5 +776,42 @@ export function createPerplexityServer(serviceOrigin?: string, serverOptions?: P
}
);

advertiseJsonSchema202012(server.server);

return server.server;
}

// The MCP TypeScript SDK stamps draft-07 on tools/list schemas
// (modelcontextprotocol/typescript-sdk#2084); 2020-12-only clients reject
// them. The schemas are valid under both dialects, so only the declared
// dialect needs rewriting. Remove once typescript-sdk#2085 ships.
const JSON_SCHEMA_2020_12 = "https://json-schema.org/draft/2020-12/schema";

function advertiseJsonSchema202012(server: McpServer["server"]) {
type ListToolsHandler = (request: unknown, extra: unknown) => Promise<{
tools: Array<{
inputSchema?: { $schema?: string };
outputSchema?: { $schema?: string };
}>;
}>;
// _requestHandlers is private SDK state; goes away with this shim.
const handlers = (server as unknown as {
_requestHandlers: Map<string, ListToolsHandler>;
})._requestHandlers;
const listTools = handlers.get("tools/list");
if (!listTools) {
return;
}
handlers.set("tools/list", async (request, extra) => {
const result = await listTools(request, extra);
for (const tool of result.tools ?? []) {
if (tool.inputSchema?.$schema) {
tool.inputSchema.$schema = JSON_SCHEMA_2020_12;
}
if (tool.outputSchema?.$schema) {
tool.outputSchema.$schema = JSON_SCHEMA_2020_12;
}
}
return result;
});
}