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.

fix(mcp): use rag endpoint for inkeep docs (#56636)

Georgiy Tarasov5dfb1ba29987
diff --git a/ee/hogai/tools/search.py b/ee/hogai/tools/search.py
index 5b2ae3f8cff8..c5f4102aa494 100644
--- a/ee/hogai/tools/search.py
+++ b/ee/hogai/tools/search.py
@@ -169,36 +169,47 @@ URL: {url}
""".strip()
-class InkeepDocsSearchTool(MaxSubtool):
- async def execute(self, query: str, tool_call_id: str) -> tuple[str, ToolMessagesArtifact | None]:
- model = ChatOpenAI(
- model="inkeep-rag",
- base_url="https://api.inkeep.com/v1/",
- api_key=settings.INKEEP_API_KEY,
- streaming=False,
- stream_usage=False,
- disable_streaming=True,
- )
+async def perform_inkeep_docs_search(query: str, *, include_system_reminder: bool = True) -> str:
+ model = ChatOpenAI(
+ model="inkeep-rag",
+ base_url="https://api.inkeep.com/v1/",
+ api_key=settings.INKEEP_API_KEY,
+ streaming=False,
+ stream_usage=False,
+ disable_streaming=True,
+ )
- prompt = ChatPromptTemplate.from_messages([("user", "{query}")])
- chain = prompt | model | SimpleJsonOutputParser()
- rag_context_raw = await chain.ainvoke({"query": query})
+ prompt = ChatPromptTemplate.from_messages([("user", "{query}")])
+ chain = prompt | model | SimpleJsonOutputParser()
+ rag_context_raw = await chain.ainvoke({"query": query})
- if not rag_context_raw or not rag_context_raw.get("content"):
- return DOCS_SEARCH_NO_RESULTS_TEMPLATE, None
+ return format_inkeep_docs_response(rag_context_raw, include_system_reminder=include_system_reminder)
- rag_context = InkeepResponse.model_validate(rag_context_raw)
- docs = []
+def format_inkeep_docs_response(rag_context_raw: dict | None, *, include_system_reminder: bool = True) -> str:
+ """Format an Inkeep RAG payload (already JSON-parsed) into the agent-facing markdown.
+
+ Shared between the LangChain `InkeepDocsSearchTool` (which uses ChatOpenAI) and the
+ typed `MCPToolsViewSet.docs_search` endpoint (which uses the plain openai client).
+ """
+ docs: list[str] = []
+ if rag_context_raw and rag_context_raw.get("content"):
+ rag_context = InkeepResponse.model_validate(rag_context_raw)
for doc in rag_context.content:
if doc.type != "document":
continue
-
text = doc.source.content[0].text if doc.source.content else ""
docs.append(DOC_ITEM_TEMPLATE.format(title=doc.title, url=doc.url, text=text))
- if not docs:
- return DOCS_SEARCH_NO_RESULTS_TEMPLATE, None
+ if not docs:
+ return DOCS_SEARCH_NO_RESULTS_TEMPLATE if include_system_reminder else "No documentation found."
+
+ formatted_docs = "\n\n---\n\n".join(docs)
+ if include_system_reminder:
+ return DOCS_SEARCH_RESULTS_TEMPLATE.format(count=len(docs), docs=formatted_docs)
+ return f"Found {len(docs)} relevant documentation page(s):\n\n{formatted_docs}"
- formatted_docs = "\n\n---\n\n".join(docs)
- return DOCS_SEARCH_RESULTS_TEMPLATE.format(count=len(docs), docs=formatted_docs), None
+
+class InkeepDocsSearchTool(MaxSubtool):
+ async def execute(self, query: str, tool_call_id: str) -> tuple[str, ToolMessagesArtifact | None]:
+ return await perform_inkeep_docs_search(query), None
diff --git a/posthog/hogql_queries/web_analytics/test/__snapshots__/test_web_stats_table.ambr b/posthog/hogql_queries/web_analytics/test/__snapshots__/test_web_stats_table.ambr
index d445fd52fb42..edaeaca8abbe 100644
--- a/posthog/hogql_queries/web_analytics/test/__snapshots__/test_web_stats_table.ambr
+++ b/posthog/hogql_queries/web_analytics/test/__snapshots__/test_web_stats_table.ambr
@@ -624,94 +624,13 @@
# ---
# name: TestWebStatsTableQueryRunner.test_bounce_rate.2
'''
- SELECT counts.breakdown_value AS `context.columns.breakdown_value`,
- tuple(counts.visitors, counts.previous_visitors) AS `context.columns.visitors`,
- tuple(counts.views, counts.previous_views) AS `context.columns.views`,
- tuple(bounce.bounce_rate, bounce.previous_bounce_rate) AS `context.columns.bounce_rate`,
- divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`
- FROM
- (SELECT breakdown_value AS breakdown_value,
- uniqIf(filtered_person_id, and(ifNull(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), 0), ifNull(lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC'))), 0))) AS visitors,
- uniqIf(filtered_person_id, 0) AS previous_visitors,
- sumIf(filtered_pageview_count, and(ifNull(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), 0), ifNull(lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC'))), 0))) AS views,
- sumIf(filtered_pageview_count, 0) AS previous_views
- FROM
- (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
- count() AS filtered_pageview_count,
- replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$pathname'), ''), 'null'), '^"|"$', '') AS breakdown_value,
- events__session.session_id AS session_id,
- min(events__session.`$start_timestamp`) AS start_timestamp
- FROM
- (SELECT events.`$session_id_uuid`,
- events.distinct_id,
- events.event,
- events.person_id,
- events.properties,
- events.timestamp
- FROM events
- WHERE and(equals(events.team_id, 99999), greaterOrEquals(toDate(events.timestamp), '2023-12-01'), lessOrEquals(toDate(events.timestamp), '2023-12-16'))) AS events
- LEFT JOIN
- (SELECT toString(reinterpretAsUUID(bitOr(bitShiftLeft(raw_sessions.session_id_v7, 64), bitShiftRight(raw_sessions.session_id_v7, 64)))) AS session_id,
- min(toTimeZone(raw_sessions.min_timestamp, 'UTC')) AS `$start_timestamp`,
- raw_sessions.session_id_v7 AS session_id_v7
- FROM raw_sessions
- WHERE and(equals(raw_sessions.team_id, 99999), greaterOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), minus(assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC')), toIntervalDay(3))), lessOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), plus(assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')), toIntervalDay(3))))
- GROUP BY raw_sessions.session_id_v7) AS events__session ON equals(events.`$session_id_uuid`, events__session.session_id_v7)
- LEFT OUTER JOIN
- (SELECT tupleElement(argMax(tuple(person_distinct_id_overrides.person_id), person_distinct_id_overrides.version), 1) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING ifNull(equals(tupleElement(argMax(tuple(person_distinct_id_overrides.is_deleted), person_distinct_id_overrides.version), 1), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)
- WHERE and(or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1, 1)
- GROUP BY session_id,
- breakdown_value)
- GROUP BY breakdown_value) AS counts
- LEFT JOIN
- (SELECT breakdown_value AS breakdown_value,
- avgIf(is_bounce, and(ifNull(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), 0), ifNull(lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC'))), 0))) AS bounce_rate,
- avgIf(is_bounce, 0) AS previous_bounce_rate
- FROM
- (SELECT events__session.`$entry_pathname` AS breakdown_value,
- any(events__session.`$is_bounce`) AS is_bounce,
- events__session.session_id AS session_id,
- min(events__session.`$start_timestamp`) AS start_timestamp
- FROM
- (SELECT events.`$session_id_uuid`,
- events.distinct_id,
- events.event,
- events.timestamp
- FROM events
- WHERE and(equals(events.team_id, 99999), greaterOrEquals(toDate(events.timestamp), '2023-12-01'), lessOrEquals(toDate(events.timestamp), '2023-12-16'))) AS events
- LEFT JOIN
- (SELECT path(nullIf(nullIf(argMinMerge(raw_sessions.entry_url), 'null'), '')) AS `$entry_pathname`,
- if(ifNull(equals(uniqMerge(raw_sessions.pageview_uniq), 0), 0), NULL, not(or(ifNull(greater(uniqMerge(raw_sessions.pageview_uniq), 1), 0), ifNull(greater(uniqMerge(raw_sessions.autocapture_uniq), 0), 0), greaterOrEquals(dateDiff('second', min(toTimeZone(raw_sessions.min_timestamp, 'UTC')), max(toTimeZone(raw_sessions.max_timestamp, 'UTC'))), 10)))) AS `$is_bounce`,
- toString(reinterpretAsUUID(bitOr(bitShiftLeft(raw_sessions.session_id_v7, 64), bitShiftRight(raw_sessions.session_id_v7, 64)))) AS session_id,
- min(toTimeZone(raw_sessions.min_timestamp, 'UTC')) AS `$start_timestamp`,
- raw_sessions.session_id_v7 AS session_id_v7
- FROM raw_sessions
- WHERE and(equals(raw_sessions.team_id, 99999), greaterOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), minus(assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC')), toIntervalDay(3))), lessOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), plus(assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')), toIntervalDay(3))))
- GROUP BY raw_sessions.session_id_v7) AS events__session ON equals(events.`$session_id_uuid`, events__session.session_id_v7)
- WHERE and(or(equals(events.event, '$pageview'), equals(events.event, '$screen')), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-02 12:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-15 23:59:59', 'UTC')))), 0), 1, 1)
- GROUP BY session_id,
- breakdown_value)
- GROUP BY breakdown_value) AS bounce ON equals(counts.breakdown_value, bounce.breakdown_value)
- WHERE isNotNull(counts.breakdown_value)
- ORDER BY `context.columns.visitors` DESC,
- `context.columns.views` DESC,
- `context.columns.breakdown_value` ASC
- LIMIT 101
- OFFSET 0 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
+
+ SELECT timestamp
+ from events
+ WHERE team_id = 99999
+ AND timestamp > '2015-01-01'
+ order by timestamp
+ limit 1
'''
# ---
# name: TestWebStatsTableQueryRunner.test_bounce_rate_one_user
diff --git a/products/posthog_ai/backend/api/mcp_tools.py b/products/posthog_ai/backend/api/mcp_tools.py
index 1c70178619dc..a52291fc7e50 100644
--- a/products/posthog_ai/backend/api/mcp_tools.py
+++ b/products/posthog_ai/backend/api/mcp_tools.py
@@ -1,20 +1,25 @@
+import json
from typing import cast
+from django.conf import settings
from django.views.generic import View
import pydantic
from asgiref.sync import async_to_sync
from drf_spectacular.types import OpenApiTypes
-from drf_spectacular.utils import OpenApiParameter, extend_schema
+from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schema
+from openai import AsyncOpenAI
from posthoganalytics import capture_exception
-from rest_framework import status
+from rest_framework import serializers, status
from rest_framework.decorators import action
+from rest_framework.exceptions import APIException
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet
from structlog import get_logger
from posthog.api.documentation import _FallbackSerializer
+from posthog.api.mixins import ValidatedRequest, validated_request
from posthog.api.routing import TeamAndOrgViewSetMixin
from posthog.clickhouse.query_tagging import Feature, tags_context
from posthog.models.user import User
@@ -22,10 +27,36 @@ from posthog.renderers import SafeJSONRenderer
from ee.hogai.mcp_tool import mcp_tool_registry
from ee.hogai.tool_errors import MaxToolError
+from ee.hogai.tools.search import format_inkeep_docs_response
logger = get_logger(__name__)
+class DocsSearchRequestSerializer(serializers.Serializer):
+ query = serializers.CharField(
+ help_text=(
+ "Natural-language description of what to find in the PostHog documentation. "
+ "Inkeep performs hybrid (semantic + full-text) RAG, so phrase the query the way "
+ "a user would ask the question."
+ )
+ )
+
+
+class DocsSearchResponseSerializer(serializers.Serializer):
+ content = serializers.CharField(
+ help_text=(
+ "Markdown-formatted documentation results. Each block has a title, URL and excerpt; "
+ "an empty result set returns guidance to navigate to https://posthog.com/docs."
+ )
+ )
+
+
+class _DocsSearchUnavailable(APIException):
+ status_code = status.HTTP_503_SERVICE_UNAVAILABLE
+ default_detail = "Documentation search is not available: INKEEP_API_KEY is not configured."
+ default_code = "docs_search_unavailable"
+
+
class MCPToolsViewSet(TeamAndOrgViewSetMixin, GenericViewSet):
scope_object = "project"
serializer_class = _FallbackSerializer
@@ -39,6 +70,43 @@ class MCPToolsViewSet(TeamAndOrgViewSetMixin, GenericViewSet):
return scopes or None
return None
+ @validated_request(
+ request_serializer=DocsSearchRequestSerializer,
+ responses={
+ 200: OpenApiResponse(
+ response=DocsSearchResponseSerializer,
+ description="Markdown-formatted documentation results.",
+ ),
+ },
+ summary="Search PostHog documentation",
+ description=(
+ "Run a hybrid (semantic + full-text) RAG search over the PostHog documentation via "
+ "Inkeep. Returns a markdown body with title, URL, and excerpt for each match for the "
+ "agent to cite back to the user."
+ ),
+ operation_id="docs_search",
+ tags=["docs"],
+ )
+ @action(detail=False, methods=["POST"], url_path="docs_search", required_scopes=["project:read"])
+ def docs_search(self, request: ValidatedRequest, *args, **kwargs) -> Response:
+ if not settings.INKEEP_API_KEY:
+ raise _DocsSearchUnavailable()
+
+ query = cast(dict, request.validated_data)["query"]
+ client = AsyncOpenAI(base_url="https://api.inkeep.com/v1/", api_key=settings.INKEEP_API_KEY)
+
+ try:
+ content = async_to_sync(_run_inkeep_docs_search)(client, query)
+ except Exception as e:
+ logger.exception("Error running docs_search", extra={"error": str(e)})
+ capture_exception(e, properties={"tag": "mcp", "tool_name": "docs_search"})
+ return Response(
+ {"content": "The tool raised an internal error. Do not immediately retry the tool call."},
+ status=status.HTTP_500_INTERNAL_SERVER_ERROR,
+ )
+
+ return Response(DocsSearchResponseSerializer({"content": content}).data)
+
@extend_schema(
parameters=[OpenApiParameter("tool_name", OpenApiTypes.STR, OpenApiParameter.PATH)],
responses={200: OpenApiTypes.OBJECT},
@@ -102,3 +170,13 @@ class MCPToolsViewSet(TeamAndOrgViewSetMixin, GenericViewSet):
)
return Response({"success": True, "content": content})
+
+
+async def _run_inkeep_docs_search(client: AsyncOpenAI, query: str) -> str:
+ response = await client.chat.completions.create(
+ model="inkeep-rag",
+ messages=[{"role": "user", "content": query}],
+ )
+ raw = response.choices[0].message.content if response.choices else None
+ payload = json.loads(raw) if raw else None
+ return format_inkeep_docs_response(payload, include_system_reminder=False)
diff --git a/products/posthog_ai/backend/api/test_mcp_tools.py b/products/posthog_ai/backend/api/test_mcp_tools.py
index 4f8ac746344f..047b43210c0b 100644
--- a/products/posthog_ai/backend/api/test_mcp_tools.py
+++ b/products/posthog_ai/backend/api/test_mcp_tools.py
@@ -98,3 +98,55 @@ class TestMCPToolsAPI(APIBaseTest):
data = response.json()
self.assertFalse(data["success"])
self.assertIn("internal error", data["content"].lower())
+
+
+class TestDocsSearchAction(APIBaseTest):
+ URL: str
+
+ def setUp(self):
+ super().setUp()
+ self.URL = f"/api/environments/{self.team.id}/mcp_tools/docs_search/"
+
+ def test_unauthenticated_request(self):
+ self.client.logout()
+ response = self.client.post(self.URL, {"query": "feature flags"}, format="json")
+ self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
+
+ def test_missing_query_field_returns_validation_error(self):
+ response = self.client.post(self.URL, {}, format="json")
+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
+
+ @patch("products.posthog_ai.backend.api.mcp_tools._run_inkeep_docs_search", new_callable=AsyncMock)
+ def test_docs_search_returns_formatted_content(self, mock_run):
+ from django.test import override_settings
+
+ mock_run.return_value = "Found 1 relevant documentation page(s):\n\n# Feature Flags\nURL: …\n\nDocs."
+
+ with override_settings(INKEEP_API_KEY="test-key"):
+ response = self.client.post(self.URL, {"query": "feature flags"}, format="json")
+
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ body = response.json()
+ self.assertIn("Feature Flags", body["content"])
+ self.assertNotIn("<system_reminder>", body["content"])
+ mock_run.assert_called_once()
+
+ def test_docs_search_unavailable_when_key_missing(self):
+ from django.test import override_settings
+
+ with override_settings(INKEEP_API_KEY=""):
+ response = self.client.post(self.URL, {"query": "feature flags"}, format="json")
+
+ self.assertEqual(response.status_code, status.HTTP_503_SERVICE_UNAVAILABLE)
+
+ @patch("products.posthog_ai.backend.api.mcp_tools._run_inkeep_docs_search", new_callable=AsyncMock)
+ def test_docs_search_unexpected_error_returns_500(self, mock_run):
+ from django.test import override_settings
+
+ mock_run.side_effect = RuntimeError("boom")
+
+ with override_settings(INKEEP_API_KEY="test-key"):
+ response = self.client.post(self.URL, {"query": "feature flags"}, format="json")
+
+ self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
+ self.assertIn("internal error", response.json()["content"].lower())
diff --git a/products/posthog_ai/frontend/generated/api.schemas.ts b/products/posthog_ai/frontend/generated/api.schemas.ts
index fa49bf293b6b..63af694ab95d 100644
--- a/products/posthog_ai/frontend/generated/api.schemas.ts
+++ b/products/posthog_ai/frontend/generated/api.schemas.ts
@@ -7,4 +7,14 @@
* PostHog API - generated
* OpenAPI spec version: 1.0.0
*/
+export interface DocsSearchRequestApi {
+ /** Natural-language description of what to find in the PostHog documentation. Inkeep performs hybrid (semantic + full-text) RAG, so phrase the query the way a user would ask the question. */
+ query: string
+}
+
+export interface DocsSearchResponseApi {
+ /** Markdown-formatted documentation results. Each block has a title, URL and excerpt; an empty result set returns guidance to navigate to https://posthog.com/docs. */
+ content: string
+}
+
export type McpToolsCreate200 = { [key: string]: unknown }
diff --git a/products/posthog_ai/frontend/generated/api.ts b/products/posthog_ai/frontend/generated/api.ts
index cf49b7ee5bea..27eb94c87019 100644
--- a/products/posthog_ai/frontend/generated/api.ts
+++ b/products/posthog_ai/frontend/generated/api.ts
@@ -8,7 +8,7 @@ import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'
* PostHog API - generated
* OpenAPI spec version: 1.0.0
*/
-import type { McpToolsCreate200 } from './api.schemas'
+import type { DocsSearchRequestApi, DocsSearchResponseApi, McpToolsCreate200 } from './api.schemas'
/**
* Invoke an MCP tool by name.
@@ -32,3 +32,24 @@ export const mcpToolsCreate = async (
method: 'POST',
})
}
+
+/**
+ * Run a hybrid (semantic + full-text) RAG search over the PostHog documentation via Inkeep. Returns a markdown body with title, URL, and excerpt for each match for the agent to cite back to the user.
+ * @summary Search PostHog documentation
+ */
+export const getDocsSearchUrl = (projectId: string) => {
+ return `/api/environments/${projectId}/mcp_tools/docs_search/`
+}
+
+export const docsSearch = async (
+ projectId: string,
+ docsSearchRequestApi: DocsSearchRequestApi,
+ options?: RequestInit
+): Promise<DocsSearchResponseApi> => {
+ return apiMutator<DocsSearchResponseApi>(getDocsSearchUrl(projectId), {
+ ...options,
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(docsSearchRequestApi),
+ })
+}
diff --git a/products/posthog_ai/frontend/generated/api.zod.ts b/products/posthog_ai/frontend/generated/api.zod.ts
index e8a15d4e1b52..971cfc372160 100644
--- a/products/posthog_ai/frontend/generated/api.zod.ts
+++ b/products/posthog_ai/frontend/generated/api.zod.ts
@@ -7,3 +7,16 @@
* PostHog API - generated
* OpenAPI spec version: 1.0.0
*/
+import * as zod from 'zod'
+
+/**
+ * Run a hybrid (semantic + full-text) RAG search over the PostHog documentation via Inkeep. Returns a markdown body with title, URL, and excerpt for each match for the agent to cite back to the user.
+ * @summary Search PostHog documentation
+ */
+export const DocsSearchBody = /* @__PURE__ */ zod.object({
+ query: zod
+ .string()
+ .describe(
+ 'Natural-language description of what to find in the PostHog documentation. Inkeep performs hybrid (semantic + full-text) RAG, so phrase the query the way a user would ask the question.'
+ ),
+})
diff --git a/products/posthog_ai/mcp/tools.yaml b/products/posthog_ai/mcp/tools.yaml
new file mode 100644
index 000000000000..26a66feedec6
--- /dev/null
+++ b/products/posthog_ai/mcp/tools.yaml
@@ -0,0 +1,17 @@
+# 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: PostHog AI
+feature: posthog_ai
+url_prefix: /
+ui_apps: {}
+tools:
+ docs-search:
+ operation: docs_search
+ enabled: false
+ mcp-tools-create:
+ operation: mcp_tools_create
+ enabled: false
diff --git a/services/mcp/.dev.vars.example b/services/mcp/.dev.vars.example
index 067ce546d420..65540076a0b8 100644
--- a/services/mcp/.dev.vars.example
+++ b/services/mcp/.dev.vars.example
@@ -10,8 +10,6 @@ MCP_APPS_BASE_URL=http://localhost:8787
POSTHOG_MCP_APPS_ANALYTICS_BASE_URL=http://localhost:8010
POSTHOG_UI_APPS_TOKEN=your_posthog_ui_apps_token_here
-INKEEP_API_KEY=your_inkeep_api_key_here
-
# MCPCat project ID for analytics (optional, disables MCPCat if not set)
MCP_CAT_PROJECT_ID=
diff --git a/services/mcp/definitions/docs.yaml b/services/mcp/definitions/docs.yaml
new file mode 100644
index 000000000000..d983b2bf65b8
--- /dev/null
+++ b/services/mcp/definitions/docs.yaml
@@ -0,0 +1,22 @@
+# 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: Docs
+feature: docs
+url_prefix: /
+ui_apps: {}
+tools:
+ docs-search:
+ operation: docs_search
+ enabled: true
+ scopes:
+ - project:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ title: Search documentation
+ description_file: ./prompts/docs-search.md
diff --git a/services/mcp/definitions/prompts/docs-search.md b/services/mcp/definitions/prompts/docs-search.md
new file mode 100644
index 000000000000..8ec27670c938
--- /dev/null
+++ b/services/mcp/definitions/prompts/docs-search.md
@@ -0,0 +1,20 @@
+Use this tool for any PostHog questions to search the documentation. If the user's question mentions multiple topics, search for each topic separately and combine the results. It relies on a hybrid (semantic + full-text) search, so phrase your query in natural language. Our product and docs change often, so this tool is required for accurate answers:
+
+- How to use PostHog
+- How to use PostHog features
+- How to contact support or other humans
+- How to report bugs
+- How to submit feature requests
+- To troubleshoot something
+- What default fields and properties are available for events and persons
+- …Or anything else PostHog-related
+
+For troubleshooting, ask the user to provide the error messages they are encountering. If no error message is involved, ask the user to describe their expected results vs. the actual results they're seeing. You avoid suggesting things that the user has told you they've already tried.
+
+Important:
+
+1. Don't rely on your training data or previous searches/answers. Always re-check facts against current docs and tutorials. If current docs or tutorials contradict core memory on product facts, prefer the docs result.
+2. Always search PostHog docs/tutorials and prioritize results from posthog.com over training data.
+3. Always include at least one relevant docs/tutorial link in your reply.
+4. Never suggest emailing [email protected] or say you'll create a support ticket.
+5. Never use Community Questions as a source or cite them; they're often outdated or incorrect.
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index b837abd5eeaa..209b357c6312 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -854,6 +854,21 @@
"readOnlyHint": false
}
},
+ "docs-search": {
+ "description": "Use this tool for any PostHog questions to search the documentation. If the user's question mentions multiple topics, search for each topic separately and combine the results. It relies on a hybrid (semantic + full-text) search, so phrase your query in natural language. Our product and docs change often, so this tool is required for accurate answers:\n\n- How to use PostHog\n- How to use PostHog features\n- How to contact support or other humans\n- How to report bugs\n- How to submit feature requests\n- To troubleshoot something\n- What default fields and properties are available for events and persons\n- …Or anything else PostHog-related\n\nFor troubleshooting, ask the user to provide the error messages they are encountering. If no error message is involved, ask the user to describe their expected results vs. the actual results they're seeing. You avoid suggesting things that the user has told you they've already tried.\n\nImportant:\n\n1. Don't rely on your training data or previous searches/answers. Always re-check facts against current docs and tutorials. If current docs or tutorials contradict core memory on product facts, prefer the docs result.\n2. Always search PostHog docs/tutorials and prioritize results from posthog.com over training data.\n3. Always include at least one relevant docs/tutorial link in your reply.\n4. Never suggest emailing [email protected] or say you'll create a support ticket.\n5. Never use Community Questions as a source or cite them; they're often outdated or incorrect.",
+ "category": "Docs",
+ "feature": "docs",
+ "summary": "Search documentation",
+ "title": "Search documentation",
+ "required_scopes": ["project:read"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ }
+ },
"early-access-feature-create": {
"description": "Create a new early access feature. A feature flag is automatically created unless feature_flag_id is provided. Stage determines whether opted-in users get the feature enabled.",
"category": "Early access features",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 2d4971b57afb..41e9b7ddfc5e 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -869,12 +869,12 @@
}
},
"docs-search": {
- "description": "Use this tool to search the PostHog documentation for information that can help the user with their request. Use it as a fallback when you cannot answer the user's request using other tools in this MCP. Only use this tool for PostHog related questions.",
- "category": "Documentation",
+ "description": "Use this tool for any PostHog questions to search the documentation. If the user's question mentions multiple topics, search for each topic separately and combine the results. It relies on a hybrid (semantic + full-text) search, so phrase your query in natural language. Our product and docs change often, so this tool is required for accurate answers:\n\n- How to use PostHog\n- How to use PostHog features\n- How to contact support or other humans\n- How to report bugs\n- How to submit feature requests\n- To troubleshoot something\n- What default fields and properties are available for events and persons\n- …Or anything else PostHog-related\n\nFor troubleshooting, ask the user to provide the error messages they are encountering. If no error message is involved, ask the user to describe their expected results vs. the actual results they're seeing. You avoid suggesting things that the user has told you they've already tried.\n\nImportant:\n\n1. Don't rely on your training data or previous searches/answers. Always re-check facts against current docs and tutorials. If current docs or tutorials contradict core memory on product facts, prefer the docs result.\n2. Always search PostHog docs/tutorials and prioritize results from posthog.com over training data.\n3. Always include at least one relevant docs/tutorial link in your reply.\n4. Never suggest emailing [email protected] or say you'll create a support ticket.\n5. Never use Community Questions as a source or cite them; they're often outdated or incorrect.",
+ "category": "Docs",
"feature": "docs",
- "summary": "Search the PostHog documentation for information.",
- "title": "Search docs",
- "required_scopes": [],
+ "summary": "Search documentation",
+ "title": "Search documentation",
+ "required_scopes": ["project:read"],
"new_mcp": true,
"annotations": {
"destructiveHint": false,
diff --git a/services/mcp/schema/tool-definitions.json b/services/mcp/schema/tool-definitions.json
index f77d4c075ff8..c9167b3971c0 100644
--- a/services/mcp/schema/tool-definitions.json
+++ b/services/mcp/schema/tool-definitions.json
@@ -1,19 +1,4 @@
{
- "docs-search": {
- "description": "Use this tool to search the PostHog documentation for information that can help the user with their request. Use it as a fallback when you cannot answer the user's request using other tools in this MCP. Only use this tool for PostHog related questions.",
- "category": "Documentation",
- "feature": "docs",
- "summary": "Search the PostHog documentation for information.",
- "title": "Search docs",
- "required_scopes": [],
- "new_mcp": true,
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- }
- },
"experiment-results-get": {
"description": "Get comprehensive experiment results including all metrics data (primary and secondary) and exposure data. This tool fetches the experiment details and executes the necessary queries to get complete experiment results. Only works with new experiments (not legacy experiments).",
"category": "Experiments",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index a5b692ff53f9..b8dff73a19a1 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -14244,6 +14244,16 @@ export namespace Schemas {
CosineDistance: 'cosineDistance',
} as const;
+ export interface DocsSearchRequest {
+ /** Natural-language description of what to find in the PostHog documentation. Inkeep performs hybrid (semantic + full-text) RAG, so phrase the query the way a user would ask the question. */
+ query: string;
+ }
+
+ export interface DocsSearchResponse {
+ /** Markdown-formatted documentation results. Each block has a title, URL and excerpt; an empty result set returns guidance to navigate to https://posthog.com/docs. */
+ content: string;
+ }
+
export type DocumentSimilarityQueryKind = typeof DocumentSimilarityQueryKind[keyof typeof DocumentSimilarityQueryKind];
diff --git a/services/mcp/src/generated/docs/api.ts b/services/mcp/src/generated/docs/api.ts
new file mode 100644
index 000000000000..df4e74113470
--- /dev/null
+++ b/services/mcp/src/generated/docs/api.ts
@@ -0,0 +1,29 @@
+/**
+ * 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 1 enabled ops
+ * OpenAPI spec version: 1.0.0
+ */
+import * as zod from 'zod'
+
+/**
+ * Run a hybrid (semantic + full-text) RAG search over the PostHog documentation via Inkeep. Returns a markdown body with title, URL, and excerpt for each match for the agent to cite back to the user.
+ * @summary Search PostHog documentation
+ */
+export const DocsSearchParams = /* @__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 DocsSearchBody = /* @__PURE__ */ zod.object({
+ query: zod
+ .string()
+ .describe(
+ 'Natural-language description of what to find in the PostHog documentation. Inkeep performs hybrid (semantic + full-text) RAG, so phrase the query the way a user would ask the question.'
+ ),
+})
diff --git a/services/mcp/src/tools/documentation/inkeepApi.ts b/services/mcp/src/tools/documentation/inkeepApi.ts
deleted file mode 100644
index f44ef2f8be29..000000000000
--- a/services/mcp/src/tools/documentation/inkeepApi.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-export interface InkeepResponse {
- choices: Array<{
- message: {
- content: string
- }
- }>
-}
-
-export async function docsSearch(apiKey: string, userQuery: string): Promise<string> {
- if (!apiKey) {
- throw new Error('No API key provided')
- }
-
- const response = await fetch('https://api.inkeep.com/v1/chat/completions', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Authorization: `Bearer ${apiKey}`,
- },
- body: JSON.stringify({
- model: 'inkeep-context-gpt-4o',
- messages: [{ role: 'user', content: userQuery }],
- }),
- })
-
- if (!response.ok) {
- const errorText = await response.text()
- console.error('Inkeep API error:', errorText)
- throw new Error(`Error querying Inkeep API: ${response.status} ${errorText}`)
- }
-
- const data = (await response.json()) as InkeepResponse
-
- if (data.choices && data.choices.length > 0 && data.choices[0]?.message && data.choices[0].message.content) {
- return data.choices[0].message.content
- }
- console.error('Inkeep API response format unexpected:', data)
- throw new Error('Unexpected response format from Inkeep API.')
-}
diff --git a/services/mcp/src/tools/documentation/searchDocs.ts b/services/mcp/src/tools/documentation/searchDocs.ts
deleted file mode 100644
index 15511324ee55..000000000000
--- a/services/mcp/src/tools/documentation/searchDocs.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import type { z } from 'zod'
-
-import { DocumentationSearchSchema } from '@/schema/tool-inputs'
-import type { Context, ToolBase } from '@/tools/types'
-
-import { docsSearch } from './inkeepApi'
-
-const schema = DocumentationSearchSchema
-
-type Params = z.infer<typeof schema>
-
-type Result = { content: Array<{ type: string; text: string }> }
-
-export const searchDocsHandler: ToolBase<typeof schema, Result>['handler'] = async (
- context: Context,
- params: Params
-) => {
- const { query } = params
- const inkeepApiKey = context.env.INKEEP_API_KEY
-
- if (!inkeepApiKey) {
- return {
- content: [
- {
- type: 'text',
- text: 'Error: INKEEP_API_KEY is not configured.',
- },
- ],
- }
- }
- const resultText = await docsSearch(inkeepApiKey, query)
- return { content: [{ type: 'text', text: resultText }] }
-}
-
-const tool = (): ToolBase<typeof schema, Result> => ({
- name: 'docs-search',
- schema,
- handler: searchDocsHandler,
-})
-
-export default tool
diff --git a/services/mcp/src/tools/generated/docs.ts b/services/mcp/src/tools/generated/docs.ts
new file mode 100644
index 000000000000..8be80a411d76
--- /dev/null
+++ b/services/mcp/src/tools/generated/docs.ts
@@ -0,0 +1,30 @@
+// AUTO-GENERATED from services/mcp/definitions/docs.yaml + OpenAPI — do not edit
+import { z } from 'zod'
+
+import type { Schemas } from '@/api/generated'
+import { DocsSearchBody } from '@/generated/docs/api'
+import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'
+
+const DocsSearchSchema = DocsSearchBody
+
+const docsSearch = (): ToolBase<typeof DocsSearchSchema, Schemas.DocsSearchResponse> => ({
+ name: 'docs-search',
+ schema: DocsSearchSchema,
+ handler: async (context: Context, params: z.infer<typeof DocsSearchSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.query !== undefined) {
+ body['query'] = params.query
+ }
+ const result = await context.api.request<Schemas.DocsSearchResponse>({
+ method: 'POST',
+ path: `/api/environments/${encodeURIComponent(String(projectId))}/mcp_tools/docs_search/`,
+ body,
+ })
+ return result
+ },
+})
+
+export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
+ 'docs-search': docsSearch,
+}
diff --git a/services/mcp/src/tools/generated/index.ts b/services/mcp/src/tools/generated/index.ts
index 78b102a75bd1..b6da08981d20 100644
--- a/services/mcp/src/tools/generated/index.ts
+++ b/services/mcp/src/tools/generated/index.ts
@@ -12,6 +12,7 @@ import { GENERATED_TOOLS as core } from './core'
import { GENERATED_TOOLS as customer_analytics } from './customer_analytics'
import { GENERATED_TOOLS as dashboards } from './dashboards'
import { GENERATED_TOOLS as data_warehouse } from './data_warehouse'
+import { GENERATED_TOOLS as docs } from './docs'
import { GENERATED_TOOLS as early_access_features } from './early_access_features'
import { GENERATED_TOOLS as endpoints } from './endpoints'
import { GENERATED_TOOLS as error_tracking } from './error_tracking'
@@ -46,6 +47,7 @@ export const GENERATED_TOOL_MAP: Record<string, () => ToolBase<ZodObjectAny>> =
...customer_analytics,
...dashboards,
...data_warehouse,
+ ...docs,
...early_access_features,
...endpoints,
...error_tracking,
diff --git a/services/mcp/src/tools/index.ts b/services/mcp/src/tools/index.ts
index acd3b06aeb99..55d2d5b66f34 100644
--- a/services/mcp/src/tools/index.ts
+++ b/services/mcp/src/tools/index.ts
@@ -2,8 +2,6 @@ import { hasScopes } from '@/lib/api'
// Debug
import debugMcpUiApps from './debug/debugMcpUiApps'
-// Documentation
-import searchDocs from './documentation/searchDocs'
// Experiments (hand-written — CRUD + lifecycle are codegen in generated/experiments.ts)
import getExperimentResults from './experiments/getResults'
import experimentListDeprecated from './experiments/listDeprecated'
@@ -57,9 +55,6 @@ export const TOOL_MAP: Record<string, () => ToolBase<ZodObjectAny>> = {
'event-definition-update': updateEventDefinition,
'properties-list': getProperties,
- // Documentation - handled separately due to env check
- // "docs-search": searchDocs,
-
// Experiments (results is hand-written; CRUD + lifecycle are codegen)
'experiment-results-get': getExperimentResults,
// Deprecated alias for experiment-list — forwards and annotates the response.
@@ -107,14 +102,9 @@ export const getToolsFromContext = async (
const toolBases: ToolBase<ZodObjectAny>[] = []
for (const toolName of allowedToolNames) {
- // Special handling for docs-search which requires API key
- if (toolName === 'docs-search' && context.env.INKEEP_API_KEY) {
- toolBases.push(searchDocs())
- } else {
- const toolFactory = effectiveMap[toolName]
- if (toolFactory) {
- toolBases.push(toolFactory())
- }
+ const toolFactory = effectiveMap[toolName]
+ if (toolFactory) {
+ toolBases.push(toolFactory())
}
}
diff --git a/services/mcp/src/tools/types.ts b/services/mcp/src/tools/types.ts
index 72a25f4d9264..72a9f832d8fb 100644
--- a/services/mcp/src/tools/types.ts
+++ b/services/mcp/src/tools/types.ts
@@ -36,11 +36,6 @@ export type State = {
Record<PrefixedString<'cachedProjectFetchedAt'>, number | undefined>
export type Env = {
- /**
- * Inkeep API key for the PostHog Agent Toolkit.
- * Setting this enables the 'docs-search' tool.
- */
- INKEEP_API_KEY: string | undefined
/**
* Custom API base URL for self-hosted PostHog instances.
*
diff --git a/services/mcp/tests/integration/feature-routing.test.ts b/services/mcp/tests/integration/feature-routing.test.ts
index a4a23155ffe8..fb9ad73deccd 100644
--- a/services/mcp/tests/integration/feature-routing.test.ts
+++ b/services/mcp/tests/integration/feature-routing.test.ts
@@ -8,7 +8,6 @@ const createMockContext = (): Context => ({
api: {} as any,
cache: {} as any,
env: {
- INKEEP_API_KEY: undefined,
MCP_APPS_BASE_URL: undefined,
POSTHOG_ANALYTICS_API_KEY: undefined,
POSTHOG_ANALYTICS_HOST: undefined,
diff --git a/services/mcp/tests/setup.ts b/services/mcp/tests/setup.ts
index 1aa07ae93902..5a5329a51834 100644
--- a/services/mcp/tests/setup.ts
+++ b/services/mcp/tests/setup.ts
@@ -13,7 +13,6 @@ vi.mock('mcpcat', () => ({
// Mock cloudflare:workers module for Node.js test environment
vi.mock('cloudflare:workers', () => ({
env: {
- INKEEP_API_KEY: undefined,
MCP_CAT_PROJECT_ID: undefined,
POSTHOG_ANALYTICS_API_KEY: undefined,
POSTHOG_ANALYTICS_HOST: undefined,
diff --git a/services/mcp/tests/tools/documentation.integration.test.ts b/services/mcp/tests/tools/documentation.integration.test.ts
index 30e9fd00a051..530a3ec9e463 100644
--- a/services/mcp/tests/tools/documentation.integration.test.ts
+++ b/services/mcp/tests/tools/documentation.integration.test.ts
@@ -10,7 +10,7 @@ import {
setActiveProjectAndOrg,
validateEnvironmentVariables,
} from '@/shared/test-utils'
-import searchDocsTool from '@/tools/documentation/searchDocs'
+import { GENERATED_TOOL_MAP } from '@/tools/generated'
import type { Context } from '@/tools/types'
describe('Documentation', { concurrent: false }, () => {
@@ -35,62 +35,39 @@ describe('Documentation', { concurrent: false }, () => {
await cleanupResources(context.api, TEST_PROJECT_ID!, createdResources)
})
- describe('search-docs tool', () => {
- const searchTool = searchDocsTool()
-
- it('should handle missing INKEEP_API_KEY', async () => {
- const contextWithoutKey = {
- ...context,
- env: { ...context.env, INKEEP_API_KEY: undefined as any },
- }
-
- const result = await searchTool.handler(contextWithoutKey as Context, {
- query: 'feature flags',
- })
-
- expect(result.content[0]!.text).toBe('Error: INKEEP_API_KEY is not configured.')
- })
+ describe('docs-search tool', () => {
+ const searchTool = GENERATED_TOOL_MAP['docs-search']!()
it.skip('should search documentation with valid query', async () => {
- const result = await searchTool.handler(context, {
- query: 'feature flags',
- })
+ const result = (await searchTool.handler(context, { query: 'feature flags' })) as { content: string }
- expect(result.content[0]!.type).toBe('text')
- expect(result.content[0]!.text).toBeTruthy()
- expect(result.content[0]!.text.length).toBeGreaterThan(0)
+ expect(typeof result.content).toBe('string')
+ expect(result.content.length).toBeGreaterThan(0)
})
it.skip('should search for analytics documentation', async () => {
- const result = await searchTool.handler(context, {
- query: 'analytics events tracking',
- })
+ const result = (await searchTool.handler(context, { query: 'analytics events tracking' })) as {
+ content: string
+ }
- expect(result.content[0]!.type).toBe('text')
- expect(result.content[0]!.text).toBeTruthy()
- expect(result.content[0]!.text.length).toBeGreaterThan(0)
+ expect(typeof result.content).toBe('string')
+ expect(result.content.length).toBeGreaterThan(0)
})
it.skip('should handle empty query results', async () => {
- const result = await searchTool.handler(context, {
+ const result = (await searchTool.handler(context, {
query: 'zxcvbnmasdfghjklqwertyuiop123456789',
- })
+ })) as { content: string }
- expect(result.content[0]!.type).toBe('text')
- expect(result.content[0]!.text).toBeTruthy()
+ expect(typeof result.content).toBe('string')
})
})
describe('Documentation search workflow', () => {
it('should validate query parameter is required', async () => {
- const searchTool = searchDocsTool()
+ const searchTool = GENERATED_TOOL_MAP['docs-search']!()
- try {
- await searchTool.handler(context, { query: '' })
- expect.fail('Should have thrown validation error')
- } catch (error) {
- expect(error).toBeTruthy()
- }
+ await expect(searchTool.handler(context, {} as { query: string })).rejects.toBeTruthy()
})
})
})
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/docs-search.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/docs-search.json
index fe549a431534..8846c0e277a6 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/docs-search.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/docs-search.json
@@ -2,6 +2,7 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"query": {
+ "description": "Natural-language description of what to find in the PostHog documentation. Inkeep performs hybrid (semantic + full-text) RAG, so phrase the query the way a user would ask the question.",
"type": "string"
}
},
diff --git a/services/mcp/tests/unit/exec.test.ts b/services/mcp/tests/unit/exec.test.ts
index d78db1233aae..3f2d5c00728c 100644
--- a/services/mcp/tests/unit/exec.test.ts
+++ b/services/mcp/tests/unit/exec.test.ts
@@ -227,7 +227,6 @@ describe('exec tool', () => {
api: {} as any,
cache: {} as any,
env: {
- INKEEP_API_KEY: 'test-key',
MCP_APPS_BASE_URL: undefined,
POSTHOG_ANALYTICS_API_KEY: undefined,
POSTHOG_ANALYTICS_HOST: undefined,
diff --git a/services/mcp/tests/unit/tool-filtering.test.ts b/services/mcp/tests/unit/tool-filtering.test.ts
index 6cc6ec547c47..e0efa0be920f 100644
--- a/services/mcp/tests/unit/tool-filtering.test.ts
+++ b/services/mcp/tests/unit/tool-filtering.test.ts
@@ -194,7 +194,6 @@ const createMockContext = (scopes: string[]): Context => ({
api: {} as any,
cache: {} as any,
env: {
- INKEEP_API_KEY: undefined,
MCP_APPS_BASE_URL: undefined,
POSTHOG_ANALYTICS_API_KEY: undefined,
POSTHOG_ANALYTICS_HOST: undefined,
@@ -407,7 +406,6 @@ describe('Tool Filtering - AI Consent', () => {
api: {} as any,
cache: {} as any,
env: {
- INKEEP_API_KEY: undefined,
MCP_APPS_BASE_URL: undefined,
POSTHOG_ANALYTICS_API_KEY: undefined,
POSTHOG_ANALYTICS_HOST: undefined,
@@ -433,7 +431,6 @@ describe('Tool Filtering - AI Consent', () => {
api: {} as any,
cache: {} as any,
env: {
- INKEEP_API_KEY: undefined,
MCP_APPS_BASE_URL: undefined,
POSTHOG_ANALYTICS_API_KEY: undefined,
POSTHOG_ANALYTICS_HOST: undefined,
diff --git a/services/mcp/tests/unit/tool-schema-snapshots.test.ts b/services/mcp/tests/unit/tool-schema-snapshots.test.ts
index b2b8cb825e59..bc9370569ae9 100644
--- a/services/mcp/tests/unit/tool-schema-snapshots.test.ts
+++ b/services/mcp/tests/unit/tool-schema-snapshots.test.ts
@@ -14,7 +14,6 @@ function createMockContext(): Context {
api: {} as any,
cache: {} as any,
env: {
- INKEEP_API_KEY: 'test-key',
MCP_APPS_BASE_URL: undefined,
POSTHOG_ANALYTICS_API_KEY: undefined,
POSTHOG_ANALYTICS_HOST: undefined,
diff --git a/services/mcp/tests/unit/ui-apps.test.ts b/services/mcp/tests/unit/ui-apps.test.ts
index 35dc33ce3cf1..c5498ad30531 100644
--- a/services/mcp/tests/unit/ui-apps.test.ts
+++ b/services/mcp/tests/unit/ui-apps.test.ts
@@ -71,7 +71,6 @@ describe('ui-apps', () => {
MCP_APPS_BASE_URL: undefined,
POSTHOG_MCP_APPS_ANALYTICS_BASE_URL: undefined,
POSTHOG_UI_APPS_TOKEN: undefined,
- INKEEP_API_KEY: undefined,
POSTHOG_API_BASE_URL: undefined,
POSTHOG_ANALYTICS_API_KEY: undefined,
POSTHOG_ANALYTICS_HOST: undefined,
diff --git a/services/mcp/vitest.workers.config.mts b/services/mcp/vitest.workers.config.mts
index 12e6ddc3727b..a562f026754d 100644
--- a/services/mcp/vitest.workers.config.mts
+++ b/services/mcp/vitest.workers.config.mts
@@ -35,7 +35,6 @@ export default defineWorkersProject({
POSTHOG_ANALYTICS_HOST: '',
POSTHOG_MCP_APPS_ANALYTICS_BASE_URL: '',
POSTHOG_UI_APPS_TOKEN: '',
- INKEEP_API_KEY: '',
MCP_CAT_PROJECT_ID: '',
// Generic test marker. Code can short-circuit features
// that need real network (e.g. context-mill GitHub
diff --git a/services/mcp/worker-configuration.d.ts b/services/mcp/worker-configuration.d.ts
index 59fde7c513c5..18ab9a55313a 100644
--- a/services/mcp/worker-configuration.d.ts
+++ b/services/mcp/worker-configuration.d.ts
@@ -8,7 +8,6 @@ declare namespace Cloudflare {
}
interface Env {
MCP_APPS_BASE_URL: "https://mcp.posthog.com";
- INKEEP_API_KEY: string;
POSTHOG_API_BASE_URL: string;
POSTHOG_MCP_APPS_ANALYTICS_BASE_URL: string;
POSTHOG_UI_APPS_TOKEN: string;