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(error-tracking): allow api tokens to manage external references (#65719)

Hugues Pouillot57ae208b7bad
diff --git a/posthog/api/integration.py b/posthog/api/integration.py
index f7ccd700a922..cacdfd03b22f 100644
--- a/posthog/api/integration.py
+++ b/posthog/api/integration.py
@@ -212,6 +212,25 @@ class GitHubReposRefreshResponseSerializer(serializers.Serializer):
repositories = GitHubRepoSerializer(many=True, help_text="The refreshed repository cache.")
+class JiraProjectSerializer(serializers.Serializer):
+ id = serializers.CharField(help_text="Jira project ID.")
+ key = serializers.CharField(help_text="Jira project key to pass as error tracking config.project_key.")
+ name = serializers.CharField(help_text="Jira project display name.")
+
+
+class JiraProjectsResponseSerializer(serializers.Serializer):
+ projects = JiraProjectSerializer(many=True, help_text="Jira projects available to this integration.")
+
+
+class LinearTeamSerializer(serializers.Serializer):
+ id = serializers.CharField(help_text="Linear team ID to pass as error tracking config.team_id.")
+ name = serializers.CharField(help_text="Linear team display name.")
+
+
+class LinearTeamsResponseSerializer(serializers.Serializer):
+ teams = LinearTeamSerializer(many=True, help_text="Linear teams available to this integration.")
+
+
class GitHubTeamSerializer(serializers.Serializer):
id = serializers.IntegerField(help_text="GitHub team numeric identifier.")
slug = serializers.CharField(help_text="GitHub team slug.")
@@ -800,6 +819,8 @@ class IntegrationViewSet(
"github_repos",
"github_branches",
"github_teams",
+ "jira_projects",
+ "linear_teams",
"anthropic_managed_agents",
"anthropic_managed_agent_environments",
"anthropic_managed_agent_vaults",
@@ -1245,9 +1266,12 @@ class IntegrationViewSet(
return Response({"workspaces": workspaces})
+ @extend_schema(responses={200: LinearTeamsResponseSerializer})
@action(methods=["GET"], detail=True, url_path="linear_teams")
def linear_teams(self, request: Request, *args: Any, **kwargs: Any) -> Response:
instance = self.get_object()
+ if instance.kind != "linear":
+ raise ValidationError("linear_teams endpoint is only supported for Linear integrations")
_ensure_oauth_token_valid(instance)
linear = LinearIntegration(instance)
return Response({"teams": linear.list_teams()})
@@ -1545,9 +1569,12 @@ class IntegrationViewSet(
return Response({"branches": branches, "default_branch": default_branch, "has_more": has_more})
+ @extend_schema(responses={200: JiraProjectsResponseSerializer})
@action(methods=["GET"], detail=True, url_path="jira_projects")
def jira_projects(self, request: Request, *args: Any, **kwargs: Any) -> Response:
instance = self.get_object()
+ if instance.kind != "jira":
+ raise ValidationError("jira_projects endpoint is only supported for Jira integrations")
_ensure_oauth_token_valid(instance)
jira = JiraIntegration(instance)
return Response({"projects": jira.list_projects()})
diff --git a/posthog/api/test/test_integration.py b/posthog/api/test/test_integration.py
index f678eeaac2ab..6529cfe471ce 100644
--- a/posthog/api/test/test_integration.py
+++ b/posthog/api/test/test_integration.py
@@ -918,14 +918,18 @@ class TestIntegrationAPIKeyAccess:
assert "sensitive_config" not in body
@pytest.mark.parametrize(
- "url_suffix,method",
+ "url_suffix,method,expected_provider",
[
- ("github_repos/", "get"),
- ("github_repos/refresh/", "post"),
- ("github_branches/?repo=org/repo", "get"),
+ ("github_repos/", "get", "GitHub"),
+ ("github_repos/refresh/", "post", "GitHub"),
+ ("github_branches/?repo=org/repo", "get", "GitHub"),
+ ("jira_projects/", "get", "Jira"),
+ ("linear_teams/", "get", "Linear"),
],
)
- def test_github_actions_on_non_github_integration_return_400(self, url_suffix, method, client: HttpClient):
+ def test_provider_lookup_actions_on_wrong_integration_return_400(
+ self, url_suffix, method, expected_provider, client: HttpClient
+ ):
key_value = "test_key_non_github"
PersonalAPIKey.objects.create(
label="Test Key",
@@ -940,7 +944,7 @@ class TestIntegrationAPIKeyAccess:
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
- assert "GitHub" in response.json()["detail"]
+ assert expected_provider in response.json()["detail"]
@patch("posthog.models.integration.GitHubIntegration.list_cached_repositories")
def test_github_repos_with_scope_succeeds(self, mock_list_repos, client: HttpClient):
@@ -1140,6 +1144,64 @@ class TestIntegrationAPIKeyAccess:
== "Unable to fetch GitHub teams. Please check integration settings and try again."
)
+ @patch("posthog.api.integration._ensure_oauth_token_valid")
+ @patch("posthog.api.integration.JiraIntegration.list_projects")
+ def test_jira_projects_with_scope_succeeds(self, mock_list_projects, mock_ensure_token_valid, client: HttpClient):
+ mock_list_projects.return_value = [{"id": "10000", "key": "ENG", "name": "Engineering"}]
+ jira_integration = Integration.objects.create(
+ team=self.team,
+ kind=Integration.IntegrationKind.JIRA.value,
+ config={"cloud_id": "cloud-id"},
+ sensitive_config={"access_token": "test-token"},
+ )
+
+ key_value = "test_key_123"
+ PersonalAPIKey.objects.create(
+ label="Test Key",
+ user=self.user,
+ secure_value=hash_key_value(key_value),
+ scopes=["integration:read"],
+ )
+
+ response = client.get(
+ f"/api/environments/{self.team.pk}/integrations/{jira_integration.id}/jira_projects/",
+ HTTP_AUTHORIZATION=f"Bearer {key_value}",
+ )
+
+ assert response.status_code == status.HTTP_200_OK
+ assert response.json() == {"projects": [{"id": "10000", "key": "ENG", "name": "Engineering"}]}
+ mock_ensure_token_valid.assert_called_once_with(jira_integration)
+ mock_list_projects.assert_called_once_with()
+
+ @patch("posthog.api.integration._ensure_oauth_token_valid")
+ @patch("posthog.api.integration.LinearIntegration.list_teams")
+ def test_linear_teams_with_scope_succeeds(self, mock_list_teams, mock_ensure_token_valid, client: HttpClient):
+ mock_list_teams.return_value = [{"id": "team-id", "name": "Engineering"}]
+ linear_integration = Integration.objects.create(
+ team=self.team,
+ kind=Integration.IntegrationKind.LINEAR.value,
+ config={},
+ sensitive_config={"access_token": "test-token"},
+ )
+
+ key_value = "test_key_123"
+ PersonalAPIKey.objects.create(
+ label="Test Key",
+ user=self.user,
+ secure_value=hash_key_value(key_value),
+ scopes=["integration:read"],
+ )
+
+ response = client.get(
+ f"/api/environments/{self.team.pk}/integrations/{linear_integration.id}/linear_teams/",
+ HTTP_AUTHORIZATION=f"Bearer {key_value}",
+ )
+
+ assert response.status_code == status.HTTP_200_OK
+ assert response.json() == {"teams": [{"id": "team-id", "name": "Engineering"}]}
+ mock_ensure_token_valid.assert_called_once_with(linear_integration)
+ mock_list_teams.assert_called_once_with()
+
@patch("posthog.models.integration.GitHubIntegration.sync_repository_cache")
def test_refresh_github_repos_with_write_scope_succeeds(self, mock_sync_repository_cache, client: HttpClient):
mock_sync_repository_cache.return_value = [
diff --git a/products/error_tracking/backend/logic/__init__.py b/products/error_tracking/backend/logic/__init__.py
index 66249d13689b..960fd5152767 100644
--- a/products/error_tracking/backend/logic/__init__.py
+++ b/products/error_tracking/backend/logic/__init__.py
@@ -80,11 +80,63 @@ SUPPORTED_EXTERNAL_ISSUE_PROVIDERS = frozenset(
}
)
+EXTERNAL_REFERENCE_REQUIRED_CONFIG_FIELDS = {
+ Integration.IntegrationKind.GITHUB.value: ("repository", "title", "body"),
+ Integration.IntegrationKind.GITLAB.value: ("title", "body"),
+ Integration.IntegrationKind.LINEAR.value: ("team_id", "title", "description"),
+ Integration.IntegrationKind.JIRA.value: ("project_key", "title", "description"),
+}
+
+EXTERNAL_REFERENCE_NON_BLANK_CONFIG_FIELDS = {
+ Integration.IntegrationKind.GITHUB.value: ("repository", "title"),
+ Integration.IntegrationKind.GITLAB.value: ("title",),
+ Integration.IntegrationKind.LINEAR.value: ("team_id", "title"),
+ Integration.IntegrationKind.JIRA.value: ("project_key", "title"),
+}
+
def is_supported_external_issue_provider(kind: str) -> bool:
return kind in SUPPORTED_EXTERNAL_ISSUE_PROVIDERS
+def _validate_external_reference_config(integration: Integration, config: Any) -> None:
+ if not isinstance(config, dict):
+ raise ErrorTrackingExternalReferenceValidationError("External reference config must be an object.")
+
+ required_fields = EXTERNAL_REFERENCE_REQUIRED_CONFIG_FIELDS.get(integration.kind)
+ if required_fields is None:
+ raise ErrorTrackingExternalReferenceValidationError("Provider not supported")
+
+ missing_fields = [field for field in required_fields if field not in config]
+ if missing_fields:
+ raise ErrorTrackingExternalReferenceValidationError(
+ f"Missing required config fields for {integration.kind}: {', '.join(missing_fields)}."
+ )
+
+ non_string_fields = [field for field in required_fields if not isinstance(config[field], str)]
+ if non_string_fields:
+ raise ErrorTrackingExternalReferenceValidationError(
+ f"Config fields for {integration.kind} must be strings: {', '.join(non_string_fields)}."
+ )
+
+ blank_fields = [
+ field for field in EXTERNAL_REFERENCE_NON_BLANK_CONFIG_FIELDS[integration.kind] if not config[field].strip()
+ ]
+ if blank_fields:
+ raise ErrorTrackingExternalReferenceValidationError(
+ f"Config fields for {integration.kind} cannot be blank: {', '.join(blank_fields)}."
+ )
+
+ if integration.kind == Integration.IntegrationKind.LINEAR:
+ team_id = config["team_id"]
+ teams = LinearIntegration(integration).list_teams() or []
+ valid_team_ids = {str(team["id"]) for team in teams if isinstance(team, dict) and team.get("id")}
+ if team_id not in valid_team_ids:
+ raise ErrorTrackingExternalReferenceValidationError(
+ "Invalid Linear team_id. Use integrations-linear-teams-retrieve to choose a team from this integration."
+ )
+
+
def get_issue_list_queryset(team_id: int) -> QuerySet[ErrorTrackingIssue]:
return ErrorTrackingIssue.objects.with_first_seen().select_related("assignment").filter(team_id=team_id)
@@ -168,14 +220,17 @@ def create_external_reference(
if integration is None:
raise ErrorTrackingExternalReferenceValidationError("Integration does not belong to this team.")
+ _validate_external_reference_config(integration, config)
+ provider_config = dict(config)
+
if integration.kind == Integration.IntegrationKind.GITHUB:
- external_context = GitHubIntegration(integration).create_issue(config)
+ external_context = GitHubIntegration(integration).create_issue(provider_config)
elif integration.kind == Integration.IntegrationKind.GITLAB:
- external_context = GitLabIntegration(integration).create_issue(config)
+ external_context = GitLabIntegration(integration).create_issue(provider_config)
elif integration.kind == Integration.IntegrationKind.LINEAR:
- external_context = LinearIntegration(integration).create_issue(str(team_id), issue.id, config)
+ external_context = LinearIntegration(integration).create_issue(str(team_id), issue.id, provider_config)
elif integration.kind == Integration.IntegrationKind.JIRA:
- external_context = JiraIntegration(integration).create_issue(config)
+ external_context = JiraIntegration(integration).create_issue(provider_config)
else:
raise ErrorTrackingExternalReferenceValidationError("Provider not supported")
diff --git a/products/error_tracking/backend/presentation/views/external_references.py b/products/error_tracking/backend/presentation/views/external_references.py
index ba429867671a..b5f252601a77 100644
--- a/products/error_tracking/backend/presentation/views/external_references.py
+++ b/products/error_tracking/backend/presentation/views/external_references.py
@@ -1,7 +1,7 @@
import logging
from uuid import UUID
-from drf_spectacular.utils import extend_schema_serializer
+from drf_spectacular.utils import extend_schema_field, extend_schema_serializer
from rest_framework import serializers, status, viewsets
from rest_framework.exceptions import NotFound, ValidationError
from rest_framework.response import Response
@@ -23,20 +23,45 @@ logger = logging.getLogger(__name__)
@extend_schema_serializer(component_name="ErrorTrackingExternalReferenceIntegrationResult")
class ErrorTrackingExternalReferenceIntegrationSerializer(serializers.Serializer):
- id = serializers.IntegerField(read_only=True)
- kind = serializers.CharField(read_only=True)
- display_name = serializers.CharField(read_only=True)
+ id = serializers.IntegerField(read_only=True, help_text="ID of the integration backing this external reference.")
+ kind = serializers.CharField(
+ read_only=True, help_text="Integration provider, e.g. 'github', 'gitlab', 'linear', or 'jira'."
+ )
+ display_name = serializers.CharField(read_only=True, help_text="Human-readable name of the connected integration.")
+
+
+@extend_schema_field({"type": "object", "additionalProperties": {"type": "string"}})
+class ExternalReferenceConfigField(serializers.JSONField):
+ pass
@extend_schema_serializer(component_name="ErrorTrackingExternalReferenceResult")
class ErrorTrackingExternalReferenceSerializer(serializers.Serializer):
- id = serializers.UUIDField(read_only=True)
- integration = ErrorTrackingExternalReferenceIntegrationSerializer(read_only=True)
- integration_id = serializers.IntegerField(write_only=True)
- config = serializers.JSONField(write_only=True)
- issue = serializers.UUIDField(write_only=True)
- external_url = serializers.SerializerMethodField()
-
+ id = serializers.UUIDField(read_only=True, help_text="Unique ID of the external reference.")
+ integration = ErrorTrackingExternalReferenceIntegrationSerializer(
+ read_only=True, help_text="The connected integration this reference was created through."
+ )
+ integration_id = serializers.IntegerField(
+ write_only=True,
+ help_text="ID of the connected integration to create the external issue with. List the project's integrations to find the right ID and its kind (one of 'github', 'gitlab', 'linear', 'jira').",
+ )
+ config = ExternalReferenceConfigField(
+ write_only=True,
+ help_text=(
+ "Provider-specific fields describing the external issue to create. Required keys depend on the "
+ "integration kind: github -> {repository, title, body}; gitlab -> {title, body}; "
+ "linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: "
+ 'github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; '
+ 'linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; '
+ 'jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}.'
+ ),
+ )
+ issue = serializers.UUIDField(write_only=True, help_text="ID of the error tracking issue to link the reference to.")
+ external_url = serializers.SerializerMethodField(
+ help_text="URL of the linked external issue in the provider's system."
+ )
+
+ @extend_schema_field(serializers.CharField())
def get_external_url(self, reference: contracts.ErrorTrackingExternalReference) -> str:
if reference.external_url:
return reference.external_url
@@ -48,7 +73,7 @@ class ErrorTrackingExternalReferenceSerializer(serializers.Serializer):
class ErrorTrackingExternalReferenceViewSet(TeamAndOrgViewSetMixin, ForbidDestroyModel, viewsets.GenericViewSet):
- scope_object = "INTERNAL"
+ scope_object = "error_tracking"
serializer_class = ErrorTrackingExternalReferenceSerializer
def list(self, request, *args, **kwargs):
@@ -92,7 +117,7 @@ class ErrorTrackingExternalReferenceViewSet(TeamAndOrgViewSetMixin, ForbidDestro
)
except ExternalReferenceValidationError as error:
logger.warning("Failed to create external reference", exc_info=error)
- raise ValidationError("Invalid external reference configuration") from error
+ raise ValidationError(str(error)) from error
response_serializer = self.get_serializer(reference)
return Response(response_serializer.data, status=status.HTTP_201_CREATED)
diff --git a/products/error_tracking/backend/test/test_facade_api.py b/products/error_tracking/backend/test/test_facade_api.py
index 228f8a5eb046..6029f094a6d2 100644
--- a/products/error_tracking/backend/test/test_facade_api.py
+++ b/products/error_tracking/backend/test/test_facade_api.py
@@ -1,12 +1,14 @@
from datetime import timedelta
from posthog.test.base import BaseTest
+from unittest.mock import patch
from django.utils.timezone import now
from parameterized import parameterized
from posthog.models import Team
+from posthog.models.integration import Integration
from products.error_tracking.backend.facade import api, contracts
from products.error_tracking.backend.models import (
@@ -59,6 +61,30 @@ class TestErrorTrackingFacadeAPI(BaseTest):
with self.assertRaises(api.IssueNotFoundError):
api.get_issue(issue_id=issue.id, team_id=other_team.id)
+ @patch("products.error_tracking.backend.logic.LinearIntegration.list_teams")
+ def test_create_external_reference_rejects_invalid_linear_team_id(self, mock_list_teams):
+ mock_list_teams.return_value = [{"id": "linear-team-id", "name": "Engineering"}]
+ issue = self._create_issue(team=self.team, name="Checkout TypeError")
+ integration = Integration.objects.create(
+ team=self.team,
+ kind=Integration.IntegrationKind.LINEAR.value,
+ config={"data": {"viewer": {"organization": {"urlKey": "acme"}}}},
+ sensitive_config={"access_token": "access-token"},
+ )
+
+ with self.assertRaises(api.ExternalReferenceValidationError) as context:
+ api.create_external_reference(
+ team_id=self.team.id,
+ issue_id=issue.id,
+ integration_id=integration.id,
+ config={"team_id": "other-team-id", "title": "Checkout TypeError", "description": ""},
+ )
+
+ assert str(context.exception) == (
+ "Invalid Linear team_id. Use integrations-linear-teams-retrieve to choose a team from this integration."
+ )
+ mock_list_teams.assert_called_once_with()
+
def test_issue_exists(self):
assert api.issue_exists(team_id=self.team.id) is False
diff --git a/products/error_tracking/backend/tests/api/test_error_tracking_api.py b/products/error_tracking/backend/tests/api/test_error_tracking_api.py
index 277e803d5e67..cc60e0d864c0 100644
--- a/products/error_tracking/backend/tests/api/test_error_tracking_api.py
+++ b/products/error_tracking/backend/tests/api/test_error_tracking_api.py
@@ -13,6 +13,7 @@ from parameterized import parameterized
from rest_framework import status
from posthog.models import User
+from posthog.models.integration import Integration
from posthog.models.utils import uuid7
from posthog.settings import (
OBJECT_STORAGE_ACCESS_KEY_ID,
@@ -48,6 +49,28 @@ class TestErrorTracking(APIBaseTest):
ErrorTrackingIssueFingerprintV2.objects.create(team=self.team, issue=issue, fingerprint=fingerprint)
return issue
+ def test_external_reference_create_returns_provider_config_validation_error(self):
+ issue = self.create_issue()
+ integration = Integration.objects.create(
+ team=self.team,
+ kind=Integration.IntegrationKind.JIRA.value,
+ config={"cloud_id": "cloud-id"},
+ sensitive_config={"access_token": "access-token"},
+ )
+
+ response = self.client.post(
+ f"/api/environments/{self.team.id}/error_tracking/external_references/",
+ data={
+ "issue": str(issue.id),
+ "integration_id": integration.id,
+ "config": {"title": "Checkout TypeError", "description": ""},
+ },
+ format="json",
+ )
+
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert response.json()["detail"] == "Missing required config fields for jira: project_key."
+
def teardown_method(self, method) -> None:
s3 = resource(
"s3",
diff --git a/products/error_tracking/frontend/generated/api.schemas.ts b/products/error_tracking/frontend/generated/api.schemas.ts
index 387eb68cb176..9f8b49f9c1e8 100644
--- a/products/error_tracking/frontend/generated/api.schemas.ts
+++ b/products/error_tracking/frontend/generated/api.schemas.ts
@@ -373,17 +373,31 @@ export interface PatchedErrorTrackingAssignmentRuleApi {
}
export interface ErrorTrackingExternalReferenceIntegrationResultApi {
+ /** ID of the integration backing this external reference. */
readonly id: number
+ /** Integration provider, e.g. 'github', 'gitlab', 'linear', or 'jira'. */
readonly kind: string
+ /** Human-readable name of the connected integration. */
readonly display_name: string
}
+/**
+ * Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}.
+ */
+export type ErrorTrackingExternalReferenceResultApiConfig = { [key: string]: string }
+
export interface ErrorTrackingExternalReferenceResultApi {
+ /** Unique ID of the external reference. */
readonly id: string
+ /** The connected integration this reference was created through. */
readonly integration: ErrorTrackingExternalReferenceIntegrationResultApi
+ /** ID of the connected integration to create the external issue with. List the project's integrations to find the right ID and its kind (one of 'github', 'gitlab', 'linear', 'jira'). */
integration_id: number
- config: unknown
+ /** Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}. */
+ config: ErrorTrackingExternalReferenceResultApiConfig
+ /** ID of the error tracking issue to link the reference to. */
issue: string
+ /** URL of the linked external issue in the provider's system. */
readonly external_url: string
}
diff --git a/products/error_tracking/frontend/generated/api.zod.ts b/products/error_tracking/frontend/generated/api.zod.ts
index 82db8ab223dc..a4ade733b9ba 100644
--- a/products/error_tracking/frontend/generated/api.zod.ts
+++ b/products/error_tracking/frontend/generated/api.zod.ts
@@ -102,9 +102,17 @@ export const ErrorTrackingAssignmentRulesReorderPartialUpdateBody = /* @__PURE__
})
export const ErrorTrackingExternalReferencesCreateBody = /* @__PURE__ */ zod.object({
- integration_id: zod.number(),
- config: zod.unknown(),
- issue: zod.uuid(),
+ integration_id: zod
+ .number()
+ .describe(
+ "ID of the connected integration to create the external issue with. List the project's integrations to find the right ID and its kind (one of 'github', 'gitlab', 'linear', 'jira')."
+ ),
+ config: zod
+ .record(zod.string(), zod.string())
+ .describe(
+ 'Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace\"}; linear {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}; jira {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}.'
+ ),
+ issue: zod.uuid().describe('ID of the error tracking issue to link the reference to.'),
})
export const ErrorTrackingGroupingRulesCreateBody = /* @__PURE__ */ zod.object({
@@ -213,16 +221,28 @@ export const ErrorTrackingIssuesAssignPartialUpdateBody = /* @__PURE__ */ zod
external_issues: zod
.array(
zod.object({
- id: zod.uuid(),
- integration: zod.object({
- id: zod.number(),
- kind: zod.string(),
- display_name: zod.string(),
- }),
- integration_id: zod.number(),
- config: zod.unknown(),
- issue: zod.uuid(),
- external_url: zod.string(),
+ id: zod.uuid().describe('Unique ID of the external reference.'),
+ integration: zod
+ .object({
+ id: zod.number().describe('ID of the integration backing this external reference.'),
+ kind: zod
+ .string()
+ .describe("Integration provider, e.g. 'github', 'gitlab', 'linear', or 'jira'."),
+ display_name: zod.string().describe('Human-readable name of the connected integration.'),
+ })
+ .describe('The connected integration this reference was created through.'),
+ integration_id: zod
+ .number()
+ .describe(
+ "ID of the connected integration to create the external issue with. List the project's integrations to find the right ID and its kind (one of 'github', 'gitlab', 'linear', 'jira')."
+ ),
+ config: zod
+ .record(zod.string(), zod.string())
+ .describe(
+ 'Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace\"}; linear {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}; jira {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}.'
+ ),
+ issue: zod.uuid().describe('ID of the error tracking issue to link the reference to.'),
+ external_url: zod.string().describe("URL of the linked external issue in the provider's system."),
})
)
.optional(),
@@ -254,16 +274,28 @@ export const ErrorTrackingIssuesCohortUpdateBody = /* @__PURE__ */ zod
]),
external_issues: zod.array(
zod.object({
- id: zod.uuid(),
- integration: zod.object({
- id: zod.number(),
- kind: zod.string(),
- display_name: zod.string(),
- }),
- integration_id: zod.number(),
- config: zod.unknown(),
- issue: zod.uuid(),
- external_url: zod.string(),
+ id: zod.uuid().describe('Unique ID of the external reference.'),
+ integration: zod
+ .object({
+ id: zod.number().describe('ID of the integration backing this external reference.'),
+ kind: zod
+ .string()
+ .describe("Integration provider, e.g. 'github', 'gitlab', 'linear', or 'jira'."),
+ display_name: zod.string().describe('Human-readable name of the connected integration.'),
+ })
+ .describe('The connected integration this reference was created through.'),
+ integration_id: zod
+ .number()
+ .describe(
+ "ID of the connected integration to create the external issue with. List the project's integrations to find the right ID and its kind (one of 'github', 'gitlab', 'linear', 'jira')."
+ ),
+ config: zod
+ .record(zod.string(), zod.string())
+ .describe(
+ 'Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace\"}; linear {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}; jira {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}.'
+ ),
+ issue: zod.uuid().describe('ID of the error tracking issue to link the reference to.'),
+ external_url: zod.string().describe("URL of the linked external issue in the provider's system."),
})
),
cohort: zod.union([
@@ -315,16 +347,28 @@ export const ErrorTrackingIssuesBulkCreateBody = /* @__PURE__ */ zod
]),
external_issues: zod.array(
zod.object({
- id: zod.uuid(),
- integration: zod.object({
- id: zod.number(),
- kind: zod.string(),
- display_name: zod.string(),
- }),
- integration_id: zod.number(),
- config: zod.unknown(),
- issue: zod.uuid(),
- external_url: zod.string(),
+ id: zod.uuid().describe('Unique ID of the external reference.'),
+ integration: zod
+ .object({
+ id: zod.number().describe('ID of the integration backing this external reference.'),
+ kind: zod
+ .string()
+ .describe("Integration provider, e.g. 'github', 'gitlab', 'linear', or 'jira'."),
+ display_name: zod.string().describe('Human-readable name of the connected integration.'),
+ })
+ .describe('The connected integration this reference was created through.'),
+ integration_id: zod
+ .number()
+ .describe(
+ "ID of the connected integration to create the external issue with. List the project's integrations to find the right ID and its kind (one of 'github', 'gitlab', 'linear', 'jira')."
+ ),
+ config: zod
+ .record(zod.string(), zod.string())
+ .describe(
+ 'Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace\"}; linear {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}; jira {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}.'
+ ),
+ issue: zod.uuid().describe('ID of the error tracking issue to link the reference to.'),
+ external_url: zod.string().describe("URL of the linked external issue in the provider's system."),
})
),
cohort: zod.union([
diff --git a/products/error_tracking/mcp/tools.yaml b/products/error_tracking/mcp/tools.yaml
index 4dc2d7ad2ba1..58ee4f208e1e 100644
--- a/products/error_tracking/mcp/tools.yaml
+++ b/products/error_tracking/mcp/tools.yaml
@@ -63,7 +63,28 @@ tools:
enabled: false
error-tracking-external-references-create:
operation: error_tracking_external_references_create
- enabled: false
+ enabled: true
+ scopes:
+ - error_tracking:write
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: false
+ title: Create error tracking external reference
+ description: >
+ Create a new external issue in GitHub, GitLab, Linear, or Jira, then link it to a PostHog error tracking
+ issue as an external reference. This tool does not link an existing external issue by URL or key. Provide
+ the error tracking issue id as `issue`, the connected integration as `integration_id`, and a `config` object
+ with provider-specific fields. Examples: Jira config {"project_key":"ENG","title":"Checkout
+ TypeError","description":"Stack trace and reproduction details"}; Linear config
+ {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace and reproduction details"};
+ GitHub config {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace and reproduction
+ details"}; GitLab config {"title":"Checkout TypeError","body":"Stack trace and reproduction details"}.
+ Required `config` keys by integration kind: github -> {repository, title, body}; gitlab -> {title, body};
+ linear -> {team_id, title, description}; jira -> {project_key, title, description}. Use integrations-list
+ first to find the `integration_id` and kind; use integrations-jira-projects-retrieve,
+ integrations-linear-teams-retrieve, or integrations-github-repos-retrieve when you need provider-specific
+ IDs.
error-tracking-external-references-destroy:
operation: error_tracking_external_references_destroy
enabled: false
diff --git a/products/integrations/frontend/generated/api.schemas.ts b/products/integrations/frontend/generated/api.schemas.ts
index a1ebf5af1e4a..ddb78e938563 100644
--- a/products/integrations/frontend/generated/api.schemas.ts
+++ b/products/integrations/frontend/generated/api.schemas.ts
@@ -351,6 +351,32 @@ export interface GoogleSearchConsoleSitesResponseApi {
sites: GoogleSearchConsoleSiteApi[]
}
+export interface JiraProjectApi {
+ /** Jira project ID. */
+ id: string
+ /** Jira project key to pass as error tracking config.project_key. */
+ key: string
+ /** Jira project display name. */
+ name: string
+}
+
+export interface JiraProjectsResponseApi {
+ /** Jira projects available to this integration. */
+ projects: JiraProjectApi[]
+}
+
+export interface LinearTeamApi {
+ /** Linear team ID to pass as error tracking config.team_id. */
+ id: string
+ /** Linear team display name. */
+ name: string
+}
+
+export interface LinearTeamsResponseApi {
+ /** Linear teams available to this integration. */
+ teams: LinearTeamApi[]
+}
+
export interface GitHubLinkExistingRequestApi {
/**
* Sibling team in the same organization whose GitHub installation should be reused.
diff --git a/products/integrations/frontend/generated/api.ts b/products/integrations/frontend/generated/api.ts
index e80f5a4b8064..c80ea67d99bc 100644
--- a/products/integrations/frontend/generated/api.ts
+++ b/products/integrations/frontend/generated/api.ts
@@ -26,6 +26,8 @@ import type {
IntegrationsGithubReposRetrieveParams,
IntegrationsGithubTeamsRetrieveParams,
IntegrationsListParams,
+ JiraProjectsResponseApi,
+ LinearTeamsResponseApi,
OrganizationIntegrationApi,
PaginatedIntegrationConfigListApi,
PaginatedRoleExternalReferenceListApi,
@@ -573,8 +575,8 @@ export const integrationsJiraProjectsRetrieve = async (
projectId: string,
id: number,
options?: RequestInit
-): Promise<void> => {
- return apiMutator<void>(getIntegrationsJiraProjectsRetrieveUrl(projectId, id), {
+): Promise<JiraProjectsResponseApi> => {
+ return apiMutator<JiraProjectsResponseApi>(getIntegrationsJiraProjectsRetrieveUrl(projectId, id), {
...options,
method: 'GET',
})
@@ -588,8 +590,8 @@ export const integrationsLinearTeamsRetrieve = async (
projectId: string,
id: number,
options?: RequestInit
-): Promise<void> => {
- return apiMutator<void>(getIntegrationsLinearTeamsRetrieveUrl(projectId, id), {
+): Promise<LinearTeamsResponseApi> => {
+ return apiMutator<LinearTeamsResponseApi>(getIntegrationsLinearTeamsRetrieveUrl(projectId, id), {
...options,
method: 'GET',
})
diff --git a/products/integrations/mcp/tools.yaml b/products/integrations/mcp/tools.yaml
index ea50ac3c4fc7..ee35f83f4c37 100644
--- a/products/integrations/mcp/tools.yaml
+++ b/products/integrations/mcp/tools.yaml
@@ -145,10 +145,32 @@ tools:
enabled: false
integrations-jira-projects-retrieve:
operation: integrations_jira_projects_retrieve
- enabled: false
+ enabled: true
+ scopes:
+ - integration:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ title: List Jira projects
+ description: >
+ List Jira projects available through a connected Jira integration. Use integrations-list with kind=jira
+ first to find the integration id, then pass a returned project key as `config.project_key` when creating an
+ error tracking external reference.
integrations-linear-teams-retrieve:
operation: integrations_linear_teams_retrieve
- enabled: false
+ enabled: true
+ scopes:
+ - integration:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ title: List Linear teams
+ description: >
+ List Linear teams available through a connected Linear integration. Use integrations-list with kind=linear
+ first to find the integration id, then pass a returned team id as `config.team_id` when creating an error
+ tracking external reference.
integrations-linkedin-ads-accounts-retrieve:
operation: integrations_linkedin_ads_accounts_retrieve
enabled: false
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 75037d038385..6ff76bb27463 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -2417,6 +2417,20 @@
"readOnlyHint": true
}
},
+ "error-tracking-external-references-create": {
+ "description": "Create a new external issue in GitHub, GitLab, Linear, or Jira, then link it to a PostHog error tracking issue as an external reference. This tool does not link an existing external issue by URL or key. Provide the error tracking issue id as `issue`, the connected integration as `integration_id`, and a `config` object with provider-specific fields. Examples: Jira config {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace and reproduction details\"}; Linear config {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace and reproduction details\"}; GitHub config {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace and reproduction details\"}; GitLab config {\"title\":\"Checkout TypeError\",\"body\":\"Stack trace and reproduction details\"}. Required `config` keys by integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Use integrations-list first to find the `integration_id` and kind; use integrations-jira-projects-retrieve, integrations-linear-teams-retrieve, or integrations-github-repos-retrieve when you need provider-specific IDs.",
+ "category": "Error tracking",
+ "feature": "error_tracking",
+ "summary": "Create error tracking external reference",
+ "title": "Create error tracking external reference",
+ "required_scopes": ["error_tracking:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
+ },
"error-tracking-grouping-rules-create": {
"description": "Create an error tracking grouping rule for the current project. Provide required `filters`, and optionally set `assignee` and `description` for the issues this rule creates.",
"category": "Error tracking",
@@ -4038,6 +4052,34 @@
"readOnlyHint": true
}
},
+ "integrations-jira-projects-retrieve": {
+ "description": "List Jira projects available through a connected Jira integration. Use integrations-list with kind=jira first to find the integration id, then pass a returned project key as `config.project_key` when creating an error tracking external reference.",
+ "category": "Integrations",
+ "feature": "integrations",
+ "summary": "List Jira projects",
+ "title": "List Jira projects",
+ "required_scopes": ["integration:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "integrations-linear-teams-retrieve": {
+ "description": "List Linear teams available through a connected Linear integration. Use integrations-list with kind=linear first to find the integration id, then pass a returned team id as `config.team_id` when creating an error tracking external reference.",
+ "category": "Integrations",
+ "feature": "integrations",
+ "summary": "List Linear teams",
+ "title": "List Linear teams",
+ "required_scopes": ["integration:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
"integrations-list": {
"description": "List all third-party integrations configured in the current project. Returns each integration's type (kind), display name, non-sensitive configuration, error status, and creation metadata. Common kinds include slack, github, hubspot, salesforce, and various ad platforms. Sensitive credentials (access tokens, secrets) are never serialized.",
"category": "Integrations",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index efa2dafdde73..bc79857a936f 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -2461,6 +2461,20 @@
"readOnlyHint": true
}
},
+ "error-tracking-external-references-create": {
+ "description": "Create a new external issue in GitHub, GitLab, Linear, or Jira, then link it to a PostHog error tracking issue as an external reference. This tool does not link an existing external issue by URL or key. Provide the error tracking issue id as `issue`, the connected integration as `integration_id`, and a `config` object with provider-specific fields. Examples: Jira config {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace and reproduction details\"}; Linear config {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace and reproduction details\"}; GitHub config {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace and reproduction details\"}; GitLab config {\"title\":\"Checkout TypeError\",\"body\":\"Stack trace and reproduction details\"}. Required `config` keys by integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Use integrations-list first to find the `integration_id` and kind; use integrations-jira-projects-retrieve, integrations-linear-teams-retrieve, or integrations-github-repos-retrieve when you need provider-specific IDs.",
+ "category": "Error tracking",
+ "feature": "error_tracking",
+ "summary": "Create error tracking external reference",
+ "title": "Create error tracking external reference",
+ "required_scopes": ["error_tracking:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
+ },
"error-tracking-grouping-rules-create": {
"description": "Create an error tracking grouping rule for the current project. Provide required `filters`, and optionally set `assignee` and `description` for the issues this rule creates.",
"category": "Error tracking",
@@ -4334,6 +4348,34 @@
"readOnlyHint": true
}
},
+ "integrations-jira-projects-retrieve": {
+ "description": "List Jira projects available through a connected Jira integration. Use integrations-list with kind=jira first to find the integration id, then pass a returned project key as `config.project_key` when creating an error tracking external reference.",
+ "category": "Integrations",
+ "feature": "integrations",
+ "summary": "List Jira projects",
+ "title": "List Jira projects",
+ "required_scopes": ["integration:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
+ "integrations-linear-teams-retrieve": {
+ "description": "List Linear teams available through a connected Linear integration. Use integrations-list with kind=linear first to find the integration id, then pass a returned team id as `config.team_id` when creating an error tracking external reference.",
+ "category": "Integrations",
+ "feature": "integrations",
+ "summary": "List Linear teams",
+ "title": "List Linear teams",
+ "required_scopes": ["integration:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
"integrations-list": {
"description": "List all third-party integrations configured in the current project. Returns each integration's type (kind), display name, non-sensitive configuration, error status, and creation metadata. Common kinds include slack, github, hubspot, salesforce, and various ad platforms. Sensitive credentials (access tokens, secrets) are never serialized.",
"category": "Integrations",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 2be2214127fc..70111ca489df 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -19406,17 +19406,31 @@ export namespace Schemas {
}
export interface ErrorTrackingExternalReferenceIntegrationResult {
+ /** ID of the integration backing this external reference. */
readonly id: number;
+ /** Integration provider, e.g. 'github', 'gitlab', 'linear', or 'jira'. */
readonly kind: string;
+ /** Human-readable name of the connected integration. */
readonly display_name: string;
}
+ /**
+ * Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}.
+ */
+ export type ErrorTrackingExternalReferenceResultConfig = {[key: string]: string};
+
export interface ErrorTrackingExternalReferenceResult {
+ /** Unique ID of the external reference. */
readonly id: string;
+ /** The connected integration this reference was created through. */
readonly integration: ErrorTrackingExternalReferenceIntegrationResult;
+ /** ID of the connected integration to create the external issue with. List the project's integrations to find the right ID and its kind (one of 'github', 'gitlab', 'linear', 'jira'). */
integration_id: number;
- config: unknown;
+ /** Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}. */
+ config: ErrorTrackingExternalReferenceResultConfig;
+ /** ID of the error tracking issue to link the reference to. */
issue: string;
+ /** URL of the linked external issue in the provider's system. */
readonly external_url: string;
}
@@ -27492,6 +27506,20 @@ export namespace Schemas {
identifier: string;
}
+ export interface JiraProject {
+ /** Jira project ID. */
+ id: string;
+ /** Jira project key to pass as error tracking config.project_key. */
+ key: string;
+ /** Jira project display name. */
+ name: string;
+ }
+
+ export interface JiraProjectsResponse {
+ /** Jira projects available to this integration. */
+ projects: JiraProject[];
+ }
+
/**
* * `2.0` - 2.0
*/
@@ -28226,6 +28254,18 @@ export namespace Schemas {
Sustained: 'sustained',
} as const;
+ export interface LinearTeam {
+ /** Linear team ID to pass as error tracking config.team_id. */
+ id: string;
+ /** Linear team display name. */
+ name: string;
+ }
+
+ export interface LinearTeamsResponse {
+ /** Linear teams available to this integration. */
+ teams: LinearTeam[];
+ }
+
/**
* Minimal inbox `SignalReport` projection for the scout reverse lookup — just enough
* for the scout UI to render a clickable chip and deep-link into the inbox, which loads
diff --git a/services/mcp/src/generated/error_tracking/api.ts b/services/mcp/src/generated/error_tracking/api.ts
index 91d71acb602a..9253f2acb22b 100644
--- a/services/mcp/src/generated/error_tracking/api.ts
+++ b/services/mcp/src/generated/error_tracking/api.ts
@@ -3,7 +3,7 @@
* MCP service uses these Zod schemas for generated tool handlers.
* To regenerate: hogli build:openapi
*
- * PostHog API - MCP 20 enabled ops
+ * PostHog API - MCP 21 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -1011,6 +1011,28 @@ export const ErrorTrackingAssignmentRulesCreateBody = /* @__PURE__ */ zod.object
),
})
+export const ErrorTrackingExternalReferencesCreateParams = /* @__PURE__ */ zod.object({
+ 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 ErrorTrackingExternalReferencesCreateBody = /* @__PURE__ */ zod.object({
+ integration_id: zod
+ .number()
+ .describe(
+ "ID of the connected integration to create the external issue with. List the project's integrations to find the right ID and its kind (one of 'github', 'gitlab', 'linear', 'jira')."
+ ),
+ config: zod
+ .record(zod.string(), zod.string())
+ .describe(
+ 'Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {"repository":"posthog","title":"Checkout TypeError","body":"Stack trace"}; linear {"team_id":"team-id","title":"Checkout TypeError","description":"Stack trace"}; jira {"project_key":"ENG","title":"Checkout TypeError","description":"Stack trace"}.'
+ ),
+ issue: zod.string().describe('ID of the error tracking issue to link the reference to.'),
+})
+
export const ErrorTrackingGroupingRulesListParams = /* @__PURE__ */ zod.object({
project_id: zod
.string()
diff --git a/services/mcp/src/generated/integrations/api.ts b/services/mcp/src/generated/integrations/api.ts
index a32b9d29f2a4..c427208edcb5 100644
--- a/services/mcp/src/generated/integrations/api.ts
+++ b/services/mcp/src/generated/integrations/api.ts
@@ -3,7 +3,7 @@
* MCP service uses these Zod schemas for generated tool handlers.
* To regenerate: hogli build:openapi
*
- * PostHog API - MCP 5 enabled ops
+ * PostHog API - MCP 7 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -154,3 +154,21 @@ export const IntegrationsGithubReposRetrieveQueryParams = /* @__PURE__ */ zod.ob
.default(integrationsGithubReposRetrieveQuerySearchDefault)
.describe('Optional case-insensitive repository name search query.'),
})
+
+export const IntegrationsJiraProjectsRetrieveParams = /* @__PURE__ */ zod.object({
+ id: zod.number().describe('A unique integer value identifying this integration.'),
+ 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 IntegrationsLinearTeamsRetrieveParams = /* @__PURE__ */ zod.object({
+ id: zod.number().describe('A unique integer value identifying this integration.'),
+ 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/."
+ ),
+})
diff --git a/services/mcp/src/tools/generated/error_tracking.ts b/services/mcp/src/tools/generated/error_tracking.ts
index 3024b56de10d..c0e4c9b53448 100644
--- a/services/mcp/src/tools/generated/error_tracking.ts
+++ b/services/mcp/src/tools/generated/error_tracking.ts
@@ -5,6 +5,7 @@ import type { Schemas } from '@/api/generated'
import {
ErrorTrackingAssignmentRulesCreateBody,
ErrorTrackingAssignmentRulesListQueryParams,
+ ErrorTrackingExternalReferencesCreateBody,
ErrorTrackingGroupingRulesCreateBody,
ErrorTrackingGroupingRulesUpdateBody,
ErrorTrackingGroupingRulesUpdateParams,
@@ -82,6 +83,35 @@ const errorTrackingAssignmentRulesList = (): ToolBase<
},
})
+const ErrorTrackingExternalReferencesCreateSchema = ErrorTrackingExternalReferencesCreateBody
+
+const errorTrackingExternalReferencesCreate = (): ToolBase<
+ typeof ErrorTrackingExternalReferencesCreateSchema,
+ Schemas.ErrorTrackingExternalReferenceResult
+> => ({
+ name: 'error-tracking-external-references-create',
+ schema: ErrorTrackingExternalReferencesCreateSchema,
+ handler: async (context: Context, params: z.infer<typeof ErrorTrackingExternalReferencesCreateSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.integration_id !== undefined) {
+ body['integration_id'] = params.integration_id
+ }
+ if (params.config !== undefined) {
+ body['config'] = params.config
+ }
+ if (params.issue !== undefined) {
+ body['issue'] = params.issue
+ }
+ const result = await context.api.request<Schemas.ErrorTrackingExternalReferenceResult>({
+ method: 'POST',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/error_tracking/external_references/`,
+ body,
+ })
+ return result
+ },
+})
+
const ErrorTrackingGroupingRulesCreateSchema = ErrorTrackingGroupingRulesCreateBody
const errorTrackingGroupingRulesCreate = (): ToolBase<
@@ -663,6 +693,7 @@ const queryErrorTrackingIssuesList = (): ToolBase<
export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'error-tracking-assignment-rules-create': errorTrackingAssignmentRulesCreate,
'error-tracking-assignment-rules-list': errorTrackingAssignmentRulesList,
+ 'error-tracking-external-references-create': errorTrackingExternalReferencesCreate,
'error-tracking-grouping-rules-create': errorTrackingGroupingRulesCreate,
'error-tracking-grouping-rules-list': errorTrackingGroupingRulesList,
'error-tracking-grouping-rules-update': errorTrackingGroupingRulesUpdate,
diff --git a/services/mcp/src/tools/generated/integrations.ts b/services/mcp/src/tools/generated/integrations.ts
index 2d8d21d9a0dc..4b2569cb0100 100644
--- a/services/mcp/src/tools/generated/integrations.ts
+++ b/services/mcp/src/tools/generated/integrations.ts
@@ -8,6 +8,8 @@ import {
IntegrationsDestroyParams,
IntegrationsGithubReposRetrieveParams,
IntegrationsGithubReposRetrieveQueryParams,
+ IntegrationsJiraProjectsRetrieveParams,
+ IntegrationsLinearTeamsRetrieveParams,
IntegrationsListQueryParams,
IntegrationsRetrieveParams,
} from '@/generated/integrations/api'
@@ -102,6 +104,42 @@ const integrationsGithubReposRetrieve = (): ToolBase<
},
})
+const IntegrationsJiraProjectsRetrieveSchema = IntegrationsJiraProjectsRetrieveParams.omit({ project_id: true })
+
+const integrationsJiraProjectsRetrieve = (): ToolBase<
+ typeof IntegrationsJiraProjectsRetrieveSchema,
+ Schemas.JiraProjectsResponse
+> => ({
+ name: 'integrations-jira-projects-retrieve',
+ schema: IntegrationsJiraProjectsRetrieveSchema,
+ handler: async (context: Context, params: z.infer<typeof IntegrationsJiraProjectsRetrieveSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const result = await context.api.request<Schemas.JiraProjectsResponse>({
+ method: 'GET',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/integrations/${encodeURIComponent(String(params.id))}/jira_projects/`,
+ })
+ return result
+ },
+})
+
+const IntegrationsLinearTeamsRetrieveSchema = IntegrationsLinearTeamsRetrieveParams.omit({ project_id: true })
+
+const integrationsLinearTeamsRetrieve = (): ToolBase<
+ typeof IntegrationsLinearTeamsRetrieveSchema,
+ Schemas.LinearTeamsResponse
+> => ({
+ name: 'integrations-linear-teams-retrieve',
+ schema: IntegrationsLinearTeamsRetrieveSchema,
+ handler: async (context: Context, params: z.infer<typeof IntegrationsLinearTeamsRetrieveSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const result = await context.api.request<Schemas.LinearTeamsResponse>({
+ method: 'GET',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/integrations/${encodeURIComponent(String(params.id))}/linear_teams/`,
+ })
+ return result
+ },
+})
+
const IntegrationsListSchema = IntegrationsListQueryParams
const integrationsList = (): ToolBase<
@@ -136,5 +174,7 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'integration-get': integrationGet,
'integrations-channels-retrieve': integrationsChannelsRetrieve,
'integrations-github-repos-retrieve': integrationsGithubReposRetrieve,
+ 'integrations-jira-projects-retrieve': integrationsJiraProjectsRetrieve,
+ 'integrations-linear-teams-retrieve': integrationsLinearTeamsRetrieve,
'integrations-list': integrationsList,
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-external-references-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-external-references-create.json
new file mode 100644
index 000000000000..de5d7cfea432
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-external-references-create.json
@@ -0,0 +1,25 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "config": {
+ "additionalProperties": {
+ "type": "string"
+ },
+ "description": "Provider-specific fields describing the external issue to create. Required keys depend on the integration kind: github -> {repository, title, body}; gitlab -> {title, body}; linear -> {team_id, title, description}; jira -> {project_key, title, description}. Examples: github {\"repository\":\"posthog\",\"title\":\"Checkout TypeError\",\"body\":\"Stack trace\"}; linear {\"team_id\":\"team-id\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}; jira {\"project_key\":\"ENG\",\"title\":\"Checkout TypeError\",\"description\":\"Stack trace\"}.",
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ "integration_id": {
+ "description": "ID of the connected integration to create the external issue with. List the project's integrations to find the right ID and its kind (one of 'github', 'gitlab', 'linear', 'jira').",
+ "type": "number"
+ },
+ "issue": {
+ "description": "ID of the error tracking issue to link the reference to.",
+ "type": "string"
+ }
+ },
+ "required": ["integration_id", "config", "issue"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-jira-projects-retrieve.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-jira-projects-retrieve.json
new file mode 100644
index 000000000000..34da2ca90cc2
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-jira-projects-retrieve.json
@@ -0,0 +1,11 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "id": {
+ "description": "A unique integer value identifying this integration.",
+ "type": "number"
+ }
+ },
+ "required": ["id"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-linear-teams-retrieve.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-linear-teams-retrieve.json
new file mode 100644
index 000000000000..34da2ca90cc2
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-linear-teams-retrieve.json
@@ -0,0 +1,11 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "id": {
+ "description": "A unique integer value identifying this integration.",
+ "type": "number"
+ }
+ },
+ "required": ["id"],
+ "type": "object"
+}