npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@benvargas/pi-claude-code-use

v1.0.4

Published

Patch Anthropic OAuth payloads and companion tools for Claude Code-style subscription use

Readme

@benvargas/pi-claude-code-use

pi-claude-code-use keeps Pi's built-in anthropic provider intact and applies the smallest payload changes needed for Anthropic OAuth subscription use in Pi.

It does not register a new provider or replace Pi's Anthropic request transport. Pi core remains in charge of OAuth transport, headers, model definitions, and streaming.

What It Changes

When Pi is using Anthropic OAuth, this extension intercepts outbound API requests via the before_provider_request hook and:

  • System prompt rewrite -- rewrites a small set of Pi-identifying prompt phrases in system prompt text:
    • pi itselfthe cli itself
    • pi .md filescli .md files
    • pi packagescli packages Preserves Pi's original system[] structure, cache_control metadata, and non-text blocks.
  • Tool filtering -- passes through core Claude Code tools, Anthropic-native typed tools (e.g. web_search), and any tool prefixed with mcp__. Unknown flat-named tools are filtered out.
  • Companion tool remapping -- renames known companion extension tools from their flat names to MCP-style aliases (e.g. web_search_exa becomes mcp__exa__web_search). Duplicate flat entries are removed after remapping.
  • tool_choice remapping -- if tool_choice references a flat companion name that was remapped, the reference is updated to the MCP alias. If it references a tool that was filtered out, tool_choice is removed from the payload.
  • Message history rewriting -- tool_use blocks in conversation history that reference flat companion names are rewritten to their MCP aliases so the model sees consistent tool names across the conversation.
  • Companion alias registration -- at session start and before each agent turn, discovers loaded companion extensions, captures their tool definitions via a jiti-based shim, and registers MCP-alias copies so Anthropic sees Claude Code-compatible names.
  • Managed tool-call unaliasing -- when the model calls an MCP alias registered by this extension, rewrites the finalized toolCall name back to the original flat tool name during message_end, before Pi resolves execution. Direct MCP tools from other extensions are left untouched.
  • Alias activation tracking -- auto-activates MCP aliases when their flat counterpart is active under Anthropic OAuth. Tracks provenance (auto-managed vs user-selected) so that disabling OAuth only removes auto-activated aliases, preserving any the user explicitly enabled.

Non-OAuth Anthropic usage and non-Anthropic providers are left completely unchanged.

Install

pi install npm:@benvargas/pi-claude-code-use

Or load it directly without installing:

pi -e /path/to/pi-packages/packages/pi-claude-code-use/extensions/index.ts

Usage

Install the package and continue using the normal anthropic provider with Anthropic OAuth login:

/login anthropic
/model anthropic/claude-opus-4-6

No extra configuration is required.

Environment Variables

| Variable | Description | |---|---| | PI_CLAUDE_CODE_USE_DEBUG_LOG | Set to a file path to enable debug logging. Writes two JSON entries per Anthropic OAuth request: one with "stage": "before" (the original payload from Pi) and one with "stage": "after" (the transformed payload sent to Anthropic). | | PI_CLAUDE_CODE_USE_DISABLE_TOOL_FILTER | Set to 1 to disable tool filtering. System prompt rewriting still applies, but all tools pass through unchanged. Useful for debugging whether a tool-filtering issue is causing a problem. |

Example:

PI_CLAUDE_CODE_USE_DEBUG_LOG=/tmp/pi-claude-debug.log pi -e /path/to/extensions/index.ts --model anthropic/claude-sonnet-4-20250514

Companion Tool Aliases

When these companion extensions from this monorepo are loaded alongside pi-claude-code-use, MCP aliases are automatically registered and remapped:

| Flat name | MCP alias | |---|---| | web_search_exa | mcp__exa__web_search | | get_code_context_exa | mcp__exa__get_code_context | | firecrawl_scrape | mcp__firecrawl__scrape | | firecrawl_map | mcp__firecrawl__map | | firecrawl_search | mcp__firecrawl__search |

