: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(aiobs): expose provider key read tools over MCP (#66041)
Carlos Marchalc6f542e0542b
diff --git a/frontend/src/lib/agentScopes.generated.ts b/frontend/src/lib/agentScopes.generated.tsindex 88c0d17b9dc8..93534da02630 100644--- a/frontend/src/lib/agentScopes.generated.ts+++ b/frontend/src/lib/agentScopes.generated.ts@@ -66,6 +66,7 @@ export const AGENT_USE_CASE_SCOPES = ['llm_analytics:write','llm_prompt:read','llm_prompt:write',+ 'llm_provider_key:read','llm_skill:read','llm_skill:write','logs:read',diff --git a/products/ai_observability/mcp/tools.yaml b/products/ai_observability/mcp/tools.yamlindex 7dc6ce5a2657..4e874c188b51 100644--- a/products/ai_observability/mcp/tools.yaml+++ b/products/ai_observability/mcp/tools.yaml@@ -592,10 +592,33 @@ tools:enabled: falsellma-provider-key-get:operation: llm_analytics_provider_keys_retrieve- enabled: false+ enabled: true+ scopes:+ - llm_provider_key:read+ annotations:+ readOnly: true+ destructive: false+ idempotent: true+ title: Get LLM provider key+ description: >+ Fetch one LLM provider key by ID — its provider, name, and validation state, with a masked preview (never+ the secret). Use when you have a key ID to resolve, e.g. the key an evaluation references.llma-provider-key-list:operation: llm_analytics_provider_keys_list- enabled: false+ enabled: true+ scopes:+ - llm_provider_key:read+ annotations:+ readOnly: true+ destructive: false+ idempotent: true+ list: true+ title: List LLM provider keys+ description: >+ List the team's configured LLM provider keys (OpenAI, Anthropic, Azure, etc.). Returns each key's provider,+ name, validation state, and a masked preview — never the secret itself. Call this before creating an+ llm_judge evaluation to discover which providers have a usable ('ok' state) key available. Creating,+ updating, and deleting keys are intentionally UI-only.llma-provider-key-trial-evaluations-get:operation: llm_analytics_provider_keys_trial_evaluations_retrieveenabled: falsediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex e82dc13aebc3..6b1026a43ca8 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -4472,6 +4472,34 @@"readOnlyHint": false}},+ "llma-provider-key-get": {+ "description": "Fetch one LLM provider key by ID — its provider, name, and validation state, with a masked preview (never the secret). Use when you have a key ID to resolve, e.g. the key an evaluation references.",+ "category": "AI observability",+ "feature": "llm_analytics",+ "summary": "Get LLM provider key",+ "title": "Get LLM provider key",+ "required_scopes": ["llm_provider_key:read"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ }+ },+ "llma-provider-key-list": {+ "description": "List the team's configured LLM provider keys (OpenAI, Anthropic, Azure, etc.). Returns each key's provider, name, validation state, and a masked preview — never the secret itself. Call this before creating an llm_judge evaluation to discover which providers have a usable ('ok' state) key available. Creating, updating, and deleting keys are intentionally UI-only.",+ "category": "AI observability",+ "feature": "llm_analytics",+ "summary": "List LLM provider keys",+ "title": "List LLM provider keys",+ "required_scopes": ["llm_provider_key:read"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ }+ },"llma-review-queue-create": {"description": "Create a review queue for routing traces that still need review. Queue names must be unique among active queues in the current project.","category": "AI observability",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 2dba708093e3..ec4cf2806938 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -4768,6 +4768,34 @@"readOnlyHint": false}},+ "llma-provider-key-get": {+ "description": "Fetch one LLM provider key by ID — its provider, name, and validation state, with a masked preview (never the secret). Use when you have a key ID to resolve, e.g. the key an evaluation references.",+ "category": "AI observability",+ "feature": "llm_analytics",+ "summary": "Get LLM provider key",+ "title": "Get LLM provider key",+ "required_scopes": ["llm_provider_key:read"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ }+ },+ "llma-provider-key-list": {+ "description": "List the team's configured LLM provider keys (OpenAI, Anthropic, Azure, etc.). Returns each key's provider, name, validation state, and a masked preview — never the secret itself. Call this before creating an llm_judge evaluation to discover which providers have a usable ('ok' state) key available. Creating, updating, and deleting keys are intentionally UI-only.",+ "category": "AI observability",+ "feature": "llm_analytics",+ "summary": "List LLM provider keys",+ "title": "List LLM provider keys",+ "required_scopes": ["llm_provider_key:read"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ }+ },"llma-review-queue-create": {"description": "Create a review queue for routing traces that still need review. Queue names must be unique among active queues in the current project.","category": "AI observability",diff --git a/services/mcp/src/generated/ai_observability/api.ts b/services/mcp/src/generated/ai_observability/api.tsindex d5d4cc42188e..dd3aa97efdc5 100644--- a/services/mcp/src/generated/ai_observability/api.ts+++ b/services/mcp/src/generated/ai_observability/api.ts@@ -3,7 +3,7 @@* MCP service uses these Zod schemas for generated tool handlers.* To regenerate: hogli build:openapi*- * PostHog API - MCP 55 enabled ops+ * PostHog API - MCP 57 enabled ops* OpenAPI spec version: 1.0.0*/import * as zod from 'zod'@@ -922,6 +922,28 @@ export const LlmAnalyticsModelsRetrieveQueryParams = /* @__PURE__ */ zod.object(.describe('LLM provider to list models for. Must be one of the supported providers.'),})+export const LlmAnalyticsProviderKeysListParams = /* @__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 LlmAnalyticsProviderKeysListQueryParams = /* @__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.'),+})++export const LlmAnalyticsProviderKeysRetrieveParams = /* @__PURE__ */ zod.object({+ id: zod.string().describe('A UUID string identifying this llm provider key.'),+ 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 LlmAnalyticsReviewQueueItemsListParams = /* @__PURE__ */ zod.object({project_id: zod.string()diff --git a/services/mcp/src/tools/generated/ai_observability.ts b/services/mcp/src/tools/generated/ai_observability.tsindex 219245c5ac05..ea47437fc92b 100644--- a/services/mcp/src/tools/generated/ai_observability.ts+++ b/services/mcp/src/tools/generated/ai_observability.ts@@ -31,6 +31,8 @@ import {LlmAnalyticsEvaluationSummaryCreateBody,LlmAnalyticsModelsRetrieveQueryParams,LlmAnalyticsPersonalSpendListQueryParams,+ LlmAnalyticsProviderKeysListQueryParams,+ LlmAnalyticsProviderKeysRetrieveParams,LlmAnalyticsReviewQueueItemsCreateBody,LlmAnalyticsReviewQueueItemsDestroyParams,LlmAnalyticsReviewQueueItemsListQueryParams,@@ -869,6 +871,43 @@ const llmaPromptUpdate = (): ToolBase<typeof LlmaPromptUpdateSchema, Schemas.LLM},})+const LlmaProviderKeyGetSchema = LlmAnalyticsProviderKeysRetrieveParams.omit({ project_id: true })++const llmaProviderKeyGet = (): ToolBase<typeof LlmaProviderKeyGetSchema, Schemas.LLMProviderKey> => ({+ name: 'llma-provider-key-get',+ schema: LlmaProviderKeyGetSchema,+ handler: async (context: Context, params: z.infer<typeof LlmaProviderKeyGetSchema>) => {+ const projectId = await context.stateManager.getProjectId()+ const result = await context.api.request<Schemas.LLMProviderKey>({+ method: 'GET',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/llm_analytics/provider_keys/${encodeURIComponent(String(params.id))}/`,+ })+ return result+ },+})++const LlmaProviderKeyListSchema = LlmAnalyticsProviderKeysListQueryParams++const llmaProviderKeyList = (): ToolBase<+ typeof LlmaProviderKeyListSchema,+ WithPostHogUrl<Schemas.PaginatedLLMProviderKeyList>+> => ({+ name: 'llma-provider-key-list',+ schema: LlmaProviderKeyListSchema,+ handler: async (context: Context, params: z.infer<typeof LlmaProviderKeyListSchema>) => {+ const projectId = await context.stateManager.getProjectId()+ const result = await context.api.request<Schemas.PaginatedLLMProviderKeyList>({+ method: 'GET',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/llm_analytics/provider_keys/`,+ query: {+ limit: params.limit,+ offset: params.offset,+ },+ })+ return await withPostHogUrl(context, result, '/ai-observability')+ },+})+const LlmaReviewQueueCreateSchema = LlmAnalyticsReviewQueuesCreateBodyconst llmaReviewQueueCreate = (): ToolBase<@@ -1545,6 +1584,8 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {'llma-prompt-get': llmaPromptGet,'llma-prompt-list': llmaPromptList,'llma-prompt-update': llmaPromptUpdate,+ 'llma-provider-key-get': llmaProviderKeyGet,+ 'llma-provider-key-list': llmaProviderKeyList,'llma-review-queue-create': llmaReviewQueueCreate,'llma-review-queue-delete': llmaReviewQueueDelete,'llma-review-queue-get': llmaReviewQueueGet,diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-provider-key-get.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-provider-key-get.jsonnew file mode 100644index 000000000000..50745dbeca5c--- /dev/null+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-provider-key-get.json@@ -0,0 +1,11 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "properties": {+ "id": {+ "description": "A UUID string identifying this llm provider key.",+ "type": "string"+ }+ },+ "required": ["id"],+ "type": "object"+}diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-provider-key-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-provider-key-list.jsonnew file mode 100644index 000000000000..8331b796ac73--- /dev/null+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/llma-provider-key-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"+}