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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.33.0"
".": "0.34.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 13
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai/perplexity-6a9e741f72f36fa6c1f8ece842ba1616376107badbfdeaf6e88c5db7b9412437.yml
openapi_spec_hash: 76d7c6e6e7f84a1de30b869a7579e6b6
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai/perplexity-a48f6cfc0c2120ede5bd103b3c7fce20079d5a8baece7dad3ddaf98955309329.yml
openapi_spec_hash: 5f4746838a4a9455b5413bb3f1a01b84
config_hash: 3f1487a29a16f85810ba4d77134da232
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 0.34.0 (2026-07-02)

Full Changelog: [v0.33.0...v0.34.0](https://github.com/perplexityai/perplexity-node/compare/v0.33.0...v0.34.0)

### Features

* **responses:** add `mcp` tool and typed `mcp_list_tools`/`mcp_call` output items ([38e23f1](https://github.com/perplexityai/perplexity-node/commit/38e23f16b2ae2d178815bede417d33e1a4a233e8))


### Bug Fixes

* **client:** send content-type header for requests with an omitted optional body ([ea14be8](https://github.com/perplexityai/perplexity-node/commit/ea14be8cd8fa67316a4edd0d998ad6721246f029))

## 0.33.0 (2026-06-08)

Full Changelog: [v0.32.0...v0.33.0](https://github.com/perplexityai/perplexity-node/compare/v0.32.0...v0.33.0)
Expand Down
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/perplexity_ai",
"version": "0.33.0",
"version": "0.34.0",
"description": "The official TypeScript library for the Perplexity API",
"author": "Perplexity <api@perplexity.ai>",
"types": "dist/index.d.ts",
Expand Down
10 changes: 9 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,11 +697,19 @@ export class Perplexity {
return () => controller.abort();
}

private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
private buildBody({ options }: { options: FinalRequestOptions }): {
bodyHeaders: HeadersLike;
body: BodyInit | undefined;
} {
const { body, headers: rawHeaders } = options;
if (!body) {
// A resource method always passes a `body` key when its operation defines a
// request body, even if the caller omitted an optional body param. Keep the
// content-type for those, and only elide it for operations with no body at
// all (e.g. GET/DELETE).
if (body == null && 'body' in options) {
return this.#encoder({ body, headers: buildHeaders([rawHeaders]) });
}
return { bodyHeaders: undefined, body: undefined };
}
const headers = buildHeaders([rawHeaders]);
Expand Down
154 changes: 153 additions & 1 deletion src/resources/responses/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,17 @@ export namespace InputItem {
}
}

/**
* One item in the response output: an assistant message, retrieved tool results,
* or a record of a tool call.
*/
export type OutputItem =
| OutputItem.MessageOutputItem
| OutputItem.SearchResultsOutputItem
| OutputItem.FetchURLResultsOutputItem
| FunctionCallOutputItem;
| FunctionCallOutputItem
| OutputItem.McpListToolsOutputItem
| OutputItem.McpCallOutputItem;

export namespace OutputItem {
export interface MessageOutputItem {
Expand Down Expand Up @@ -279,6 +285,68 @@ export namespace OutputItem {
url: string;
}
}

/**
* Tools discovered on one external MCP server at boot. Matches OpenAI's
* mcp_list_tools item.
*/
export interface McpListToolsOutputItem {
id: string;

server_label: string;

tools: Array<McpListToolsOutputItem.Tool>;

type: 'mcp_list_tools';

error?: string;
}

export namespace McpListToolsOutputItem {
/**
* One tool discovered on a remote MCP server.
*/
export interface Tool {
/**
* The server's JSON Schema for the tool, passed through unmodified.
*/
input_schema: { [key: string]: unknown };

name: string;

description?: string;
}
}

/**
* One tool call executed against an external MCP server, modeled on OpenAI's
* mcp_call item.
*/
export interface McpCallOutputItem {
id: string;

/**
* JSON-encoded arguments the model passed.
*/
arguments: string;

name: string;

server_label: string;

type: 'mcp_call';

/**
* The failure string when the call failed (also returned to the model in-band);
* null on success, matching OpenAI's mcp_call.
*/
error?: string | null;

/**
* Tool output text; empty when the call failed.
*/
output?: string;
}
}

/**
Expand Down Expand Up @@ -542,6 +610,10 @@ export namespace ResponseStreamChunk {
* output item (message or tool call) starts.
*/
export interface OutputItemAddedEvent {
/**
* One item in the response output: an assistant message, retrieved tool results,
* or a record of a tool call.
*/
item: ResponsesAPI.OutputItem;

output_index: number;
Expand All @@ -562,6 +634,10 @@ export namespace ResponseStreamChunk {
* output item (message or tool call) completes.
*/
export interface OutputItemDoneEvent {
/**
* One item in the response output: an assistant message, retrieved tool results,
* or a record of a tool call.
*/
item: ResponsesAPI.OutputItem;

output_index: number;
Expand Down Expand Up @@ -844,6 +920,7 @@ export interface ResponsesCreateParams {
| FunctionTool
| ResponsesCreateParams.FinanceSearchTool
| ResponsesCreateParams.SandboxTool
| ResponsesCreateParams.McpTool
>;
}

Expand Down Expand Up @@ -954,6 +1031,43 @@ export namespace ResponsesCreateParams {
*/
type: 'sandbox';
}

/**
* Connects a user-supplied remote MCP server. The worker discovers the server's
* tools at boot and calls them like native tools. Matches OpenAI's mcp tool.
* `require_approval`, `connector_id`, and `defer_loading` are not supported in v1
* and are ignored if sent: every call auto-runs, and only bring-your-own
* `server_url` is honored.
*/
export interface McpTool {
/**
* Unique per request, ^[a-zA-Z0-9_-]{1,64}$. Namespaces the server's tools.
*/
server_label: string;

/**
* HTTPS URL of the remote MCP server.
*/
server_url: string;

type: 'mcp';

/**
* Optional allowlist of tool names. Empty exposes all discovered tools.
*/
allowed_tools?: Array<string>;

/**
* An OAuth access token that can be used with a remote MCP server, with a custom
* MCP server URL. Never logged or echoed.
*/
authorization?: string;

/**
* Extra request headers. Never logged or echoed.
*/
headers?: { [key: string]: string };
}
}

export interface ResponsesUsage {
Expand Down Expand Up @@ -1160,6 +1274,7 @@ export interface ResponseCreateParamsBase {
| FunctionTool
| ResponseCreateParams.FinanceSearchTool
| ResponseCreateParams.SandboxTool
| ResponseCreateParams.McpTool
>;
}

Expand Down Expand Up @@ -1271,6 +1386,43 @@ export namespace ResponseCreateParams {
type: 'sandbox';
}

/**
* Connects a user-supplied remote MCP server. The worker discovers the server's
* tools at boot and calls them like native tools. Matches OpenAI's mcp tool.
* `require_approval`, `connector_id`, and `defer_loading` are not supported in v1
* and are ignored if sent: every call auto-runs, and only bring-your-own
* `server_url` is honored.
*/
export interface McpTool {
/**
* Unique per request, ^[a-zA-Z0-9_-]{1,64}$. Namespaces the server's tools.
*/
server_label: string;

/**
* HTTPS URL of the remote MCP server.
*/
server_url: string;

type: 'mcp';

/**
* Optional allowlist of tool names. Empty exposes all discovered tools.
*/
allowed_tools?: Array<string>;

/**
* An OAuth access token that can be used with a remote MCP server, with a custom
* MCP server URL. Never logged or echoed.
*/
authorization?: string;

/**
* Extra request headers. Never logged or echoed.
*/
headers?: { [key: string]: string };
}

export type ResponseCreateParamsNonStreaming = ResponsesAPI.ResponseCreateParamsNonStreaming;
export type ResponseCreateParamsStreaming = ResponsesAPI.ResponseCreateParamsStreaming;
}
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.33.0'; // x-release-please-version
export const VERSION = '0.34.0'; // x-release-please-version