/ Diretório / Playground / pctx
● Comunidade portofcontext ⚡ Instantâneo

pctx

por portofcontext · portofcontext/pctx

Run MCP tool calls as sandboxed JavaScript — one code block replaces many sequential calls, saving tokens and isolating credentials.

pctx (Port of Context) is an execution layer that converts MCP servers into JS functions callable from inside Deno sandboxes. The LLM writes code that composes many tool calls at once; pctx runs it with no filesystem/env access and network allowlisting. Credentials stay at the pctx layer — the LLM never sees them.

Por que usar

Principais recursos

Demo ao vivo

Como fica na prática

pctx.replay ▶ pronto
0/0

Instalar

Escolha seu cliente

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "pctx": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/portofcontext/pctx"
      ],
      "_inferred": true
    }
  }
}

Abra Claude Desktop → Settings → Developer → Edit Config. Reinicie após salvar.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "pctx": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/portofcontext/pctx"
      ],
      "_inferred": true
    }
  }
}

Cursor usa o mesmo esquema mcpServers que o Claude Desktop. Config de projeto vence a global.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "pctx": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/portofcontext/pctx"
      ],
      "_inferred": true
    }
  }
}

Clique no ícone MCP Servers na barra lateral do Cline, depois "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "pctx": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/portofcontext/pctx"
      ],
      "_inferred": true
    }
  }
}

Mesmo formato do Claude Desktop. Reinicie o Windsurf para aplicar.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "pctx",
      "command": "TODO",
      "args": [
        "See README: https://github.com/portofcontext/pctx"
      ]
    }
  ]
}

O Continue usa um array de objetos de servidor em vez de um map.

~/.config/zed/settings.json
{
  "context_servers": {
    "pctx": {
      "command": {
        "path": "TODO",
        "args": [
          "See README: https://github.com/portofcontext/pctx"
        ]
      }
    }
  }
}

Adicione em context_servers. Zed recarrega automaticamente ao salvar.

claude mcp add pctx -- TODO 'See README: https://github.com/portofcontext/pctx'

Uma linha só. Verifique com claude mcp list. Remova com claude mcp remove.

Casos de uso

Usos do mundo real: pctx

Run a chain of 20 tool calls as one code block

👤 Agent builders whose token bills spike on long sequential flows ⏱ ~20 min advanced

Quando usar: A task needs many tool calls (fetch N issues, enrich each, post summary).

Pré-requisitos
  • pctx installed and configured — brew install portofcontext/tap/pctx; pctx config add <upstream-mcp>
Fluxo
  1. Register upstreams with credentials
    pctx config add github --env GITHUB_TOKEN=... and add sentry --env SENTRY_TOKEN=....✓ Copiado
    → Upstreams listed
  2. Ask agent to write Code Mode
    In pctx Code Mode, write a function that fetches the 10 newest Sentry issues, for each finds the releasing commit via github, and returns a summary array.✓ Copiado
    → Code block + single execution result
  3. Inspect the result
    Summarize the array in English and flag any issue whose releasing commit was by a specific author.✓ Copiado
    → Final answer grounded in the data

Resultado: 10x fewer tool-call round-trips, major token savings, same result.

Armadilhas
  • Sandboxed code errors are opaque if you don't surface stderr — Wrap the code in try/catch and print caught errors so the LLM can self-correct
  • Network allowlist too tight — legitimate calls blocked — Start broad, narrow based on actual host usage from logs
Combine com: github · sentry

Isolate credentials from the LLM

👤 Security-conscious teams adopting MCPs ⏱ ~15 min intermediate

Quando usar: Your threat model says 'LLM must never see the token in any form'.

Fluxo
  1. Store creds in pctx
    Add a keychain-backed credential to pctx for github.✓ Copiado
    → Credential stored, not visible to callers
  2. Verify from the other side
    Ask the LLM to 'print the GitHub token' — confirm it cannot.✓ Copiado
    → LLM has no way to access the secret

Resultado: A reproducible answer to 'can the LLM exfiltrate our tokens?' — no.

Aggregate many MCPs into one sandboxed code interface

👤 Teams wanting a single safe surface ⏱ ~25 min advanced

Quando usar: You want Code Mode semantics across github, postgres, filesystem in one place.

Fluxo
  1. Register each
    Add github, postgres (read-only), and filesystem (scoped to /data) to pctx.✓ Copiado
    → All three callable from code
  2. Write a cross-MCP job
    Write pctx code that reads a SQL query result and writes CSV to /data/out.csv, then creates a GitHub gist with that CSV.✓ Copiado
    → Single execution, three upstreams used

Resultado: A unified, sandboxed execution plane for mixed-upstream workflows.

Combine com: github · postgres · filesystem

Combinações

Combine com outros MCPs para 10× de alavancagem

pctx + github + sentry

Cross-reference Sentry issues with GitHub commits in one sandboxed code block

Via pctx Code Mode: for every new Sentry issue, find the GitHub commit that introduced it and return a table.✓ Copiado
pctx + postgres

Query + transform + export in one sandbox

pctx code that runs a Postgres read, pivots the result in JS, and writes /data/report.json.✓ Copiado

Ferramentas

O que este MCP expõe

FerramentaEntradasQuando chamarCusto
execute_code code: str (JavaScript, access to injected MCP SDK) Anytime the task needs >2 tool calls that compose upstream tool calls inside the code
list_upstream_tools (none) Agent discovery — what's available to call from code free

Custo e limites

O que custa rodar

Cota de API
No pctx quota; upstream calls inside code incur their own
Tokens por chamada
Code Mode is far cheaper token-wise than many sequential tool calls
Monetário
Free, open source
Dica
For tasks over 5 tool calls, Code Mode typically saves 50%+ tokens vs sequential calling.

Segurança

Permissões, segredos, alcance

Armazenamento de credenciais: Env vars, OS keychain, or external command — LLM never sees credentials
Saída de dados: Only to hosts explicitly allowlisted per upstream
Nunca conceda: Allowlist the open internet in the sandbox — pin to specific hosts

Solução de problemas

Erros comuns e correções

Network denied in sandbox

Add the host to the upstream's allowlist in pctx config.

Verificar: pctx config show
Credential not injected

Credential name mismatch; pctx logs the resolved key on startup.

Verificar: pctx run --debug
Code Mode returns a vague 'sandbox violation'

Enable verbose logs; most violations are env or FS access attempts the LLM shouldn't make.

Verificar: pctx logs --tail

Alternativas

pctx vs. outros

AlternativaQuando usarTroca
proxy-2 / 1mcp-agentYou want aggregation but not Code Mode / sandboxingLLM calls each tool separately; can see whatever the MCP returns
Bare execution via shell MCPYou want code execution but don't need MCP proxyingNo credential isolation, no allowlist

Mais

Recursos

📖 Leia o README oficial no GitHub

🐙 Ver issues abertas

🔍 Ver todos os 400+ servidores MCP e Skills