Skip to content

: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.

feat(customer-analytics): expose feature request github link as mcp tool (#121840)

Tyler Crandall9f0cb4d9b2f8
diff --git a/products/customer_analytics/mcp/tools.yaml b/products/customer_analytics/mcp/tools.yaml
index e13b5d3927ff..baa658bf0f6d 100644
--- a/products/customer_analytics/mcp/tools.yaml
+++ b/products/customer_analytics/mcp/tools.yaml
@@ -1088,6 +1088,25 @@ tools:
the caller cannot access are removed or redacted. HogQL `system.feature_request_history` exposes entry
metadata and changed field names, but not before and after values.
feature_flag: customer-analytics-feature-requests
+ feature-requests-link-github-create:
+ operation: feature_requests_link_github_create
+ enabled: true
+ scopes:
+ - customer_analytics:write
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: false
+ enrich_url: feature-requests/{id}
+ title: Link feature request to GitHub issue
+ description: >
+ Link a Customer analytics feature request to one GitHub issue. Pass the request id, its current
+ `expected_version`, the id of a GitHub integration connected to the project, and the issue URL. Pull request
+ URLs are rejected, and a request can have only one linked issue. Link an issue only when it describes the
+ same customer problem and one feature would close both. The link syncs the issue state to the request: a
+ closed issue sets the status to completed or won't fix, and a reopened issue restores the earlier status.
+ The response contains the request with its `github_link` and the next version.
+ feature_flag: customer-analytics-feature-requests
feature-requests-list:
operation: feature_requests_list
enabled: true
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 88289ef2aed4..28ad75c6d9a5 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -7010,6 +7010,22 @@
},
"feature_flag": "customer-analytics-feature-requests"
},
+ "feature-requests-link-github-create": {
+ "description": "Link a Customer analytics feature request to one GitHub issue. Pass the request id, its current `expected_version`, the id of a GitHub integration connected to the project, and the issue URL. Pull request URLs are rejected, and a request can have only one linked issue. Link an issue only when it describes the same customer problem and one feature would close both. The link syncs the issue state to the request: a closed issue sets the status to completed or won't fix, and a reopened issue restores the earlier status. The response contains the request with its `github_link` and the next version.",
+ "category": "Customer analytics",
+ "feature": "customer_analytics",
+ "summary": "Link feature request to GitHub issue",
+ "title": "Link feature request to GitHub issue",
+ "required_scopes": ["customer_analytics:write"],
+ "api_operations": ["POST /api/projects/{project_id}/feature_requests/{id}/link_github/"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "customer-analytics-feature-requests"
+ },
"feature-requests-list": {
"description": "List Customer analytics feature requests linked to accounts the caller can access. Filter by search text, lifecycle status, priority, product area, account, or archive state. Active requests are returned by default. Each request includes its active visible account links, account-specific evidence, product areas, and version. For bulk reads and aggregations, query `system.feature_requests` and its related system tables.",
"category": "Customer analytics",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index e5d3278a7f9f..c313b5116576 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -7182,6 +7182,22 @@
},
"feature_flag": "customer-analytics-feature-requests"
},
+ "feature-requests-link-github-create": {
+ "description": "Link a Customer analytics feature request to one GitHub issue. Pass the request id, its current `expected_version`, the id of a GitHub integration connected to the project, and the issue URL. Pull request URLs are rejected, and a request can have only one linked issue. Link an issue only when it describes the same customer problem and one feature would close both. The link syncs the issue state to the request: a closed issue sets the status to completed or won't fix, and a reopened issue restores the earlier status. The response contains the request with its `github_link` and the next version.",
+ "category": "Customer analytics",
+ "feature": "customer_analytics",
+ "summary": "Link feature request to GitHub issue",
+ "title": "Link feature request to GitHub issue",
+ "required_scopes": ["customer_analytics:write"],
+ "api_operations": ["POST /api/projects/{project_id}/feature_requests/{id}/link_github/"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "customer-analytics-feature-requests"
+ },
"feature-requests-list": {
"description": "List Customer analytics feature requests linked to accounts the caller can access. Filter by search text, lifecycle status, priority, product area, account, or archive state. Active requests are returned by default. Each request includes its active visible account links, account-specific evidence, product areas, and version. For bulk reads and aggregations, query `system.feature_requests` and its related system tables.",
"category": "Customer analytics",
diff --git a/services/mcp/src/generated/customer_analytics/api.ts b/services/mcp/src/generated/customer_analytics/api.ts
index 465b7ac65f94..88d690899767 100644
--- a/services/mcp/src/generated/customer_analytics/api.ts
+++ b/services/mcp/src/generated/customer_analytics/api.ts
@@ -3,7 +3,7 @@
* MCP service uses these Zod schemas for generated tool handlers.
* To regenerate: hogli build:openapi
*
- * PostHog API - MCP 72 enabled ops
+ * PostHog API - MCP 73 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -1747,6 +1747,24 @@ export const FeatureRequestsHistoryListParams = () => zod.object({
),
})
+export const FeatureRequestsLinkGithubCreateParams = () => zod.object({
+ id: zod.string(),
+ project_id: zod
+ .string()
+ .describe(
+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
+ ),
+})
+
+export const FeatureRequestsLinkGithubCreateBody = () => zod.object({
+ integration_id: zod.number().min(1).describe('GitHub integration ID connected to this project.'),
+ issue_url: zod.url().describe('GitHub issue URL. Pull request URLs are not supported.'),
+ expected_version: zod
+ .number()
+ .min(1)
+ .describe('Request version loaded by the editor. Stale versions return 409 Conflict.'),
+})
+
export const FeatureRequestsRemoveEvidenceCreateParams = () => zod.object({
id: zod.string(),
project_id: zod
diff --git a/services/mcp/src/tools/generated/customer_analytics.ts b/services/mcp/src/tools/generated/customer_analytics.ts
index 8259a85865fc..2e2e963fd28a 100644
--- a/services/mcp/src/tools/generated/customer_analytics.ts
+++ b/services/mcp/src/tools/generated/customer_analytics.ts
@@ -1831,6 +1831,41 @@ const featureRequestsHistoryList = (): ToolBase<
},
})
+const FeatureRequestsLinkGithubCreateSchema = () => {
+ const FeatureRequestsLinkGithubCreateBody = orvalSchemas.FeatureRequestsLinkGithubCreateBody()
+ const FeatureRequestsLinkGithubCreateParams = orvalSchemas.FeatureRequestsLinkGithubCreateParams()
+ return FeatureRequestsLinkGithubCreateParams.omit({ project_id: true }).extend(
+ FeatureRequestsLinkGithubCreateBody.shape
+ )
+}
+
+const featureRequestsLinkGithubCreate = (): ToolBase<
+ ReturnType<typeof FeatureRequestsLinkGithubCreateSchema>,
+ WithPostHogUrl<Schemas.FeatureRequest>
+> => ({
+ name: 'feature-requests-link-github-create',
+ schema: FeatureRequestsLinkGithubCreateSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof FeatureRequestsLinkGithubCreateSchema>>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.integration_id !== undefined) {
+ body['integration_id'] = params.integration_id
+ }
+ if (params.issue_url !== undefined) {
+ body['issue_url'] = params.issue_url
+ }
+ if (params.expected_version !== undefined) {
+ body['expected_version'] = params.expected_version
+ }
+ const result = await context.api.request<Schemas.FeatureRequest>({
+ method: 'POST',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/feature_requests/${encodeURIComponent(String(params.id))}/link_github/`,
+ body,
+ })
+ return await withPostHogUrl(context, result, `/customer_analytics/feature-requests/${result.id}`)
+ },
+})
+
const FeatureRequestsListSchema = () => {
const FeatureRequestsListQueryParams = orvalSchemas.FeatureRequestsListQueryParams()
return FeatureRequestsListQueryParams
@@ -2327,6 +2362,7 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'feature-requests-archive-create': featureRequestsArchiveCreate,
'feature-requests-create': featureRequestsCreate,
'feature-requests-history-list': featureRequestsHistoryList,
+ 'feature-requests-link-github-create': featureRequestsLinkGithubCreate,
'feature-requests-list': featureRequestsList,
'feature-requests-partial-update': featureRequestsPartialUpdate,
'feature-requests-remove-evidence-create': featureRequestsRemoveEvidenceCreate,