feat(agent): add internal MCP server for self-modification#1969
Draft
feat(agent): add internal MCP server for self-modification#1969
Conversation
Local HTTP MCP server, started with the main process and torn down on quit, that exposes four self-modification tools to the running agent: read/write the user's custom instructions and list/add MCP server installations on the active project. Mirrors McpProxyService: binds 127.0.0.1:0, generates a per-boot random bearer token, registers @preDestroy cleanup. AgentAuthAdapter appends one extra entry to the agent's MCP server list. A tRPC subscription keeps the renderer settings store in sync when the agent rewrites custom instructions in the encrypted renderer-storage bucket. Generated-By: PostHog Code Task-Id: 934a7fa1-fbb6-4f1d-89d3-f6abc69b7e23
Installing an MCP server via add_mcp_server now triggers a session refresh so the new tools become available without restarting the agent. - Emit McpServerInstalled after successful install (api_key + OAuth) - For OAuth, poll the backend until pending_oauth flips, then emit - AgentService listens and calls _posthog/refresh_session per session - Defer the refresh when a turn is in flight; fire it after turn ends - Drop the local api_key requirement check (backend enforces it; this unblocks no-auth servers that need a dummy key value)
The setup.ts default `/mock/userData` works locally as root but EACCES in GitHub runners. Mocking the store at the test level keeps the fix scoped — the polling tests never need real store state. Generated-By: PostHog Code Task-Id: 934a7fa1-fbb6-4f1d-89d3-f6abc69b7e23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Code can't do anything to itself. I find that annoying. We need to let it modify itself.
Changes
Local HTTP MCP server, started with the main process and torn down on quit, that exposes four self-modification tools to the running agent: read/write the user's custom instructions and list/add MCP server installations on the active project.
Mirrors McpProxyService: binds 127.0.0.1:0, generates a per-boot random bearer token, registers @preDestroy cleanup. AgentAuthAdapter appends one extra entry to the agent's MCP server list. A tRPC subscription keeps the renderer settings store in sync when the agent rewrites custom instructions in the encrypted renderer-storage bucket.
Generated-By: PostHog Code
Task-Id: 934a7fa1-fbb6-4f1d-89d3-f6abc69b7e23
How did you test this?
ran it locally to install the Linear MCP server (OAuth flow) and the NYC subway for the API key route.
Publish to changelog?