Skip to content

feat(phai): create MCP store#48215

Merged
cvolzer3 merged 82 commits intomasterfrom
feat/mcp-store
Feb 27, 2026
Merged

feat(phai): create MCP store#48215
cvolzer3 merged 82 commits intomasterfrom
feat/mcp-store

Conversation

@cvolzer3
Copy link
Copy Markdown
Contributor

Problem

As a user, I want to install MCP servers into PostHog AI and Twig so that the agent can make use of data and actions from third-party services.

Changes

This PR adds an MCP store that lets users install and manage third-party MCP servers, with OAuth and API key auth, so PostHog's and Twig's AI agents can call external tools on their behalf.

Overview of the main concepts:

  • By default, we display a list of recommended MCP servers.
  • When a user connects a server, we create an MCPServerInstallation record scoped to the user and team. Users can also add a custom server via URL using either an API key or OAuth.
  • For OAuth based servers, we support discovery and DCR. Shared DCR credentials are stored and keyed by issuer URL, so multiple users connecting to the same provider don't trigger duplicate registrations.
  • The PHAI agents constructs MCP requests from stored credentials. I also added token refresh handling. If a refresh fails, we surface an error state in the UI.

How did you test this code?

  • Backend unit tests
  • Agent tool tests
  • Lots and lots of local testing

Publish to changelog?

Yes

@cvolzer3
Copy link
Copy Markdown
Contributor Author

Still WIP:

  • Add integration for Twig agent
  • Add an icon for Notion
  • Add more MCP servers to recommended list
  • Fix state issue when user cancels OAuth flow, but we show "Active" in Recommend Servers and "Connect" in Installed Servers

Comment thread products/mcp_store/backend/api.py Outdated
Copy link
Copy Markdown
Contributor

@joshsny joshsny left a comment

Choose a reason for hiding this comment

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

gave it a skim through and left some comments, this is looking really good 🙌

Comment thread ee/hogai/tools/call_mcp_server/mcp_client.py Outdated
Comment thread ee/hogai/tools/call_mcp_server/mcp_client.py
Comment thread ee/hogai/tools/call_mcp_server/tool.py Outdated
Comment thread frontend/src/scenes/insights/views/BoldNumber/Textfit.tsx
Comment thread products/mcp_store/backend/api.py
Comment thread products/mcp_store/manifest.tsx Outdated
Comment thread products/mcp_store/backend/api.py Fixed
Comment thread products/mcp_store/backend/api.py Fixed
Comment thread products/mcp_store/backend/api.py Fixed
Comment thread products/mcp_store/backend/api.py Fixed
Comment thread products/mcp_store/backend/api.py Fixed
Comment thread products/mcp_store/backend/api.py Fixed
Comment thread products/mcp_store/backend/api.py Fixed
Copy link
Copy Markdown
Contributor

@joshsny joshsny left a comment

Choose a reason for hiding this comment

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

looks great - awesome work on this! left some comments, approving not to block

Comment thread ee/hogai/tools/call_mcp_server/installations.py Outdated
Comment thread ee/hogai/tools/call_mcp_server/mcp_client.py Outdated
Comment thread ee/hogai/tools/call_mcp_server/mcp_client.py Outdated
Comment thread ee/hogai/tools/call_mcp_server/mcp_client.py Outdated
Comment thread ee/hogai/tools/call_mcp_server/tool.py
Comment thread ee/hogai/tools/call_mcp_server/tool.py Outdated
Comment thread ee/hogai/tools/call_mcp_server/tool.py Outdated
return obj.server.name
return ""

def get_needs_reauth(self, obj: MCPServerInstallation) -> bool:
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.

how do we handle invalid api keys?

Comment thread products/mcp_store/backend/api.py
Comment thread products/mcp_store/backend/models.py
Copy link
Copy Markdown
Member

@Piccirello Piccirello left a comment

Choose a reason for hiding this comment

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

Nothing further from my end, your honor

@tests-posthog
Copy link
Copy Markdown
Contributor

tests-posthog Bot commented Feb 26, 2026

Visual regression: Storybook UI snapshots updated

Changes: 73 snapshots (73 modified, 0 added, 0 deleted)

What this means:

  • Snapshots have been automatically updated to match current rendering
  • Next CI run will switch to CHECK mode to verify stability
  • If snapshots change again, CHECK mode will fail (indicates flapping)

Next steps:

  • Review the changes to ensure they're intentional
  • Approve if changes match your expectations
  • If unexpected, investigate component rendering

Review snapshot changes →

@tests-posthog
Copy link
Copy Markdown
Contributor

tests-posthog Bot commented Feb 27, 2026

Visual regression: Storybook UI snapshots updated

Changes: 2 snapshots (2 modified, 0 added, 0 deleted)

What this means:

  • Snapshots have been automatically updated to match current rendering
  • Next CI run will switch to CHECK mode to verify stability
  • If snapshots change again, CHECK mode will fail (indicates flapping)

Next steps:

  • Review the changes to ensure they're intentional
  • Approve if changes match your expectations
  • If unexpected, investigate component rendering

Review snapshot changes →

@tests-posthog
Copy link
Copy Markdown
Contributor

tests-posthog Bot commented Feb 27, 2026

Visual regression: Storybook UI snapshots updated

Changes: 2 snapshots (2 modified, 0 added, 0 deleted)

What this means:

  • Snapshots have been automatically updated to match current rendering
  • Next CI run will switch to CHECK mode to verify stability
  • If snapshots change again, CHECK mode will fail (indicates flapping)

Next steps:

  • Review the changes to ensure they're intentional
  • Approve if changes match your expectations
  • If unexpected, investigate component rendering

Review snapshot changes →

@cvolzer3 cvolzer3 merged commit b4deb35 into master Feb 27, 2026
203 checks passed
@cvolzer3 cvolzer3 deleted the feat/mcp-store branch February 27, 2026 18:51
govambam pushed a commit to code-review-studio/posthog that referenced this pull request Feb 27, 2026
fercgomes pushed a commit that referenced this pull request Mar 1, 2026
tomasfarias pushed a commit that referenced this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants