Pctx

Developer tools

Pctx is the execution layer for agentic tool calls. It auto-converts agent tools and MCP servers into code that runs in secure sandboxes for token-efficient workflows.

Your AI app calls the Pctx MCP server, which does the developer tools work and sends the result back to the chat.

About Pctx

Pctx is a community MCP server from portofcontext, filed in our directory under developer tools. Pctx is the execution layer for agentic tool calls. It auto-converts agent tools and MCP servers into code that runs in secure sandboxes for token-efficient workflows.

Pctx runs on your own machine: your AI app starts it with the command npx -y @modelcontextprotocol/server-memory and talks to it over standard input and output.

At a glance

Publisher
portofcontext (community)
Runs
Locally on your machine
Install from
Node.js package on npm: @modelcontextprotocol/server-memory
Written in
Rust
License
MIT
GitHub stars
292

How to set up Pctx

  1. Install Node.js on the machine that runs your AI app, because Pctx starts with npx and downloads its package on first run.
  2. Check the Pctx README for keys or settings; the registry lists none that Pctx requires.
  3. Add Pctx to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the Pctx tools to confirm the connection.
  5. Run one read-only task with Pctx first, and keep your app asking before each tool call until the results look right.

Pctx compared with similar servers

  • Apple Health (the-momentum) by the-momentum has fewer GitHub stars than Pctx (291 against 292); both are community servers, and both run locally.
  • Kmsg by channprj has fewer GitHub stars than Pctx (292 against 292); both are community servers, and both run locally.
  • Argo by taxueseek has fewer GitHub stars than Pctx (291 against 292); both are community servers, and both run locally.

Before you connect Pctx

  • Give Pctx its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each Pctx tool call until you trust what it does with them.
  • Treat text that Pctx fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for Pctx on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for Pctx

How marketing and sales teams put Pctx to work, by company size. Pick the size closest to yours and start Pctx on one use case.

Small business

  • A small business with a developer can use Pctx to ship site and tracking fixes faster, with the AI reading the code it changes.
  • Technical founders can ask Pctx to explain and fix a marketing site issue without context switching between tools.
  • Pctx runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Growth engineers can use Pctx to build landing pages, tracking and integrations in fewer cycles, with reviews kept in the normal flow.
  • Marketing ops engineers can connect Pctx to keep scripts and automations documented and versioned as they change.
  • Start Pctx on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprise engineering teams can roll out Pctx with repo scopes and audit logs, so agents work only where they are allowed.
  • Platform teams can standardize on Pctx so web and marketing engineering share one reviewed way of working with AI.
  • Pctx is a community server, so have security review the code and pin a version before Pctx touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

Pctx README

From portofcontext/pctx on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

pctx

The open source framework to connect AI agents to tools and mcp with Code Mode


, T R U S T E D B Y,

Install

# Homebrew
brew install portofcontext/tap/pctx

# cURL
curl --proto '=https' --tlsv1.2 -LsSf https://raw.githubusercontent.com/portofcontext/pctx/main/install.sh | sh

# npm
npm i -g @portofcontext/pctx

Core Functionality

pctx can be run as a scalable session server for Code Mode or as a lightweight unified MCP server that exposes Code Mode functionality for registered upstream MCP servers.

# Start the Code Mode session server for the Python SDK
pctx code-mode serve

# Start Code Mode as a unified MCP server
pctx code-mode init
pctx code-mode dev

Python SDK

Use the Python SDK if building agents in Python and want to run Code Mode with custom tools and/or MCP servers. The Python SDK is an HTTP client to the pctx server.

pip install pctx-client
from pctx_client import Pctx, tool
from agents import Agent # Use any Agent SDK
from agents.run import Runner # This example is OpenAI Agents SDK

@tool
def get_weather(city: str) -> str:
    """Get weather information for a given city."""
    return f"It's always sunny in {city}!"

pctx = Pctx(tools=[get_weather]) # or with mcp: servers=[your_mcp]

