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(user-interviews): add UserInterviewTopic model with API and MCP tools (#58400)

Paul D'Ambraf9a2cd7dee74
diff --git a/.semgrep/rules/idor-team-scoped-models.yaml b/.semgrep/rules/idor-team-scoped-models.yaml
index 4b5cb18df810..e29abc6eb08d 100644
--- a/.semgrep/rules/idor-team-scoped-models.yaml
+++ b/.semgrep/rules/idor-team-scoped-models.yaml
@@ -218,6 +218,7 @@ rules:
|TraceReviewScore
|UploadedMedia
|UserInterview
+ |UserInterviewTopic
|UserRepoPreference
|WebAnalyticsFilterPreset
)$
@@ -431,6 +432,7 @@ rules:
|TraceReviewScore
|UploadedMedia
|UserInterview
+ |UserInterviewTopic
|UserRepoPreference
|WebAnalyticsFilterPreset
)$
diff --git a/posthog/api/__init__.py b/posthog/api/__init__.py
index 44fd106f49da..cae4bd9ca07c 100644
--- a/posthog/api/__init__.py
+++ b/posthog/api/__init__.py
@@ -113,7 +113,7 @@ from products.product_tours.backend.api import ProductTourViewSet
from products.replay_vision.backend.api import ReplayLensViewSet, ReplayObservationViewSet
from products.signals.backend.views import SignalViewSet
from products.tracing.backend.presentation.views import SpansViewSet as TracingSpansViewSet
-from products.user_interviews.backend.api import UserInterviewViewSet
+from products.user_interviews.backend.api import UserInterviewTopicViewSet, UserInterviewViewSet
from products.visual_review.backend.presentation.views import (
RepoRunsViewSet as VisualReviewRepoRunsViewSet,
RepoViewSet as VisualReviewRepoViewSet,
@@ -1310,6 +1310,13 @@ environments_router.register(
["team_id"],
)
+environments_router.register(
+ r"user_interview_topics",
+ UserInterviewTopicViewSet,
+ "environment_user_interview_topics",
+ ["team_id"],
+)
+
visual_review_repos_router = projects_router.register(
r"visual_review/repos",
VisualReviewRepoViewSet,
diff --git a/posthog/scopes.py b/posthog/scopes.py
index a5cd0df57d26..1476af221e59 100644
--- a/posthog/scopes.py
+++ b/posthog/scopes.py
@@ -93,7 +93,7 @@ APIScopeObject = Literal[
"uploaded_media",
"usage_metric",
"user",
- "user_interview_DO_NOT_USE", # This is a super alpha product, so only exposing here for internal personal API key access
+ "user_interview", # Alpha product — access gated by feature flag at the MCP/API layer rather than by hiding the scope.
"visual_review",
"warehouse_objects",
"warehouse_table",
@@ -124,7 +124,7 @@ INTERNAL_API_SCOPE_OBJECTS: frozenset[APIScopeObject] = frozenset({"clickhouse_t
# OAuth metadata. Used for alpha / not-yet-public products where a user can
# manually paste the scope into a PAT but where we don't want OAuth-based
# clients (the consent screen, MCP, third-party apps) to discover it.
-OAUTH_HIDDEN_SCOPE_OBJECTS: frozenset[APIScopeObject] = frozenset({"user_interview_DO_NOT_USE", "replay_lens"})
+OAUTH_HIDDEN_SCOPE_OBJECTS: frozenset[APIScopeObject] = frozenset({"replay_lens"})
PROJECT_SECRET_API_KEY_ALLOWED_API_SCOPE_ACTION: list[tuple[APIScopeObject, APIScopeActions]] = [("endpoint", "read")]
diff --git a/products/user_interviews/backend/api.py b/products/user_interviews/backend/api.py
index 3baf967f72ca..4c3818f52025 100644
--- a/products/user_interviews/backend/api.py
+++ b/products/user_interviews/backend/api.py
@@ -11,15 +11,16 @@ import posthoganalytics.ai.openai
from drf_spectacular.utils import extend_schema
from elevenlabs import ElevenLabs
from posthoganalytics.ai.openai import OpenAI
-from rest_framework import serializers, viewsets
+from rest_framework import filters, serializers, viewsets
from rest_framework.parsers import JSONParser, MultiPartParser
from posthog.schema import ProductKey
from posthog.api.routing import TeamAndOrgViewSetMixin
from posthog.api.shared import UserBasicSerializer
+from posthog.permissions import PostHogFeatureFlagPermission
-from .models import UserInterview
+from .models import EmailWithDisplayNameValidator, UserInterview, UserInterviewTopic
elevenlabs_client = ElevenLabs()
@@ -221,7 +222,100 @@ Record the agreed-upon next steps, including any additional actions that need to
@extend_schema(tags=[ProductKey.USER_INTERVIEWS])
class UserInterviewViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
- scope_object = "user_interview_DO_NOT_USE"
+ scope_object = "user_interview"
queryset = UserInterview.objects.order_by("-created_at").select_related("created_by").all()
serializer_class = UserInterviewSerializer
parser_classes = [MultiPartParser, JSONParser]
+ posthog_feature_flag = "user-interviews"
+ permission_classes = [PostHogFeatureFlagPermission]
+
+
+class UserInterviewTopicSerializer(serializers.ModelSerializer):
+ created_by = UserBasicSerializer(read_only=True)
+ interviewee_cohort = serializers.IntegerField(
+ required=False,
+ allow_null=True,
+ help_text="Optional cohort ID identifying who to target. Not enforced as a foreign key.",
+ )
+ interviewee_emails = serializers.ListField(
+ child=serializers.CharField(max_length=254, validators=[EmailWithDisplayNameValidator()]),
+ required=False,
+ help_text="Email addresses of people to interview. May be combined with interviewee_cohort and interviewee_distinct_ids.",
+ )
+ interviewee_distinct_ids = serializers.ListField(
+ child=serializers.CharField(max_length=400),
+ required=False,
+ help_text="PostHog distinct IDs of people to interview. May be combined with interviewee_cohort and interviewee_emails.",
+ )
+ topic = serializers.CharField(
+ help_text="The product, feature, or idea you want to ask interviewees about.",
+ )
+ agent_context = serializers.CharField(
+ required=False,
+ allow_blank=True,
+ help_text="Optional additional system prompt for the voice agent — extra background, tone, or constraints.",
+ )
+ questions = serializers.ListField(
+ child=serializers.CharField(),
+ required=False,
+ help_text="Ordered list of questions the voice agent should work through during the interview.",
+ )
+
+ class Meta:
+ model = UserInterviewTopic
+ fields = (
+ "id",
+ "created_by",
+ "created_at",
+ "interviewee_cohort",
+ "interviewee_emails",
+ "interviewee_distinct_ids",
+ "topic",
+ "agent_context",
+ "questions",
+ )
+ read_only_fields = ("id", "created_by", "created_at")
+
+ def validate(self, attrs: dict) -> dict:
+ cohort = (
+ attrs.get("interviewee_cohort")
+ if "interviewee_cohort" in attrs
+ else getattr(self.instance, "interviewee_cohort", None)
+ )
+ emails = (
+ attrs.get("interviewee_emails")
+ if "interviewee_emails" in attrs
+ else getattr(self.instance, "interviewee_emails", [])
+ )
+ distinct_ids = (
+ attrs.get("interviewee_distinct_ids")
+ if "interviewee_distinct_ids" in attrs
+ else getattr(self.instance, "interviewee_distinct_ids", [])
+ )
+ if cohort is None and not emails and not distinct_ids:
+ raise serializers.ValidationError(
+ "At least one of interviewee_cohort, interviewee_emails, or interviewee_distinct_ids must be provided."
+ )
+ return attrs
+
+ def create(self, validated_data: dict) -> UserInterviewTopic:
+ request = self.context["request"]
+ team = self.context["get_team"]()
+ return UserInterviewTopic.objects.create(
+ team=team,
+ created_by=request.user,
+ **validated_data,
+ )
+
+
+@extend_schema(tags=[ProductKey.USER_INTERVIEWS])
+class UserInterviewTopicViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
+ """Planned user interview topics: who we want to target (cohort) and what we want to ask about."""
+
+ scope_object = "user_interview"
+ queryset = UserInterviewTopic.objects.select_related("created_by").all()
+ serializer_class = UserInterviewTopicSerializer
+ filter_backends = [filters.SearchFilter]
+ search_fields = ["topic"]
+ posthog_feature_flag = "user-interviews"
+ permission_classes = [PostHogFeatureFlagPermission]
diff --git a/products/user_interviews/backend/migrations/0002_userinterviewtopic.py b/products/user_interviews/backend/migrations/0002_userinterviewtopic.py
new file mode 100644
index 000000000000..84212ce9c200
--- /dev/null
+++ b/products/user_interviews/backend/migrations/0002_userinterviewtopic.py
@@ -0,0 +1,77 @@
+import django.db.models.deletion
+import django.contrib.postgres.fields
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.models.utils
+
+import products.user_interviews.backend.models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ("posthog", "1152_fix_device_bucketing_persist_across_auth"),
+ ("user_interviews", "0001_initial"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="UserInterviewTopic",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(
+ default=posthog.models.utils.UUIDT, editable=False, primary_key=True, serialize=False
+ ),
+ ),
+ ("interviewee_cohort", models.BigIntegerField(blank=True, null=True)),
+ (
+ "interviewee_emails",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(
+ max_length=254,
+ validators=[products.user_interviews.backend.models.EmailWithDisplayNameValidator()],
+ ),
+ blank=True,
+ default=list,
+ size=None,
+ ),
+ ),
+ (
+ "interviewee_distinct_ids",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=400),
+ blank=True,
+ default=list,
+ size=None,
+ ),
+ ),
+ ("topic", models.TextField()),
+ ("agent_context", models.TextField(blank=True, default="")),
+ (
+ "questions",
+ django.contrib.postgres.fields.ArrayField(
+ base_field=models.TextField(),
+ blank=True,
+ default=list,
+ size=None,
+ ),
+ ),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ ],
+ options={
+ "ordering": ["-created_at"],
+ },
+ ),
+ ]
diff --git a/products/user_interviews/backend/migrations/max_migration.txt b/products/user_interviews/backend/migrations/max_migration.txt
index cbab66dde92a..478eb5da8be7 100644
--- a/products/user_interviews/backend/migrations/max_migration.txt
+++ b/products/user_interviews/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_initial
+0002_userinterviewtopic
diff --git a/products/user_interviews/backend/models.py b/products/user_interviews/backend/models.py
index e1db0835ec86..e108f0d4cdd0 100644
--- a/products/user_interviews/backend/models.py
+++ b/products/user_interviews/backend/models.py
@@ -29,3 +29,28 @@ class UserInterview(UUIDTModel, CreatedMetaFields):
)
transcript = models.TextField(blank=True)
summary = models.TextField(blank=True)
+
+
+class UserInterviewTopic(UUIDTModel, CreatedMetaFields):
+ team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ interviewee_cohort = models.BigIntegerField(null=True, blank=True)
+ interviewee_emails = ArrayField(
+ models.CharField(max_length=254, validators=[EmailWithDisplayNameValidator()]),
+ default=list,
+ blank=True,
+ )
+ interviewee_distinct_ids = ArrayField(
+ models.CharField(max_length=400),
+ default=list,
+ blank=True,
+ )
+ topic = models.TextField()
+ agent_context = models.TextField(blank=True, default="")
+ questions = ArrayField(
+ models.TextField(),
+ default=list,
+ blank=True,
+ )
+
+ class Meta:
+ ordering = ["-created_at"]
diff --git a/products/user_interviews/frontend/generated/api.schemas.ts b/products/user_interviews/frontend/generated/api.schemas.ts
index 6d3b5f118069..3016d0b2f2a2 100644
--- a/products/user_interviews/frontend/generated/api.schemas.ts
+++ b/products/user_interviews/frontend/generated/api.schemas.ts
@@ -62,6 +62,57 @@ export interface UserBasicApi {
role_at_organization?: RoleAtOrganizationEnumApi | BlankEnumApi | null
}
+export interface UserInterviewTopicApi {
+ readonly id: string
+ readonly created_by: UserBasicApi
+ readonly created_at: string
+ /**
+ * Optional cohort ID identifying who to target. Not enforced as a foreign key.
+ * @nullable
+ */
+ interviewee_cohort?: number | null
+ /** Email addresses of people to interview. May be combined with interviewee_cohort and interviewee_distinct_ids. */
+ interviewee_emails?: string[]
+ /** PostHog distinct IDs of people to interview. May be combined with interviewee_cohort and interviewee_emails. */
+ interviewee_distinct_ids?: string[]
+ /** The product, feature, or idea you want to ask interviewees about. */
+ topic: string
+ /** Optional additional system prompt for the voice agent — extra background, tone, or constraints. */
+ agent_context?: string
+ /** Ordered list of questions the voice agent should work through during the interview. */
+ questions?: string[]
+}
+
+export interface PaginatedUserInterviewTopicListApi {
+ count: number
+ /** @nullable */
+ next?: string | null
+ /** @nullable */
+ previous?: string | null
+ results: UserInterviewTopicApi[]
+}
+
+export interface PatchedUserInterviewTopicApi {
+ readonly id?: string
+ readonly created_by?: UserBasicApi
+ readonly created_at?: string
+ /**
+ * Optional cohort ID identifying who to target. Not enforced as a foreign key.
+ * @nullable
+ */
+ interviewee_cohort?: number | null
+ /** Email addresses of people to interview. May be combined with interviewee_cohort and interviewee_distinct_ids. */
+ interviewee_emails?: string[]
+ /** PostHog distinct IDs of people to interview. May be combined with interviewee_cohort and interviewee_emails. */
+ interviewee_distinct_ids?: string[]
+ /** The product, feature, or idea you want to ask interviewees about. */
+ topic?: string
+ /** Optional additional system prompt for the voice agent — extra background, tone, or constraints. */
+ agent_context?: string
+ /** Ordered list of questions the voice agent should work through during the interview. */
+ questions?: string[]
+}
+
export interface UserInterviewApi {
readonly id: string
readonly created_by: UserBasicApi
@@ -91,6 +142,21 @@ export interface PatchedUserInterviewApi {
audio?: string
}
+export type UserInterviewTopicsListParams = {
+ /**
+ * Number of results to return per page.
+ */
+ limit?: number
+ /**
+ * The initial index from which to return the results.
+ */
+ offset?: number
+ /**
+ * A search term.
+ */
+ search?: string
+}
+
export type UserInterviewsListParams = {
/**
* Number of results to return per page.
diff --git a/products/user_interviews/frontend/generated/api.ts b/products/user_interviews/frontend/generated/api.ts
index 4c79d0f2ca8a..2310c513f9de 100644
--- a/products/user_interviews/frontend/generated/api.ts
+++ b/products/user_interviews/frontend/generated/api.ts
@@ -10,8 +10,12 @@ import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'
*/
import type {
PaginatedUserInterviewListApi,
+ PaginatedUserInterviewTopicListApi,
PatchedUserInterviewApi,
+ PatchedUserInterviewTopicApi,
UserInterviewApi,
+ UserInterviewTopicApi,
+ UserInterviewTopicsListParams,
UserInterviewsListParams,
} from './api.schemas'
@@ -32,6 +36,134 @@ type NonReadonly<T> = [T] extends [UnionToIntersection<T>]
}
: DistributeReadOnlyOverUnions<T>
+export const getUserInterviewTopicsListUrl = (projectId: string, params?: UserInterviewTopicsListParams) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : value.toString())
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/environments/${projectId}/user_interview_topics/?${stringifiedParams}`
+ : `/api/environments/${projectId}/user_interview_topics/`
+}
+
+/**
+ * Planned user interview topics: who we want to target (cohort) and what we want to ask about.
+ */
+export const userInterviewTopicsList = async (
+ projectId: string,
+ params?: UserInterviewTopicsListParams,
+ options?: RequestInit
+): Promise<PaginatedUserInterviewTopicListApi> => {
+ return apiMutator<PaginatedUserInterviewTopicListApi>(getUserInterviewTopicsListUrl(projectId, params), {
+ ...options,
+ method: 'GET',
+ })
+}
+
+export const getUserInterviewTopicsCreateUrl = (projectId: string) => {
+ return `/api/environments/${projectId}/user_interview_topics/`
+}
+
+/**
+ * Planned user interview topics: who we want to target (cohort) and what we want to ask about.
+ */
+export const userInterviewTopicsCreate = async (
+ projectId: string,
+ userInterviewTopicApi: NonReadonly<UserInterviewTopicApi>,
+ options?: RequestInit
+): Promise<UserInterviewTopicApi> => {
+ return apiMutator<UserInterviewTopicApi>(getUserInterviewTopicsCreateUrl(projectId), {
+ ...options,
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(userInterviewTopicApi),
+ })
+}
+
+export const getUserInterviewTopicsRetrieveUrl = (projectId: string, id: string) => {
+ return `/api/environments/${projectId}/user_interview_topics/${id}/`
+}
+
+/**
+ * Planned user interview topics: who we want to target (cohort) and what we want to ask about.
+ */
+export const userInterviewTopicsRetrieve = async (
+ projectId: string,
+ id: string,
+ options?: RequestInit
+): Promise<UserInterviewTopicApi> => {
+ return apiMutator<UserInterviewTopicApi>(getUserInterviewTopicsRetrieveUrl(projectId, id), {
+ ...options,
+ method: 'GET',
+ })
+}
+
+export const getUserInterviewTopicsUpdateUrl = (projectId: string, id: string) => {
+ return `/api/environments/${projectId}/user_interview_topics/${id}/`
+}
+
+/**
+ * Planned user interview topics: who we want to target (cohort) and what we want to ask about.
+ */
+export const userInterviewTopicsUpdate = async (
+ projectId: string,
+ id: string,
+ userInterviewTopicApi: NonReadonly<UserInterviewTopicApi>,
+ options?: RequestInit
+): Promise<UserInterviewTopicApi> => {
+ return apiMutator<UserInterviewTopicApi>(getUserInterviewTopicsUpdateUrl(projectId, id), {
+ ...options,
+ method: 'PUT',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(userInterviewTopicApi),
+ })
+}
+
+export const getUserInterviewTopicsPartialUpdateUrl = (projectId: string, id: string) => {
+ return `/api/environments/${projectId}/user_interview_topics/${id}/`
+}
+
+/**
+ * Planned user interview topics: who we want to target (cohort) and what we want to ask about.
+ */
+export const userInterviewTopicsPartialUpdate = async (
+ projectId: string,
+ id: string,
+ patchedUserInterviewTopicApi?: NonReadonly<PatchedUserInterviewTopicApi>,
+ options?: RequestInit
+): Promise<UserInterviewTopicApi> => {
+ return apiMutator<UserInterviewTopicApi>(getUserInterviewTopicsPartialUpdateUrl(projectId, id), {
+ ...options,
+ method: 'PATCH',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(patchedUserInterviewTopicApi),
+ })
+}
+
+export const getUserInterviewTopicsDestroyUrl = (projectId: string, id: string) => {
+ return `/api/environments/${projectId}/user_interview_topics/${id}/`
+}
+
+/**
+ * Planned user interview topics: who we want to target (cohort) and what we want to ask about.
+ */
+export const userInterviewTopicsDestroy = async (
+ projectId: string,
+ id: string,
+ options?: RequestInit
+): Promise<void> => {
+ return apiMutator<void>(getUserInterviewTopicsDestroyUrl(projectId, id), {
+ ...options,
+ method: 'DELETE',
+ })
+}
+
export const getUserInterviewsListUrl = (projectId: string, params?: UserInterviewsListParams) => {
const normalizedParams = new URLSearchParams()
diff --git a/products/user_interviews/frontend/generated/api.zod.ts b/products/user_interviews/frontend/generated/api.zod.ts
index 04f83c32c939..73586ce89735 100644
--- a/products/user_interviews/frontend/generated/api.zod.ts
+++ b/products/user_interviews/frontend/generated/api.zod.ts
@@ -9,6 +9,111 @@
*/
import * as zod from 'zod'
+/**
+ * Planned user interview topics: who we want to target (cohort) and what we want to ask about.
+ */
+export const userInterviewTopicsCreateBodyIntervieweeEmailsItemMax = 254
+
+export const userInterviewTopicsCreateBodyIntervieweeDistinctIdsItemMax = 400
+
+export const UserInterviewTopicsCreateBody = /* @__PURE__ */ zod.object({
+ interviewee_cohort: zod
+ .number()
+ .nullish()
+ .describe('Optional cohort ID identifying who to target. Not enforced as a foreign key.'),
+ interviewee_emails: zod
+ .array(zod.string().max(userInterviewTopicsCreateBodyIntervieweeEmailsItemMax))
+ .optional()
+ .describe(
+ 'Email addresses of people to interview. May be combined with interviewee_cohort and interviewee_distinct_ids.'
+ ),
+ interviewee_distinct_ids: zod
+ .array(zod.string().max(userInterviewTopicsCreateBodyIntervieweeDistinctIdsItemMax))
+ .optional()
+ .describe(
+ 'PostHog distinct IDs of people to interview. May be combined with interviewee_cohort and interviewee_emails.'
+ ),
+ topic: zod.string().describe('The product, feature, or idea you want to ask interviewees about.'),
+ agent_context: zod
+ .string()
+ .optional()
+ .describe('Optional additional system prompt for the voice agent — extra background, tone, or constraints.'),
+ questions: zod
+ .array(zod.string())
+ .optional()
+ .describe('Ordered list of questions the voice agent should work through during the interview.'),
+})
+
+/**
+ * Planned user interview topics: who we want to target (cohort) and what we want to ask about.
+ */
+export const userInterviewTopicsUpdateBodyIntervieweeEmailsItemMax = 254
+
+export const userInterviewTopicsUpdateBodyIntervieweeDistinctIdsItemMax = 400
+
+export const UserInterviewTopicsUpdateBody = /* @__PURE__ */ zod.object({
+ interviewee_cohort: zod
+ .number()
+ .nullish()
+ .describe('Optional cohort ID identifying who to target. Not enforced as a foreign key.'),
+ interviewee_emails: zod
+ .array(zod.string().max(userInterviewTopicsUpdateBodyIntervieweeEmailsItemMax))
+ .optional()
+ .describe(
+ 'Email addresses of people to interview. May be combined with interviewee_cohort and interviewee_distinct_ids.'
+ ),
+ interviewee_distinct_ids: zod
+ .array(zod.string().max(userInterviewTopicsUpdateBodyIntervieweeDistinctIdsItemMax))
+ .optional()
+ .describe(
+ 'PostHog distinct IDs of people to interview. May be combined with interviewee_cohort and interviewee_emails.'
+ ),
+ topic: zod.string().describe('The product, feature, or idea you want to ask interviewees about.'),
+ agent_context: zod
+ .string()
+ .optional()
+ .describe('Optional additional system prompt for the voice agent — extra background, tone, or constraints.'),
+ questions: zod
+ .array(zod.string())
+ .optional()
+ .describe('Ordered list of questions the voice agent should work through during the interview.'),
+})
+
+/**
+ * Planned user interview topics: who we want to target (cohort) and what we want to ask about.
+ */
+export const userInterviewTopicsPartialUpdateBodyIntervieweeEmailsItemMax = 254
+
+export const userInterviewTopicsPartialUpdateBodyIntervieweeDistinctIdsItemMax = 400
+
+export const UserInterviewTopicsPartialUpdateBody = /* @__PURE__ */ zod.object({
+ interviewee_cohort: zod
+ .number()
+ .nullish()
+ .describe('Optional cohort ID identifying who to target. Not enforced as a foreign key.'),
+ interviewee_emails: zod
+ .array(zod.string().max(userInterviewTopicsPartialUpdateBodyIntervieweeEmailsItemMax))
+ .optional()
+ .describe(
+ 'Email addresses of people to interview. May be combined with interviewee_cohort and interviewee_distinct_ids.'
+ ),
+ interviewee_distinct_ids: zod
+ .array(zod.string().max(userInterviewTopicsPartialUpdateBodyIntervieweeDistinctIdsItemMax))
+ .optional()
+ .describe(
+ 'PostHog distinct IDs of people to interview. May be combined with interviewee_cohort and interviewee_emails.'
+ ),
+ topic: zod.string().optional().describe('The product, feature, or idea you want to ask interviewees about.'),
+ agent_context: zod
+ .string()
+ .optional()
+ .describe('Optional additional system prompt for the voice agent — extra background, tone, or constraints.'),
+ questions: zod
+ .array(zod.string())
+ .optional()
+ .describe('Ordered list of questions the voice agent should work through during the interview.'),
+})
+
export const userInterviewsCreateBodyIntervieweeEmailsItemMax = 254
export const UserInterviewsCreateBody = /* @__PURE__ */ zod.object({
diff --git a/products/user_interviews/mcp/tools.yaml b/products/user_interviews/mcp/tools.yaml
new file mode 100644
index 000000000000..7c992d169e0b
--- /dev/null
+++ b/products/user_interviews/mcp/tools.yaml
@@ -0,0 +1,83 @@
+# MCP tool definition — tool entries are scaffolded from the OpenAPI schema.
+# The tool list and operation IDs are kept in sync automatically:
+# pnpm --filter=@posthog/mcp run scaffold-yaml -- --sync-all
+#
+# To enable a tool, set enabled: true and add required scopes + annotations.
+# All other fields (title, description, enrich_url, etc.) are yours to configure.
+category: User interview topics
+feature: user_interviews
+url_prefix: /user_interviews
+ui_apps: {}
+tools:
+ user-interview-topics-create:
+ operation: user_interview_topics_create
+ enabled: true
+ scopes:
+ - user_interview:write
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: false
+ title: Create user interview topic
+ description: >
+ Plan a user interview by recording who you want to target and what product or idea you want to ask them
+ about. `topic` is the free-text description of the question or product area. Targets can be specified as any
+ combination of `interviewee_cohort` (optional cohort identifier), `interviewee_emails` (list of email
+ addresses), and `interviewee_distinct_ids` (list of PostHog distinct IDs) — at least one target must be
+ provided. Pass `agent_context` (free text) to give the voice agent extra background or instructions, and
+ `questions` (list of strings) for the ordered set of questions the agent should work through.
+ include_params:
+ - interviewee_cohort
+ - interviewee_emails
+ - interviewee_distinct_ids
+ - topic
+ - agent_context
+ - questions
+ feature_flag: user-interviews
+ user-interview-topics-destroy:
+ operation: user_interview_topics_destroy
+ enabled: false
+ user-interview-topics-list:
+ operation: user_interview_topics_list
+ enabled: true
+ scopes:
+ - user_interview:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ list: true
+ title: List user interview topics
+ description: >
+ List planned user interview topics in the current project, newest first. Each result includes the topic,
+ targeting (interviewee_cohort, interviewee_emails, interviewee_distinct_ids), and the voice agent setup
+ (agent_context, questions). Supports `search` for substring match against the topic, and `limit`/`offset`
+ for pagination.
+ feature_flag: user-interviews
+ user-interview-topics-partial-update:
+ operation: user_interview_topics_partial_update
+ enabled: false
+ user-interview-topics-retrieve:
+ operation: user_interview_topics_retrieve
+ enabled: false
+ user-interview-topics-update:
+ operation: user_interview_topics_update
+ enabled: false
+ user-interviews-create:
+ operation: user_interviews_create
+ enabled: false
+ user-interviews-destroy:
+ operation: user_interviews_destroy
+ enabled: false
+ user-interviews-list:
+ operation: user_interviews_list
+ enabled: false
+ user-interviews-partial-update:
+ operation: user_interviews_partial_update
+ enabled: false
+ user-interviews-retrieve:
+ operation: user_interviews_retrieve
+ enabled: false
+ user-interviews-update:
+ operation: user_interviews_update
+ enabled: false
diff --git a/products/user_interviews/skills/planning-user-interviews/SKILL.md b/products/user_interviews/skills/planning-user-interviews/SKILL.md
new file mode 100644
index 000000000000..0e79173ee39c
--- /dev/null
+++ b/products/user_interviews/skills/planning-user-interviews/SKILL.md
@@ -0,0 +1,100 @@
+---
+name: planning-user-interviews
+description: 'Plan a user interview topic in PostHog — pick who to target (cohort, emails, or PostHog distinct IDs), draft what to ask about, and prepare the voice-agent context plus a question list. Use when the user asks to "talk to users", "check how users feel about X", "interview some customers", "set up a user interview", "run a user-research call", "find users to ask about Y", or otherwise wants qualitative feedback through a conversation. Walks the user through targeting (cohorts-list, persons-list, or accepting emails / distinct IDs directly), captures the topic, and prompts for agent context and questions before calling user-interview-topics-create. Do NOT trigger when the user is uploading a recorded interview audio file (that''s the separate UserInterview/transcript flow) or only browsing existing topics with user-interview-topics-list.'
+---
+
+# Planning user interviews
+
+Use this skill when someone asks to set up a user interview — to talk to customers, check sentiment, or gather qualitative feedback through a voice conversation. The plan is captured as a `UserInterviewTopic` that a voice agent will later run through.
+
+## What a complete topic needs
+
+Before calling `user-interview-topics-create`, gather these:
+
+1. **Who to interview** — at least one of:
+ - `interviewee_cohort` — an existing cohort ID
+ - `interviewee_emails` — list of email addresses
+ - `interviewee_distinct_ids` — list of PostHog distinct IDs
+2. **What to ask about** — `topic` (required free text)
+3. **How the agent should frame the conversation** — optional `agent_context` (extra system prompt)
+4. **The questions to work through** — optional ordered `questions` list
+
+The API rejects topics with no targeting, so at least one of the three audience fields must be set. They can be combined — a cohort plus a handful of extra emails is fine.
+
+## Step 1: Pick the audience
+
+Map what the user said to one of three paths:
+
+- **They named a cohort** ("our power users", "trial signups last week") — use `cohorts-list` filtered by name to find the cohort, confirm the match, and pass the cohort ID as `interviewee_cohort`.
+- **They described the kind of person but no cohort exists** — offer to either create the cohort first (`cohorts-create`) or fall back to listing specific people.
+- **They gave email addresses or distinct IDs** — accept them directly. Skip the cohort lookup.
+- **They were vague** ("a few customers", "some power users") — ask which they prefer:
+ - Pick an existing cohort → `cohorts-list`
+ - Look up specific persons by name or email → `persons-list` with a search query
+ - Paste a list of email addresses
+
+Each email passes through DRF email validation (display-name format `Paul D'Ambra <[email protected]>` is accepted alongside plain `[email protected]`).
+
+## Step 2: Capture the topic
+
+`topic` is one or two sentences describing what the interview is about. Infer from context where possible — don't ask the user to repeat themselves.
+
+Example: "ask trial users why they didn't convert" → `topic: "Why trial users didn't convert in the first 14 days"`.
+
+## Step 3: Prepare the voice agent
+
+Two fields shape what the agent actually does on the call. **Always ask about both before creating the topic.**
+
+### Always ask: what questions do they want to ask?
+
+`questions` is an ordered list the agent works through. Anchors, not a script — the agent will adapt phrasing. Keep them open-ended:
+
+- ✅ "What made you decide to try PostHog?"
+- ❌ "Did you like PostHog?"
+
+If the user already listed questions in their original request, use those and confirm. Otherwise, ask explicitly: _"What questions do you want the agent to ask?"_
+
+If the user can't think of any, suggest 3–5 open-ended questions drawn from the `topic` and offer them for review before creating.
+
+The field is technically optional in the API, but don't skip it silently — an interview with no questions is rarely useful.
+
+### Always offer: extra context to guide the interview
+
+`agent_context` is optional, but a few sentences here make the conversation dramatically better. Always offer the user the chance to provide it, e.g.:
+
+> _"Want to give the agent any extra context? Things like tone, what to avoid, or background on the interviewee help guide the conversation. It's optional."_
+
+Useful kinds of context:
+
+- **Tone**: "warm and conversational", "skip pleasantries — this is a 10-minute call"
+- **Constraints**: "don't promise feature delivery", "do not discuss pricing"
+- **Background the agent should know**: "the user just churned from the Scale plan; be empathetic", "this person tried PostHog 6 months ago and bounced"
+- **Persona**: "you are Sam, a PostHog product researcher"
+
+If the user declines, that's fine — leave `agent_context` empty and continue.
+
+## Calling user-interview-topics-create
+
+Once you have the pieces:
+
+```json
+{
+ "topic": "Why trial users churned in week 2",
+ "interviewee_cohort": 42,
+ "interviewee_emails": ["[email protected]"],
+ "agent_context": "Be warm. The interviewee just churned — don't pitch.",
+ "questions": [
+ "What were you hoping PostHog would help with?",
+ "Where did you get stuck?",
+ "What would have made you stay?"
+ ]
+}
+```
+
+After creation, show the new topic ID so it can be handed off to the voice agent.
+
+## What this skill is not for
+
+- **Uploading a recorded interview** — that's the separate `UserInterview` model (`user_interviews_create` with an audio file). Different flow, different model.
+- **Listing existing topics** — `user-interview-topics-list` handles that directly with `search`, `limit`, and `offset`. No skill needed.
+- **Analyzing transcripts after the interview** — out of scope here; that lives with the recorded `UserInterview` flow.
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 3d39766be7ec..6c9c35d89c8b 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -4710,6 +4710,38 @@
"readOnlyHint": false
}
},
+ "user-interview-topics-create": {
+ "description": "Plan a user interview by recording who you want to target and what product or idea you want to ask them about. `topic` is the free-text description of the question or product area. Targets can be specified as any combination of `interviewee_cohort` (optional cohort identifier), `interviewee_emails` (list of email addresses), and `interviewee_distinct_ids` (list of PostHog distinct IDs) — at least one target must be provided. Pass `agent_context` (free text) to give the voice agent extra background or instructions, and `questions` (list of strings) for the ordered set of questions the agent should work through.",
+ "category": "User interview topics",
+ "feature": "user_interviews",
+ "summary": "Create user interview topic",
+ "title": "Create user interview topic",
+ "required_scopes": ["user_interview:write"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "user-interviews"
+ },
+ "user-interview-topics-list": {
+ "description": "List planned user interview topics in the current project, newest first. Each result includes the topic, targeting (interviewee_cohort, interviewee_emails, interviewee_distinct_ids), and the voice agent setup (agent_context, questions). Supports `search` for substring match against the topic, and `limit`/`offset` for pagination.",
+ "category": "User interview topics",
+ "feature": "user_interviews",
+ "summary": "List user interview topics",
+ "title": "List user interview topics",
+ "required_scopes": ["user_interview:read"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_flag": "user-interviews"
+ },
"user-settings-update": {
"description": "Update the authenticated user's profile and settings using PATCH semantics — only the fields included in the request body are changed. Pass `@me` as the UUID; non-staff callers may only update their own account. Use `user-get` first to inspect current settings. `notification_settings` merges key-by-key; changing `email` triggers a verification flow; changing `password` also requires `current_password`. Always confirm changes with the user before applying.",
"category": "Core",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index ebcaed5b5e2b..15a8e93a9f81 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -5191,6 +5191,38 @@
"readOnlyHint": false
}
},
+ "user-interview-topics-create": {
+ "description": "Plan a user interview by recording who you want to target and what product or idea you want to ask them about. `topic` is the free-text description of the question or product area. Targets can be specified as any combination of `interviewee_cohort` (optional cohort identifier), `interviewee_emails` (list of email addresses), and `interviewee_distinct_ids` (list of PostHog distinct IDs) — at least one target must be provided. Pass `agent_context` (free text) to give the voice agent extra background or instructions, and `questions` (list of strings) for the ordered set of questions the agent should work through.",
+ "category": "User interview topics",
+ "feature": "user_interviews",
+ "summary": "Create user interview topic",
+ "title": "Create user interview topic",
+ "required_scopes": ["user_interview:write"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "user-interviews"
+ },
+ "user-interview-topics-list": {
+ "description": "List planned user interview topics in the current project, newest first. Each result includes the topic, targeting (interviewee_cohort, interviewee_emails, interviewee_distinct_ids), and the voice agent setup (agent_context, questions). Supports `search` for substring match against the topic, and `limit`/`offset` for pagination.",
+ "category": "User interview topics",
+ "feature": "user_interviews",
+ "summary": "List user interview topics",
+ "title": "List user interview topics",
+ "required_scopes": ["user_interview:read"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_flag": "user-interviews"
+ },
"user-settings-update": {
"description": "Update the authenticated user's profile and settings using PATCH semantics — only the fields included in the request body are changed. Pass `@me` as the UUID; non-staff callers may only update their own account. Use `user-get` first to inspect current settings. `notification_settings` merges key-by-key; changing `email` triggers a verification flow; changing `password` also requires `current_password`. Always confirm changes with the user before applying.",
"category": "Core",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index e364def02b85..0437b33f75cd 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -24269,6 +24269,36 @@ export namespace Schemas {
results: UserInterview[];
}
+ export interface UserInterviewTopic {
+ readonly id: string;
+ readonly created_by: UserBasic;
+ readonly created_at: string;
+ /**
+ * Optional cohort ID identifying who to target. Not enforced as a foreign key.
+ * @nullable
+ */
+ interviewee_cohort?: number | null;
+ /** Email addresses of people to interview. May be combined with interviewee_cohort and interviewee_distinct_ids. */
+ interviewee_emails?: string[];
+ /** PostHog distinct IDs of people to interview. May be combined with interviewee_cohort and interviewee_emails. */
+ interviewee_distinct_ids?: string[];
+ /** The product, feature, or idea you want to ask interviewees about. */
+ topic: string;
+ /** Optional additional system prompt for the voice agent — extra background, tone, or constraints. */
+ agent_context?: string;
+ /** Ordered list of questions the voice agent should work through during the interview. */
+ questions?: string[];
+ }
+
+ export interface PaginatedUserInterviewTopicList {
+ count: number;
+ /** @nullable */
+ next?: string | null;
+ /** @nullable */
+ previous?: string | null;
+ results: UserInterviewTopic[];
+ }
+
/**
* * `disabled` - disabled
* `toolbar` - toolbar
@@ -29937,6 +29967,27 @@ export namespace Schemas {
audio?: string;
}
+ export interface PatchedUserInterviewTopic {
+ readonly id?: string;
+ readonly created_by?: UserBasic;
+ readonly created_at?: string;
+ /**
+ * Optional cohort ID identifying who to target. Not enforced as a foreign key.
+ * @nullable
+ */
+ interviewee_cohort?: number | null;
+ /** Email addresses of people to interview. May be combined with interviewee_cohort and interviewee_distinct_ids. */
+ interviewee_emails?: string[];
+ /** PostHog distinct IDs of people to interview. May be combined with interviewee_cohort and interviewee_emails. */
+ interviewee_distinct_ids?: string[];
+ /** The product, feature, or idea you want to ask interviewees about. */
+ topic?: string;
+ /** Optional additional system prompt for the voice agent — extra background, tone, or constraints. */
+ agent_context?: string;
+ /** Ordered list of questions the voice agent should work through during the interview. */
+ questions?: string[];
+ }
+
export interface PatchedUserProductList {
readonly id?: string;
readonly product_path?: string;
@@ -39191,6 +39242,21 @@ export namespace Schemas {
SpanResourceAttribute: 'span_resource_attribute',
} as const;
+ export type UserInterviewTopicsListParams = {
+ /**
+ * Number of results to return per page.
+ */
+ limit?: number;
+ /**
+ * The initial index from which to return the results.
+ */
+ offset?: number;
+ /**
+ * A search term.
+ */
+ search?: string;
+ };
+
export type UserInterviewsListParams = {
/**
* Number of results to return per page.
diff --git a/services/mcp/src/generated/user_interviews/api.ts b/services/mcp/src/generated/user_interviews/api.ts
new file mode 100644
index 000000000000..7e30526d4897
--- /dev/null
+++ b/services/mcp/src/generated/user_interviews/api.ts
@@ -0,0 +1,69 @@
+/**
+ * Auto-generated from the Django backend OpenAPI schema.
+ * MCP service uses these Zod schemas for generated tool handlers.
+ * To regenerate: hogli build:openapi
+ *
+ * PostHog API - MCP 2 enabled ops
+ * OpenAPI spec version: 1.0.0
+ */
+import * as zod from 'zod'
+
+/**
+ * Planned user interview topics: who we want to target (cohort) and what we want to ask about.
+ */
+export const UserInterviewTopicsListParams = /* @__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 UserInterviewTopicsListQueryParams = /* @__PURE__ */ zod.object({
+ limit: zod.number().optional().describe('Number of results to return per page.'),
+ offset: zod.number().optional().describe('The initial index from which to return the results.'),
+ search: zod.string().optional().describe('A search term.'),
+})
+
+/**
+ * Planned user interview topics: who we want to target (cohort) and what we want to ask about.
+ */
+export const UserInterviewTopicsCreateParams = /* @__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 userInterviewTopicsCreateBodyIntervieweeEmailsItemMax = 254
+
+export const userInterviewTopicsCreateBodyIntervieweeDistinctIdsItemMax = 400
+
+export const UserInterviewTopicsCreateBody = /* @__PURE__ */ zod.object({
+ interviewee_cohort: zod
+ .number()
+ .nullish()
+ .describe('Optional cohort ID identifying who to target. Not enforced as a foreign key.'),
+ interviewee_emails: zod
+ .array(zod.string().max(userInterviewTopicsCreateBodyIntervieweeEmailsItemMax))
+ .optional()
+ .describe(
+ 'Email addresses of people to interview. May be combined with interviewee_cohort and interviewee_distinct_ids.'
+ ),
+ interviewee_distinct_ids: zod
+ .array(zod.string().max(userInterviewTopicsCreateBodyIntervieweeDistinctIdsItemMax))
+ .optional()
+ .describe(
+ 'PostHog distinct IDs of people to interview. May be combined with interviewee_cohort and interviewee_emails.'
+ ),
+ topic: zod.string().describe('The product, feature, or idea you want to ask interviewees about.'),
+ agent_context: zod
+ .string()
+ .optional()
+ .describe('Optional additional system prompt for the voice agent — extra background, tone, or constraints.'),
+ questions: zod
+ .array(zod.string())
+ .optional()
+ .describe('Ordered list of questions the voice agent should work through during the interview.'),
+})
diff --git a/services/mcp/src/lib/oauth-scopes.generated.ts b/services/mcp/src/lib/oauth-scopes.generated.ts
index ed68473ae9bf..506469d23f57 100644
--- a/services/mcp/src/lib/oauth-scopes.generated.ts
+++ b/services/mcp/src/lib/oauth-scopes.generated.ts
@@ -163,6 +163,8 @@ export const OAUTH_SCOPES_SUPPORTED = [
'usage_metric:write',
'user:read',
'user:write',
+ 'user_interview:read',
+ 'user_interview:write',
'visual_review:read',
'visual_review:write',
'warehouse_objects:read',
diff --git a/services/mcp/src/tools/generated/index.ts b/services/mcp/src/tools/generated/index.ts
index dde4509bb4ce..e6756c3215d1 100644
--- a/services/mcp/src/tools/generated/index.ts
+++ b/services/mcp/src/tools/generated/index.ts
@@ -33,6 +33,7 @@ import { GENERATED_TOOLS as sdk_doctor } from './sdk_doctor'
import { GENERATED_TOOLS as signals } from './signals'
import { GENERATED_TOOLS as surveys } from './surveys'
import { GENERATED_TOOLS as tracing } from './tracing'
+import { GENERATED_TOOLS as user_interviews } from './user_interviews'
import { GENERATED_TOOLS as visual_review } from './visual_review'
import { GENERATED_TOOLS as web_analytics } from './web_analytics'
import { GENERATED_TOOLS as workflows } from './workflows'
@@ -70,6 +71,7 @@ export const GENERATED_TOOL_MAP: Record<string, () => ToolBase<ZodObjectAny>> =
...signals,
...surveys,
...tracing,
+ ...user_interviews,
...visual_review,
...web_analytics,
...workflows,
diff --git a/services/mcp/src/tools/generated/user_interviews.ts b/services/mcp/src/tools/generated/user_interviews.ts
new file mode 100644
index 000000000000..c606b13238a8
--- /dev/null
+++ b/services/mcp/src/tools/generated/user_interviews.ts
@@ -0,0 +1,70 @@
+// AUTO-GENERATED from products/user_interviews/mcp/tools.yaml + OpenAPI — do not edit
+import { z } from 'zod'
+
+import type { Schemas } from '@/api/generated'
+import { UserInterviewTopicsCreateBody, UserInterviewTopicsListQueryParams } from '@/generated/user_interviews/api'
+import { withPostHogUrl, type WithPostHogUrl } from '@/tools/tool-utils'
+import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'
+
+const UserInterviewTopicsCreateSchema = UserInterviewTopicsCreateBody
+
+const userInterviewTopicsCreate = (): ToolBase<typeof UserInterviewTopicsCreateSchema, Schemas.UserInterviewTopic> => ({
+ name: 'user-interview-topics-create',
+ schema: UserInterviewTopicsCreateSchema,
+ handler: async (context: Context, params: z.infer<typeof UserInterviewTopicsCreateSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.interviewee_cohort !== undefined) {
+ body['interviewee_cohort'] = params.interviewee_cohort
+ }
+ if (params.interviewee_emails !== undefined) {
+ body['interviewee_emails'] = params.interviewee_emails
+ }
+ if (params.interviewee_distinct_ids !== undefined) {
+ body['interviewee_distinct_ids'] = params.interviewee_distinct_ids
+ }
+ if (params.topic !== undefined) {
+ body['topic'] = params.topic
+ }
+ if (params.agent_context !== undefined) {
+ body['agent_context'] = params.agent_context
+ }
+ if (params.questions !== undefined) {
+ body['questions'] = params.questions
+ }
+ const result = await context.api.request<Schemas.UserInterviewTopic>({
+ method: 'POST',
+ path: `/api/environments/${encodeURIComponent(String(projectId))}/user_interview_topics/`,
+ body,
+ })
+ return result
+ },
+})
+
+const UserInterviewTopicsListSchema = UserInterviewTopicsListQueryParams
+
+const userInterviewTopicsList = (): ToolBase<
+ typeof UserInterviewTopicsListSchema,
+ WithPostHogUrl<Schemas.PaginatedUserInterviewTopicList>
+> => ({
+ name: 'user-interview-topics-list',
+ schema: UserInterviewTopicsListSchema,
+ handler: async (context: Context, params: z.infer<typeof UserInterviewTopicsListSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const result = await context.api.request<Schemas.PaginatedUserInterviewTopicList>({
+ method: 'GET',
+ path: `/api/environments/${encodeURIComponent(String(projectId))}/user_interview_topics/`,
+ query: {
+ limit: params.limit,
+ offset: params.offset,
+ search: params.search,
+ },
+ })
+ return await withPostHogUrl(context, result, '/user_interviews')
+ },
+})
+
+export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
+ 'user-interview-topics-create': userInterviewTopicsCreate,
+ 'user-interview-topics-list': userInterviewTopicsList,
+}
diff --git a/services/mcp/tests/unit/tool-filtering.test.ts b/services/mcp/tests/unit/tool-filtering.test.ts
index 919662f70a6f..ee8eae2c487b 100644
--- a/services/mcp/tests/unit/tool-filtering.test.ts
+++ b/services/mcp/tests/unit/tool-filtering.test.ts
@@ -642,9 +642,10 @@ describe('Tool Filtering - Feature Flags', () => {
'tracing',
'visual-review',
'mcp-feedback-tool',
+ 'user-interviews',
])
)
- expect(flags).toHaveLength(5)
+ expect(flags).toHaveLength(6)
})
// Test the filtering logic with a direct unit test approach using