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(conversations): enable conversations-views-list MCP tool (#71573)

Abigailac01f77ceaf0
diff --git a/products/conversations/backend/api/ticket_views.py b/products/conversations/backend/api/ticket_views.py
index c6d1cfbc907b..9ddaeb30583c 100644
--- a/products/conversations/backend/api/ticket_views.py
+++ b/products/conversations/backend/api/ticket_views.py
@@ -57,7 +57,9 @@ class TicketViewViewSet(
mixins.DestroyModelMixin,
viewsets.GenericViewSet,
):
- scope_object = "conversation"
+ # "ticket" (not "conversation"): the conversation scope also authorizes AI conversation
+ # endpoints, which saved ticket views have no business granting access to
+ scope_object = "ticket"
queryset = TicketView.objects.all().order_by("-created_at")
serializer_class = TicketViewSerializer
lookup_field = "short_id"
diff --git a/products/conversations/mcp/tools.yaml b/products/conversations/mcp/tools.yaml
index e28c56dff755..9fbebfacd203 100644
--- a/products/conversations/mcp/tools.yaml
+++ b/products/conversations/mcp/tools.yaml
@@ -157,7 +157,23 @@ tools:
enabled: false
conversations-views-list:
operation: conversations_views_list
- enabled: false
+ enabled: true
+ scopes:
+ - ticket:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ list: true
+ title: List saved ticket views
+ description: >
+ List the saved ticket views in the project. Each view is a named, saved set of ticket filters — for example
+ the per-team views named "Team <name>". Returns each view's short_id and name; a view opens in the app at
+ /support/tickets?view=<short_id>.
+ response:
+ include:
+ - short_id
+ - name
conversations-views-partial-update:
operation: conversations_views_partial_update
enabled: false
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index e28104dcdf42..cb1ca8f38713 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -1899,6 +1899,20 @@
"readOnlyHint": false
}
},
+ "conversations-views-list": {
+ "description": "List the saved ticket views in the project. Each view is a named, saved set of ticket filters — for example the per-team views named \"Team <name>\". Returns each view's short_id and name; a view opens in the app at /support/tickets?view=<short_id>.",
+ "category": "Conversations",
+ "feature": "conversations",
+ "summary": "List saved ticket views",
+ "title": "List saved ticket views",
+ "required_scopes": ["ticket:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
"create-feature-flag": {
"description": "Create a feature flag in the current project.",
"category": "Feature flags",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 0e8def454110..35f18eea62fc 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -1928,6 +1928,20 @@
"readOnlyHint": false
}
},
+ "conversations-views-list": {
+ "description": "List the saved ticket views in the project. Each view is a named, saved set of ticket filters — for example the per-team views named \"Team <name>\". Returns each view's short_id and name; a view opens in the app at /support/tickets?view=<short_id>.",
+ "category": "Conversations",
+ "feature": "conversations",
+ "summary": "List saved ticket views",
+ "title": "List saved ticket views",
+ "required_scopes": ["ticket:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
"create-feature-flag": {
"description": "Create a feature flag in the current project.",
"category": "Feature flags",
diff --git a/services/mcp/src/generated/conversations/api.ts b/services/mcp/src/generated/conversations/api.ts
index acab95f27ebb..25c106a8f2d3 100644
--- a/services/mcp/src/generated/conversations/api.ts
+++ b/services/mcp/src/generated/conversations/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 6 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -209,3 +209,16 @@ export const ConversationsTicketsReplyCreateBody = /* @__PURE__ */ zod
rich_content: zod.unknown().optional().describe('Optional TipTap rich content JSON for formatted messages.'),
})
.describe('Payload for posting a reply or internal note to a ticket.')
+
+export const ConversationsViewsListParams = /* @__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 ConversationsViewsListQueryParams = /* @__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.'),
+})
diff --git a/services/mcp/src/tools/generated/conversations.ts b/services/mcp/src/tools/generated/conversations.ts
index 925b5744f623..66945a46b415 100644
--- a/services/mcp/src/tools/generated/conversations.ts
+++ b/services/mcp/src/tools/generated/conversations.ts
@@ -11,6 +11,7 @@ import {
ConversationsTicketsReplyCreateBody,
ConversationsTicketsReplyCreateParams,
ConversationsTicketsRetrieveParams,
+ ConversationsViewsListQueryParams,
} from '@/generated/conversations/api'
import { withPostHogUrl, pickResponseFields, type WithPostHogUrl } from '@/tools/tool-utils'
import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'
@@ -203,10 +204,37 @@ const conversationsTicketsUpdate = (): ToolBase<
},
})
+const ConversationsViewsListSchema = ConversationsViewsListQueryParams
+
+const conversationsViewsList = (): ToolBase<
+ typeof ConversationsViewsListSchema,
+ WithPostHogUrl<Schemas.PaginatedTicketViewList>
+> => ({
+ name: 'conversations-views-list',
+ schema: ConversationsViewsListSchema,
+ handler: async (context: Context, params: z.infer<typeof ConversationsViewsListSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const result = await context.api.request<Schemas.PaginatedTicketViewList>({
+ method: 'GET',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/conversations/views/`,
+ query: {
+ limit: params.limit,
+ offset: params.offset,
+ },
+ })
+ const filtered = {
+ ...result,
+ results: (result.results ?? []).map((item: any) => pickResponseFields(item, ['short_id', 'name'])),
+ } as typeof result
+ return await withPostHogUrl(context, filtered, '/conversations/tickets')
+ },
+})
+
export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'conversations-tickets-list': conversationsTicketsList,
'conversations-tickets-messages-retrieve': conversationsTicketsMessagesRetrieve,
'conversations-tickets-reply-create': conversationsTicketsReplyCreate,
'conversations-tickets-retrieve': conversationsTicketsRetrieve,
'conversations-tickets-update': conversationsTicketsUpdate,
+ 'conversations-views-list': conversationsViewsList,
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/conversations-views-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/conversations-views-list.json
new file mode 100644
index 000000000000..8331b796ac73
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/conversations-views-list.json
@@ -0,0 +1,14 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "limit": {
+ "description": "Number of results to return per page.",
+ "type": "number"
+ },
+ "offset": {
+ "description": "The initial index from which to return the results.",
+ "type": "number"
+ }
+ },
+ "type": "object"
+}