How companion discovery works

The extension identifies companion tools by matching sourceInfo metadata that Pi attaches to each registered tool:

  1. baseDir match -- if the tool's sourceInfo.baseDir directory name matches the companion's directory name (e.g. pi-exa-mcp).
  2. Path match -- if the tool's sourceInfo.path contains the companion's scoped package name (e.g. @benvargas/pi-exa-mcp) or directory name as a path segment. This handles npm installs, git clones, and monorepo layouts where baseDir points to the repo root rather than the individual package.

Once a companion tool is identified, its extension factory is loaded via jiti into a capture shim to obtain the full tool definition, which is then re-registered under the MCP alias name. Those alias copies are model-facing compatibility shims; when the assistant actually calls one of these managed aliases, pi-claude-code-use rewrites the finalized toolCall back to the original flat name before Pi executes the tool. This preserves the source extension's original execute closure and state.

User-Defined Tool Aliases

To register MCP-style aliases for flat-named tools from other installed extensions, create ~/.pi/agent/extensions/pi-claude-code-use.json (global) or <project>/.pi/extensions/pi-claude-code-use.json (project). Schema:

{
  "toolAliases": [
    ["subagent", "mcp__subagent__run"],
    ["linear_search", "mcp__linear__search"]
  ]
}

Each entry maps an existing flat Pi tool name to the MCP-style name Anthropic should see. Use the flat tool name exactly as the source extension registers it; choose an MCP alias in the form mcp__<namespace>__<tool>.

Aliases registered through this config are treated the same as the built-in companion aliases: Anthropic sees the MCP-style name, but managed alias calls are canonicalized back to the flat source tool before local execution. MCP-style tools that are provided directly by another extension are not rewritten unless pi-claude-code-use registered that same alias.

The project file replaces the global file as a whole. Set "toolAliases": [] in the project file to disable inherited globals.

Core Tools Allowlist

The following tool names always pass through filtering (case-insensitive). This list mirrors Pi core's claudeCodeTools in packages/ai/src/providers/anthropic.ts:

Read, Write, Edit, Bash, Grep, Glob, AskUserQuestion, EnterPlanMode, ExitPlanMode, KillShell, NotebookEdit, Skill, Task, TaskOutput, TodoWrite, WebFetch, WebSearch

Additionally, any tool with a type field (Anthropic-native tools like web_search) and any tool prefixed with mcp__ always passes through provider-request filtering. Direct MCP tools remain direct MCP tools; only aliases registered by pi-claude-code-use are rewritten back to flat names before local execution.

Guidance For Extension Authors

Anthropic's OAuth subscription path appears to fingerprint tool names. Flat extension tool names such as web_search_exa were rejected in live testing, while MCP-style names such as mcp__exa__web_search were accepted.

If you want a custom tool to survive Anthropic OAuth filtering cleanly, prefer registering it directly under an MCP-style name:

mcp__<server>__<tool>

Examples:

  • mcp__exa__web_search
  • mcp__firecrawl__scrape
  • mcp__mytools__lookup_customer

If an extension keeps a flat legacy name for non-Anthropic use, it can also register an MCP-style alias alongside it. pi-claude-code-use already does this centrally for the known companion tools in this repo, but unknown non-MCP tool names will still be filtered out on Anthropic OAuth requests.

Notes

  • The extension activates for all Anthropic OAuth requests regardless of model, rather than using a fixed model allowlist.
  • Non-OAuth Anthropic usage (API key auth) is left unchanged.
  • In practice, unknown non-MCP extension tools were the remaining trigger for Anthropic's extra-usage classification, so this package keeps core tools, keeps MCP-style tools, auto-aliases the known companion tools above, and filters the rest.
  • Pi may show its built-in OAuth subscription warning banner even when the request path works correctly. That banner is UI logic in Pi, not a signal that the upstream request is being billed as extra usage.