pctx CLI

pctx turns tools and MCP servers into code that an agent runs in a sandbox instead of passing every result through its context.

  • 286 ★ on the repository
  • Last commit
  • MIT
CLI

Extended access

Why this level

  • Model-written code runs in a sandbox with allowed network hosts.
  • Connected MCP servers act under your authorization.
All reasons and checks

portofcontext/pctx

Install

Manual install

brew install portofcontext/tap/pctx

Other options: a cURL script and `npm i -g @portofcontext/pctx`. Then `pctx code-mode init`.

Access and checks

How we review

Extended accessThe tool runs code or makes network calls and only reads external data.

  • Model-written code runs in a sandbox with allowed network hosts.
  • Connected MCP servers act under your authorization.

This is third-party code. Review the repository files before installing.

What it does

pctx is an open execution layer for tool calls in Code Mode. Instead of calling tools one at a time and returning a thousand rows to context, the agent writes TypeScript that runs in an isolated Deno sandbox. That code reaches the network only through hosts listed in the configuration. There are two modes. The unified MCP server puts connected MCP servers behind one interface and keeps sessions between `execute_typescript` calls: `pctx code-mode init`, `pctx code-mode add` and `pctx code-mode dev` or `start --stdio`. The session server `pctx code-mode serve` works with the `pctx-client` Python SDK for agents built on the OpenAI Agents SDK and similar.

Who it is for. Agent developers whose MCP servers return big responses that flood context and burn tokens on passing intermediate data.

Good fit when

  • A thousand-row table passes through context although the agent needs fifty rows.
  • Several MCP servers are attached to the agent and should sit behind one entry point.
  • Authorization to MCP servers must persist between calls.
  • Model-written code must reach only a limited list of network hosts.

Not a fit when

  • The task is one simple tool call and the layer only adds complexity.
  • You need a Node SDK, which the README marks as coming soon.
  • The environment forbids running Deno and executing generated code.

Example request

Connect Stripe and memory MCP servers through pctx, start it as a stdio server and pick only last week's refunds from the payments table.

Limitations

The agent executes generated code, so sandbox limits and the list of allowed network hosts must be set explicitly. The Python SDK is an HTTP client for the `pctx` server and the Node SDK is still promised. For automatic install the README offers a `curl | sh` script, so read it before running. Connected MCP servers such as Stripe perform real operations under your authorization, so limit their permissions. The last repository commit is from November 2026.

How to disable. Remove the `pctx` entry from the client's MCP configuration and the package you used: `brew uninstall pctx` or `npm uninstall -g @portofcontext/pctx`. Delete `pctx.json` manually.

FAQ

What is Code Mode?

The agent writes code that runs in a sandbox and filters data itself. The result returns to context already condensed.

How do I connect an MCP server?

With `pctx code-mode add`, for example `pctx code-mode add stripe https://mcp.stripe.com`, or `--command` for stdio servers.

How do I install it?

Through Homebrew `brew install portofcontext/tap/pctx`, a cURL script or `npm i -g @portofcontext/pctx`.

What does the sandbox restrict?

Code runs in isolated Deno and may reach only the network hosts in the configuration file.

What is the Python SDK for?

It brings Code Mode to Python agents with custom tools and MCP servers. It is an HTTP client of the `pctx` server.

Discussion

No questions or reviews yet.

CLI tools

Lets an agent call MCP and UTCP tools by running code: discover tools, get typed code and run chains instead of dozens of separate calls

CLIBroad access1.7KRepository stars

An MCP bridge: a single run_python tool runs code in a container and calls your MCP servers

MCP serverBroad access343Repository stars

A universal MCP CLI client from Apify: persistent sessions, OAuth, JSON output for scripts and shell access to any MCP server for agents

CLIBroad access1.1KRepository stars

An MCP server that keeps large tool output out of the agent's context window and stores session memory in SQLite

MCP serverExtended access34KRepository stars

A CLI that turns any MCP server, OpenAPI spec or GraphQL endpoint into commands at runtime, with no codegen

CLIBroad access2.4KRepository stars

A CLI for any MCP server: list and call tools, resources and prompts, run mock and proxy modes, guard access and manage agent configs

CLIExtended access1.6KRepository stars

README in short

The README covers installation, two modes, the Python SDK, the unified MCP, a Code Mode example and sandbox properties. MIT license.

README badge

Report a problem