tools = pctx.openai_agents_tools() # Run Code Mode with any Agent SDK
agent = Agent(
    name="GreatCoder",
    model="litellm/openrouter/openai/gpt-oss-120b",
    instructions="You run code to complete complex tasks.",
    tools=tools,
)
Links

Node SDK

Coming soon

Unified MCP

Use the unified MCP to run Code Mode with MCP servers and want to persist the authentication connections and you do not need to use agent tools (non-mcp tools).

# Initialize config for upstream mcp connections
pctx code-mode init

# Add HTTP or stdio MCP servers
pctx code-mode add stripe https://mcp.stripe.com
pctx code-mode add memory --command "npx -y @modelcontextprotocol/server-memory"

# Start as HTTP server (dev mode with UI)
pctx code-mode dev

# Or start as stdio MCP server
pctx code-mode start --stdio

For complete CLI documentation, see CLI.md. For configuration options, see Configuration Guide.

What is pctx?

pctx sits between AI agents and MCP servers. It aggregates multiple upstream MCP servers, handles authentication, and exposes tools through a unified Code Mode interface. Instead of agents managing connections to individual MCP servers, they connect once to pctx.

What is Code Mode?

Code mode replaces sequential tool calling with code execution. Rather than an agent calling tools one at a time and passing results through its context window, it writes code that executes in a sandbox. Read Anthropic's overview anthropic.com/engineering/code-execution-with-mcp.

Traditional MCP flow:

  1. Agent calls getSheet(id)
  2. Server returns 1000 rows → agent's context
  3. Agent calls filterRows(criteria)
  4. Server returns 50 rows → agent's context

With Code Mode:

const sheet = await gdrive.getSheet({ sheetId: "abc" });
const orders = sheet.filter((row) => row.status === "pending");
console.log(`Found ${orders.length} orders`);

Result: 98.7% reduction in tokens (150k → 2k) for this multi-step operation.

Features

  • Code Mode interface: Tools exposed as code functions for efficient agent interaction. See Code Mode Guide.
  • Upstream MCP server aggregation: Connect to multiple MCP servers through a single interface, with persistent upstream sessions across execute_typescript calls. See Upstream MCP Servers Guide.
  • Simple config with CLI: Create the pctx.json config with a simple CLI. pctx.json manages auth, upstream MCPs, logging, and more. See Config Guide.
  • Secure authentication: Source secrets from environment variables, system keychain, and external commands. See Authentication Section in the CLI configuration docs for more details.

Security

  • LLM generated code runs in an isolated Deno sandbox that can only access the network hosts specified in the configuration file.
  • No filesystem, environment, network (beyond allowed hosts), or system access.
  • MCP clients are authenticated in pctx. LLMs can never see your auth.

Update

Depending on the installation method (Homebrew/npm/cURL) the update method is different. Run which pctx if you are unsure what you used to install it.

# Homebrew update
brew upgrade pctx

# cURL update
pctx-update

# npm update
npm upgrade -g @portofcontext/pctx

Develop

  • For core dev: install rust and jump into crates/
  • Client SDK dev: find the README in the SDK

Learn More

Questions about Pctx

What is the Pctx MCP server?

Pctx is the execution layer for agentic tool calls. It auto-converts agent tools and MCP servers into code that runs in secure sandboxes for token-efficient workflows. Pctx is maintained by portofcontext on GitHub at portofcontext/pctx, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the Pctx MCP server?

Add Pctx to your AI app's MCP config with the command npx -y @modelcontextprotocol/server-memory. In Claude Code, run claude mcp add --transport stdio pctx -- npx -y @modelcontextprotocol/server-memory. To run Pctx this way you need Node.js installed.

Does Pctx need an API key?

The registry lists no required keys for Pctx. Check the Pctx README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is Pctx an official MCP server?

No. Pctx is a community server maintained by portofcontext. Community servers can be excellent; read the code and the open issues before you give Pctx access to company data.

What license is Pctx under?

Pctx is released under the MIT license, according to its GitHub repository. The license covers the code of Pctx; the service it connects to has its own terms.