pi-codemode-mcp

pi-codemode-mcp

An MCP extension that allows coding agents to manage and compose MCP tools by executing JavaScript in a sandboxed environment. It features tools for listing available MCP capabilities and a management command for handling authentication and tool policies.

Category
Visit Server

README

pi-codemode-mcp

Pi extension that exposes MCP through two tools:

  • list_mcp_tools — enumerates all MCP tools (shows first 20 inline, overflows full list to a temp file)
  • call_mcp — runs JavaScript in a sandbox and lets the script call MCP servers

It also adds a /mcp command for status, enable/disable, reconnect, and auth setup.

Why?

This was an experiment to see if there is an efficiency benefit of allowing a coding agent interface with MCP in a way that allows composition. See this blog post.

The actual findings are that with how MCP works today, such efficiency gains are not useful. On the other hand an MCP server that uses code internally can be very helpful. See for instance an example MCP server that uses a JavaScript environment to call Google services. That one actually performs as well as a similar skill does.

Configuration files

Loaded in merge order (later overrides earlier):

  1. ~/.pi/agent/mcp.json
  2. ~/.pi/agent/.mcp.json
  3. <cwd>/.pi/mcp.json
  4. <cwd>/.mcp.json

You can override with --mcp-config /path/to/file.json.

list_mcp_tools

Parameters:

  • query (optional): case-insensitive text match, or regex via /pattern/flags

The tool always shows the first 20 matches inline. If more matches exist, it writes the full list to a temp .tsv file so the agent can grep/rg it.

Each listed MCP tool includes a compact schema signature, with required fields marked by * and optional fields in brackets.

Only currently enabled MCP tools are listed.

/mcp command

Use /mcp to manage MCP from interactive mode:

  • /mcp — opens an interactive select menu (status, reconnect, auth, and per-server tool toggles)
  • /mcp status — show server connection/auth state + enabled/disabled counts
  • /mcp enable <server> <tool|all> — enable a specific MCP tool (or all tools for server)
  • /mcp disable <server> <tool|all> — disable a specific MCP tool (or all tools for server)
  • /mcp reconnect [server] — reconnect one/all servers and refresh metadata
  • /mcp auth <server> — trigger auth setup flow

Tool enable/disable policies are persisted in:

  • ~/.pi/agent/mcp-tool-policies.json

Auth behavior

  • OAuth flow (standard MCP auth)
    • /mcp auth <server> starts an OAuth browser login flow with localhost callback (for URL-based servers).
    • received tokens are stored in: ~/.pi/agent/mcp-oauth/<server>/tokens.json
    • then the server is reconnected.
    • if a server's auth metadata does not support dynamic client registration, /mcp auth falls back to bearer setup for the current session (for GitHub Copilot MCP, it will try gh auth token automatically).
  • Bearer servers (auth: "bearer" or bearer token config)
    • if bearerTokenEnv is configured, /mcp auth <server> lets you paste a token into that env var for the current pi process.
    • if no bearerTokenEnv, it stores token in memory for the current session.

For OAuth servers that require pre-registered clients, you can provide:

  • oauthClientId
  • oauthClientSecret (optional)
  • oauthClientMetadataUrl (optional)
  • oauthTokenEndpointAuthMethod (optional)

in the server config entry.

call_mcp

call_mcp takes JavaScript code only (plus optional timeout/state reset). Prefer batching: solve each user task in one script and use Promise.all for independent calls. Inside the script:

  • await call(server, tool, args)
  • await readResource(server, uri)
  • listTools(query?)
  • servers (array of configured server names)
  • tools (map of server -> tool names)
  • resources (map of server -> resources)
  • state (persistent mutable object across calls)

Only tools currently enabled in MCP policy are visible/callable from call_mcp.

call(server, tool, args) throws on MCP tool errors (instead of returning nested isError) and includes parameter hints from schema. It also attempts one snake_case → camelCase retry for validation errors.

Example:

const screenshots = await call("chrome-devtools", "take_screenshot", { format: "png" });
const repos = await call("github", "search_repositories", { query: "pi-mono" });

return {
  screenshot: screenshots,
  repos,
  knownServers: servers,
  firstChromeTools: tools["chrome-devtools"]?.slice(0, 10)
};

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured