:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(tasks): enable tasks-create MCP tool (#72279)
Andrew Maguire665de47f2dbe
diff --git a/products/tasks/mcp/tools.yaml b/products/tasks/mcp/tools.yamlindex 9c66fbfcc29e..e5a4e6a3f118 100644--- a/products/tasks/mcp/tools.yaml+++ b/products/tasks/mcp/tools.yaml@@ -92,7 +92,45 @@ tools:enabled: falsetasks-create:operation: tasks_create- enabled: false+ enabled: true+ scopes:+ - task:write+ annotations:+ readOnly: false+ destructive: false+ idempotent: false+ enrich_url: '{id}'+ title: Create task+ description: >+ Create an agent task in the current project — a unit of work an AI agent picks up and actions, such as+ investigating an inbox report, fixing an error, or opening a pull request. `description` is the prompt+ handed to the agent, so make it specific and actionable. Pass `repository` in `organization/repo` format for+ code tasks so the agent knows where to work; omit it for investigation-only tasks. This creates the task+ record only — it does not start the agent. Returns the created task including its URL; open that URL to+ start the run. Requires the calling token's organization to have Tasks access enabled.+ include_params:+ - title+ - description+ - repository+ param_overrides:+ description:+ description: >+ The task for the agent to carry out, written as a direct prompt (e.g. "Investigate the spike in+ $exception events on the checkout page and open a PR with a fix"). Passed verbatim to the agent as+ its instructions, so be specific.+ required: true+ feature_flag: tasks+ response:+ include:+ - id+ - task_number+ - title+ - description+ - origin_product+ - repository+ - internal+ - created_at+ - updated_attasks-destroy:operation: tasks_destroyenabled: falsediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex c39a78fc470f..cb31db10d597 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -8666,6 +8666,21 @@"readOnlyHint": true}},+ "tasks-create": {+ "description": "Create an agent task in the current project — a unit of work an AI agent picks up and actions, such as investigating an inbox report, fixing an error, or opening a pull request. `description` is the prompt handed to the agent, so make it specific and actionable. Pass `repository` in `organization/repo` format for code tasks so the agent knows where to work; omit it for investigation-only tasks. This creates the task record only — it does not start the agent. Returns the created task including its URL; open that URL to start the run. Requires the calling token's organization to have Tasks access enabled.",+ "category": "Tasks",+ "feature": "tasks",+ "summary": "Create task",+ "title": "Create task",+ "required_scopes": ["task:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": false,+ "openWorldHint": true,+ "readOnlyHint": false+ },+ "feature_flag": "tasks"+ },"tasks-list": {"description": "List agent tasks in the current project. Supports filtering by `origin_product`, `stage`, `organization`, `repository`, `created_by`, and `internal`. Returns lightweight task metadata only — call tasks-retrieve for the full task including its latest run, or tasks-runs-list for run history. Requires the calling token's organization to have Tasks access enabled.","category": "Tasks",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex d5aba11e454f..1e4b268a5864 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -9216,6 +9216,21 @@"readOnlyHint": false}},+ "tasks-create": {+ "description": "Create an agent task in the current project — a unit of work an AI agent picks up and actions, such as investigating an inbox report, fixing an error, or opening a pull request. `description` is the prompt handed to the agent, so make it specific and actionable. Pass `repository` in `organization/repo` format for code tasks so the agent knows where to work; omit it for investigation-only tasks. This creates the task record only — it does not start the agent. Returns the created task including its URL; open that URL to start the run. Requires the calling token's organization to have Tasks access enabled.",+ "category": "Tasks",+ "feature": "tasks",+ "summary": "Create task",+ "title": "Create task",+ "required_scopes": ["task:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": false,+ "openWorldHint": true,+ "readOnlyHint": false+ },+ "feature_flag": "tasks"+ },"tasks-list": {"description": "List agent tasks in the current project. Supports filtering by `origin_product`, `stage`, `organization`, `repository`, `created_by`, and `internal`. Returns lightweight task metadata only — call tasks-retrieve for the full task including its latest run, or tasks-runs-list for run history. Requires the calling token's organization to have Tasks access enabled.","category": "Tasks",diff --git a/services/mcp/src/generated/tasks/api.ts b/services/mcp/src/generated/tasks/api.tsindex a2ba2dd087a9..a2014e6040a1 100644--- a/services/mcp/src/generated/tasks/api.ts+++ b/services/mcp/src/generated/tasks/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'@@ -77,6 +77,168 @@ export const TasksListQueryParams = /* @__PURE__ */ zod.object({),})+/**+ * API for managing tasks within a project. Tasks represent units of work to be performed by an agent.+ */+export const TasksCreateParams = /* @__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 tasksCreateBodyTitleMax = 255++export const tasksCreateBodyRepositoryMax = 255++export const tasksCreateBodySignalReportTaskRelationshipMax = 200++export const tasksCreateBodyBranchMax = 255++export const tasksCreateBodyPendingUserArtifactIdsItemMax = 128++export const TasksCreateBody = /* @__PURE__ */ zod+ .object({+ title: zod+ .string()+ .max(tasksCreateBodyTitleMax)+ .optional()+ .describe('Short human-readable title. Auto-generated from `description` when omitted.'),+ title_manually_set: zod+ .boolean()+ .optional()+ .describe('Whether the title was set by a human (vs auto-generated from the description).'),+ description: zod+ .string()+ .optional()+ .describe('Free-form description of the work to be done. Used as the prompt passed to the agent.'),+ origin_product: zod+ .enum([+ 'onboarding',+ 'error_tracking',+ 'eval_clusters',+ 'user_created',+ 'automation',+ 'slack',+ 'support_queue',+ 'session_summaries',+ 'posthog_ai',+ 'experiments',+ 'signal_report',+ 'signals_scout',+ 'support_reply',+ 'hogdesk',+ 'review_hog',+ 'image_builder',+ ])+ .describe(+ '* `onboarding` - Onboarding\n* `error_tracking` - Error Tracking\n* `eval_clusters` - Eval Clusters\n* `user_created` - User Created\n* `automation` - Automation\n* `slack` - Slack\n* `support_queue` - Support Queue\n* `session_summaries` - Session Summaries\n* `posthog_ai` - PostHog AI\n* `experiments` - Experiments\n* `signal_report` - Signal Report\n* `signals_scout` - Signals Scout\n* `support_reply` - Support Reply\n* `hogdesk` - HogDesk\n* `review_hog` - ReviewHog\n* `image_builder` - Image Builder'+ )+ .optional()+ .describe(+ 'PostHog product or surface that created this task (e.g. error_tracking, slack, user_created).\n\n* `onboarding` - Onboarding\n* `error_tracking` - Error Tracking\n* `eval_clusters` - Eval Clusters\n* `user_created` - User Created\n* `automation` - Automation\n* `slack` - Slack\n* `support_queue` - Support Queue\n* `session_summaries` - Session Summaries\n* `posthog_ai` - PostHog AI\n* `experiments` - Experiments\n* `signal_report` - Signal Report\n* `signals_scout` - Signals Scout\n* `support_reply` - Support Reply\n* `hogdesk` - HogDesk\n* `review_hog` - ReviewHog\n* `image_builder` - Image Builder'+ ),+ repository: zod+ .string()+ .max(tasksCreateBodyRepositoryMax)+ .nullish()+ .describe('Target GitHub repository in `organization/repo` format (e.g. `posthog/posthog-js`).'),+ github_integration: zod.number().nullish().describe('GitHub integration for this task.'),+ github_user_integration: zod+ .string()+ .nullish()+ .describe('User-scoped GitHub integration to use for user-authored cloud runs.'),+ signal_report: zod+ .string()+ .nullish()+ .describe('Signal report this task implements, when created from a report.'),+ signal_report_task_relationship: zod+ .string()+ .max(tasksCreateBodySignalReportTaskRelationshipMax)+ .optional()+ .describe(+ "How the created task relates to the signal report (e.g. 'implementation', 'discussion', 'research'). Recorded as a signals task_run work-log entry; 'implementation' also opens the auto-start spend gate. Any routing-safe identifier (lowercase letters, numbers, '_', '-') is accepted."+ ),+ json_schema: zod.unknown().optional().describe('JSON schema used to validate the output of the task.'),+ internal: zod+ .boolean()+ .optional()+ .describe('If true, this task is for internal use and should not be exposed to end users.'),+ archived: zod.boolean().optional().describe('If true, the task is hidden from default list responses.'),+ ci_prompt: zod+ .string()+ .nullish()+ .describe('Custom prompt for CI fixes. If blank, a default prompt will be used.'),+ branch: zod+ .string()+ .max(tasksCreateBodyBranchMax)+ .nullish()+ .describe(+ 'Branch the user has selected for this cloud task. Write-only and not persisted on the task itself: used only to reuse a matching pre-warmed sandbox Run on creation (the branch is otherwise carried on the run). Omit to match a warm Run on the default branch.'+ ),+ runtime_adapter: zod+ .union([zod.enum(['claude', 'codex']).describe('* `claude` - claude\n* `codex` - codex'), zod.null()])+ .optional()+ .describe(+ "Selected runtime adapter ('claude' or 'codex'). Write-only and not persisted on the task: used only to reuse a pre-warmed Run started on the same runtime. A value differing from the warm Run's runtime skips reuse so the task isn't silently run on the wrong runtime.\n\n* `claude` - claude\n* `codex` - codex"+ ),+ model: zod+ .string()+ .nullish()+ .describe(+ 'Selected LLM model identifier. Write-only; used only to reuse a warm Run started on the same model.'+ ),+ reasoning_effort: zod+ .union([+ zod+ .enum(['low', 'medium', 'high', 'xhigh', 'max'])+ .describe('* `low` - low\n* `medium` - medium\n* `high` - high\n* `xhigh` - xhigh\n* `max` - max'),+ zod.null(),+ ])+ .optional()+ .describe(+ 'Selected reasoning effort. Write-only; used only to reuse a warm Run started on the same effort.\n\n* `low` - low\n* `medium` - medium\n* `high` - high\n* `xhigh` - xhigh\n* `max` - max'+ ),+ pending_user_message: zod+ .string()+ .nullish()+ .describe(+ 'First user message to forward when creation reuses a pre-warmed Run. Write-only and not persisted on the task: lets clients deliver a message that differs from `description` (e.g. a resolved skill invocation with channel context folded in). Ignored when no warm Run is reused — cold creation takes the first message via the run start endpoint instead.'+ ),+ pending_user_artifact_ids: zod+ .array(zod.string().max(tasksCreateBodyPendingUserArtifactIdsItemMax))+ .optional()+ .describe(+ "Run artifact ids (already uploaded to the pre-warmed Run) to attach to the forwarded first message when creation reuses that warm Run, e.g. skill bundles or file attachments. If any id is missing from the warm Run's manifest, warm reuse is skipped and the task is created cold. Ignored when no warm Run is matched."+ ),+ auto_publish: zod+ .boolean()+ .nullish()+ .describe(+ "When true, the cloud run agent pushes its work and opens a draft pull request on completion without waiting for an explicit ask. Write-only and not persisted on the task: persisted into the reused warm Run's state when creation activates one, so resumes of that Run honor it. Ignored when no warm Run is reused — cold creation takes it via the run start endpoint instead."+ ),+ channel: zod.string().nullish().describe('Channel this task is owned by (the channel it was kicked off in).'),+ sandbox_environment_id: zod+ .string()+ .nullish()+ .describe('Sandbox environment selected for matching a pre-warmed cloud run. Not persisted on the task.'),+ custom_image_id: zod+ .string()+ .nullish()+ .describe('Custom image selected for matching a pre-warmed cloud run. Not persisted on the task.'),+ runtime: zod+ .enum(['acp', 'pi'])+ .describe('* `acp` - ACP\n* `pi` - Pi')+ .optional()+ .describe(+ "Agent protocol and harness used for this task's runs. Defaults to ACP when omitted.\n\n* `acp` - ACP\n* `pi` - Pi"+ ),+ })+ .describe(+ 'Request body for creating or updating a task.\n\nField required/default semantics match the ``Task`` model. The view passes\n``validated_data`` (integration/report PK fields already resolved to instances) to the\nfacade ``create_task`` / ``update_task`` functions.'+ )+/*** Retrieve a single task by ID.* @summary Get taskdiff --git a/services/mcp/src/tools/generated/tasks.ts b/services/mcp/src/tools/generated/tasks.tsindex 0cb6d2b15484..84c0fd5c2f77 100644--- a/services/mcp/src/tools/generated/tasks.ts+++ b/services/mcp/src/tools/generated/tasks.ts@@ -3,6 +3,7 @@ import { z } from 'zod'import type { Schemas } from '@/api/generated'import {+ TasksCreateBody,TasksListQueryParams,TasksRetrieveParams,TasksRunsListParams,@@ -14,6 +15,71 @@ import {import { withPostHogUrl, pickResponseFields, omitResponseFields, type WithPostHogUrl } from '@/tools/tool-utils'import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'+const TasksCreateSchema = TasksCreateBody.omit({+ title_manually_set: true,+ origin_product: true,+ github_integration: true,+ github_user_integration: true,+ signal_report: true,+ signal_report_task_relationship: true,+ json_schema: true,+ internal: true,+ archived: true,+ ci_prompt: true,+ branch: true,+ runtime_adapter: true,+ model: true,+ reasoning_effort: true,+ pending_user_message: true,+ pending_user_artifact_ids: true,+ auto_publish: true,+ channel: true,+ sandbox_environment_id: true,+ custom_image_id: true,+ runtime: true,+}).extend({+ description: TasksCreateBody.shape['description']+ .unwrap()+ .describe(+ 'The task for the agent to carry out, written as a direct prompt (e.g. "Investigate the spike in $exception events on the checkout page and open a PR with a fix"). Passed verbatim to the agent as its instructions, so be specific.'+ ),+})++const tasksCreate = (): ToolBase<typeof TasksCreateSchema, WithPostHogUrl<Schemas.TaskDetailDTO>> => ({+ name: 'tasks-create',+ schema: TasksCreateSchema,+ handler: async (context: Context, params: z.infer<typeof TasksCreateSchema>) => {+ const projectId = await context.stateManager.getProjectId()+ const body: Record<string, unknown> = {}+ if (params.title !== undefined) {+ body['title'] = params.title+ }+ if (params.description !== undefined) {+ body['description'] = params.description+ }+ if (params.repository !== undefined) {+ body['repository'] = params.repository+ }+ const result = await context.api.request<Schemas.TaskDetailDTO>({+ method: 'POST',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/tasks/`,+ body,+ })+ const filtered = pickResponseFields(result, [+ 'id',+ 'task_number',+ 'title',+ 'description',+ 'origin_product',+ 'repository',+ 'internal',+ 'created_at',+ 'updated_at',+ ]) as typeof result+ return await withPostHogUrl(context, filtered, `/tasks/${filtered.id}`)+ },+})+const TasksListSchema = TasksListQueryParamsconst tasksList = (): ToolBase<typeof TasksListSchema, WithPostHogUrl<Schemas.PaginatedTaskDetailDTOList>> => ({@@ -179,6 +245,7 @@ const tasksRunsSessionLogsRetrieve = (): ToolBase<typeof TasksRunsSessionLogsRet})export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {+ 'tasks-create': tasksCreate,'tasks-list': tasksList,'tasks-retrieve': tasksRetrieve,'tasks-runs-list': tasksRunsList,diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-create.jsonnew file mode 100644index 000000000000..69632bbff488--- /dev/null+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-create.json@@ -0,0 +1,28 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "properties": {+ "description": {+ "description": "The task for the agent to carry out, written as a direct prompt (e.g. \"Investigate the spike in $exception events on the checkout page and open a PR with a fix\"). Passed verbatim to the agent as its instructions, so be specific.",+ "type": "string"+ },+ "repository": {+ "anyOf": [+ {+ "maxLength": 255,+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Target GitHub repository in `organization/repo` format (e.g. `posthog/posthog-js`)."+ },+ "title": {+ "description": "Short human-readable title. Auto-generated from `description` when omitted.",+ "maxLength": 255,+ "type": "string"+ }+ },+ "required": ["description"],+ "type": "object"+}