Skip to content

feat(pi): inject first-party local MCP tools - #4001

Closed
jonathanlab wants to merge 3 commits into
mainfrom
fix/pi-local-tools
Closed

feat(pi): inject first-party local MCP tools#4001
jonathanlab wants to merge 3 commits into
mainfrom
fix/pi-local-tools

Conversation

@jonathanlab

Copy link
Copy Markdown
Contributor

Summary

  • expose the shared posthog-code-tools MCP server to Pi cloud runs through Pi runtime capabilities
  • move the local-tools MCP server out of the Codex adapter and reuse it from Pi
  • remove the redundant Pi runtime factory and centralize capability-to-MCP resolution in createPiRpcClient
  • package the MCP child with the Electron main build and resolve it from the Vite runtime

Testing

  • pnpm --filter agent build
  • pnpm --filter code typecheck
  • targeted agent, harness, workspace-server, and desktop Pi tests

upload_artifact remains cloud-only; normal desktop Pi sessions retain local capabilities.

@trunk-io

trunk-io Bot commented Jul 30, 2026

Copy link
Copy Markdown

🚫 This pull request was removed from the merge queue because it was canceled by Jonathan Mieloo (a GitHub user). See more details here.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 0573a01.

Comment on lines +175 to +179
},
{
name: "Pi local-tools MCP server",
source: "adapters/local-tools/mcp-server.js",
destination: "mcp-server.js",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 MCP child remains inside ASAR

When a packaged desktop Pi session enables a first-party local tool, the app launches .vite/build/mcp-server.js as a standalone Node script, but this new asset is not included in asarUnpack alongside rpc-host.js, causing the MCP child and its tools to fail at startup.

Knowledge Base Used: PostHog Code Desktop App (apps/code)

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/vite-main-plugins.mts
Line: 175-179

Comment:
**MCP child remains inside ASAR**

When a packaged desktop Pi session enables a first-party local tool, the app launches `.vite/build/mcp-server.js` as a standalone Node script, but this new asset is not included in `asarUnpack` alongside `rpc-host.js`, causing the MCP child and its tools to fail at startup.

**Knowledge Base Used:** [PostHog Code Desktop App (`apps/code`)](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/code/-/docs/apps-code-desktop.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@greptile-apps

greptile-apps Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff (1)

  1. packages/harness/src/extensions/mcp/extension.ts, line 3497-3513 (link)

    P1 Config errors drop runtime tools

    When the global or project mcp.json is malformed or unreadable, this handler returns before mergeRuntimeServers runs, causing the trusted posthog-code-tools server and its cloud Pi tools to be absent for the session.

    Knowledge Base Used:

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: packages/harness/src/extensions/mcp/extension.ts
    Line: 3497-3513
    
    Comment:
    **Config errors drop runtime tools**
    
    When the global or project `mcp.json` is malformed or unreadable, this handler returns before `mergeRuntimeServers` runs, causing the trusted `posthog-code-tools` server and its cloud Pi tools to be absent for the session.
    
    **Knowledge Base Used:**
    - [Harness (`hog`/`harness` CLI)](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/code/-/docs/harness-cli.md)
    - [Agent SDK (`packages/agent`)](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/code/-/docs/agent-sdk.md)
    
    ---
    
    For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Prompt To Fix All With AI
### Issue 1
apps/code/vite-main-plugins.mts:175-179
**MCP child remains inside ASAR**

When a packaged desktop Pi session enables a first-party local tool, the app launches `.vite/build/mcp-server.js` as a standalone Node script, but this new asset is not included in `asarUnpack` alongside `rpc-host.js`, causing the MCP child and its tools to fail at startup.

### Issue 2
packages/harness/src/extensions/mcp/extension.ts:3497-3513
**Config errors drop runtime tools**

When the global or project `mcp.json` is malformed or unreadable, this handler returns before `mergeRuntimeServers` runs, causing the trusted `posthog-code-tools` server and its cloud Pi tools to be absent for the session.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "feat(pi): inject local MCP tools" | Re-trigger Greptile

@jonathanlab

Copy link
Copy Markdown
Contributor Author

/merge stop

@jonathanlab

Copy link
Copy Markdown
Contributor Author

/trunk stop

Comment thread packages/agent/src/pi/rpc-host.ts
@veria-ai

veria-ai Bot commented Jul 30, 2026

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

@charlesvien

Copy link
Copy Markdown
Member

Hey @jonathanlab, we've migrated this repo into the PostHog/posthog monorepo, so this PR needs to be recreated there.

Easiest path: check out the monorepo and run the /porting-code-prs skill with your agent pointed at this PR. It has the migration guide and path remappings baked in so the agent doesn't have to figure them out. You don't strictly need it though, just asking your agent to port the PR works fine too.

Shout if you get stuck.

@charlesvien charlesvien added the stale No recent changes to PR label Aug 3, 2026
@jonathanlab jonathanlab closed this Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale No recent changes to PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants