Skip to content

Add MCP tool callouts to API endpoint docs#16871

Draft
thmsobrmlr wants to merge 1 commit into
masterfrom
posthog-code/api-docs-mcp-callout
Draft

Add MCP tool callouts to API endpoint docs#16871
thmsobrmlr wants to merge 1 commit into
masterfrom
posthog-code/api-docs-mcp-callout

Conversation

@thmsobrmlr
Copy link
Copy Markdown
Contributor

Summary

  • Surfaces matching MCP tools on each REST API endpoint page so users discover the MCP equivalent without leaving the API reference.
  • Enriches the MCP tools fetcher to emit a flat byName map (summary, description, category, required_scopes) alongside the existing categories shape, and caches the full payload in onPreBootstrap.
  • Adds a seeded src/data/mcp-rest-mapping.json (137 entries — direct _- matches plus verb-swap CRUD entries for feature flags, dashboards, insights, cohorts, experiments, annotations, surveys) and a helper script to regenerate candidates as the upstream tool list / OpenAPI spec evolve.
  • Renders <MCPCallout operationId={...} /> inside ApiEndpoint.tsx right after each endpoint heading; returns null when no mapping exists so unmapped endpoints stay clean.

Test plan

  • pnpm clean && pnpm install && pnpm start
  • Visit /docs/api/feature-flags — each operation with a mapping entry should show a yellow-bordered callout above the description listing the matching MCP tool(s) with summaries and a link to /docs/model-context-protocol.
  • Visit an endpoint with no mapping (e.g. a niche operation) and confirm no callout appears.
  • Confirm pnpm build still completes without TypeScript errors.

Generated-By: PostHog Code
Task-Id: 5e7552fa-6b4b-4e3a-ba92-d71895b6f041

Surfaces matching MCP tools on each REST API endpoint page so users
discover the MCP equivalent without leaving the API reference.

- Enrich fetchMCPTools to emit a byName map (summary, description,
  category, required_scopes) alongside the existing categories shape.
- Cache the full MCP tools payload in onPreBootstrap so downstream
  consumers can read either shape.
- Seed src/data/mcp-rest-mapping.json with 137 operationId -> tool
  mappings (direct underscore-to-hyphen matches plus verb-swap CRUD
  entries for feature flags, dashboards, insights, cohorts,
  experiments, annotations, surveys).
- Add scripts/generate-mcp-rest-mapping-candidates.js to refresh
  candidates as the upstream tool list / OpenAPI spec evolve.
- Render <MCPCallout /> inside ApiEndpoint.tsx, returning null when
  there is no mapping so unmapped endpoints stay clean.

Generated-By: PostHog Code
Task-Id: 5e7552fa-6b4b-4e3a-ba92-d71895b6f041
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

Deploy preview

Status Details Updated (UTC)
🟢 Ready View preview May 18, 2026 06:37PM

@thmsobrmlr thmsobrmlr marked this pull request as draft May 18, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant