:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(mcp): teach agents to switch projects and orgs proactively (#58103)
Christiaan Hendriksen42fdd7ae511c
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 110e30f242d0..eae4cff456de 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -5244,10 +5244,10 @@}},"switch-organization": {- "description": "Change the active organization from the default organization. You should only use this tool if the user asks you to change the organization - otherwise, the default organization will be used.",+ "description": "Switch the active PostHog organization for subsequent tool calls. Call this proactively whenever the user names an organization they want to operate on. Use `organizations-list` to resolve an organization name to an id. Default to the active organization when no specific organization is mentioned.","category": "Organization & project management","feature": "workspace",- "summary": "Change the active organization from the default organization.",+ "summary": "Switch the active PostHog organization for subsequent tool calls.","title": "Switch active organization","required_scopes": ["organization:read"],"new_mcp": true,@@ -5259,10 +5259,10 @@}},"switch-project": {- "description": "Change the active project from the default project. You should only use this tool if the user asks you to change the project - otherwise, the default project will be used.",+ "description": "Switch the active PostHog project for subsequent tool calls. Call this proactively whenever the user names a project or workspace they want to operate on. Use `projects-get` to resolve a project name to an id. If the project isn't found, the user may be referring to a project in a different organization, in which case call `organizations-list` and `switch-organization` first, then retry `projects-get`. Default to the active project when no specific project is mentioned.","category": "Organization & project management","feature": "workspace",- "summary": "Change the active project from the default project.",+ "summary": "Switch the active PostHog project for subsequent tool calls.","title": "Switch active project","required_scopes": ["project:read"],"new_mcp": true,diff --git a/services/mcp/schema/tool-definitions.json b/services/mcp/schema/tool-definitions.jsonindex ccea2c41fdd1..b1923fc56e83 100644--- a/services/mcp/schema/tool-definitions.json+++ b/services/mcp/schema/tool-definitions.json@@ -243,10 +243,10 @@}},"switch-organization": {- "description": "Change the active organization from the default organization. You should only use this tool if the user asks you to change the organization - otherwise, the default organization will be used.",+ "description": "Switch the active PostHog organization for subsequent tool calls. Call this proactively whenever the user names an organization they want to operate on. Use `organizations-list` to resolve an organization name to an id. Default to the active organization when no specific organization is mentioned.","category": "Organization & project management","feature": "workspace",- "summary": "Change the active organization from the default organization.",+ "summary": "Switch the active PostHog organization for subsequent tool calls.","title": "Switch active organization","required_scopes": ["organization:read"],"new_mcp": true,@@ -332,10 +332,10 @@}},"switch-project": {- "description": "Change the active project from the default project. You should only use this tool if the user asks you to change the project - otherwise, the default project will be used.",+ "description": "Switch the active PostHog project for subsequent tool calls. Call this proactively whenever the user names a project or workspace they want to operate on. Use `projects-get` to resolve a project name to an id. If the project isn't found, the user may be referring to a project in a different organization, in which case call `organizations-list` and `switch-organization` first, then retry `projects-get`. Default to the active project when no specific project is mentioned.","category": "Organization & project management","feature": "workspace",- "summary": "Change the active project from the default project.",+ "summary": "Switch the active PostHog project for subsequent tool calls.","title": "Switch active project","required_scopes": ["project:read"],"new_mcp": true,diff --git a/services/mcp/src/lib/instructions.ts b/services/mcp/src/lib/instructions.tsindex 760e55f1e08e..5a2c612fc4b7 100644--- a/services/mcp/src/lib/instructions.ts+++ b/services/mcp/src/lib/instructions.ts@@ -47,7 +47,7 @@ export function buildActiveEnvironmentContextPrompt(const fullName = [user.first_name, user.last_name].filter(Boolean).join(' ') || 'Unknown'lines.push(`The user's name is ${fullName} (${user.email}).`)}- return `### Active environment\n\nAll tool calls and queries are scoped to this environment.\n\n${lines.join('\n')}`+ return `### Active environment\n\nAll tool calls and queries default to this environment; you can switch projects or organizations at any time.\n\n${lines.join('\n')}`}export interface ToolInfo {