Skip to content

feat(code): rich formatting for posthog mcp exec tool calls#1992

Open
skoob13 wants to merge 2 commits intomainfrom
feat/posthog-exec-rich-display
Open

feat(code): rich formatting for posthog mcp exec tool calls#1992
skoob13 wants to merge 2 commits intomainfrom
feat/posthog-exec-rich-display

Conversation

@skoob13
Copy link
Copy Markdown
Contributor

@skoob13 skoob13 commented May 4, 2026

Problem

The PostHog MCP exposes a single exec dispatcher whose command parameter carries the actual action: tools, search <regex>, info <tool>, schema <tool> [path], or call <tool> <json>. Generic MCP rendering shows the verbose plumbing instead of the action — e.g. posthog - exec (MCP) {"command":"call execute-sql {…}"} — making conversation history hard to scan.

Screenshot 2026-05-04 at 13 23 48

Changes

McpToolView now branches on PostHog exec tools and renders a per-verb display. Labels were chosen to match what each verb actually does (e.g. tools returns names only — "List", not "Read all"; schema is the drill-down verb — "Inspect", not generic "Read"):

Command Renders as
tools posthog - List tools (MCP)
search query- posthog - Search tools (MCP) query-
info execute-sql posthog - Read execute-sql (MCP)
info (bare) posthog - Read tool (MCP)
schema query-trends posthog - Inspect query-trends fields (MCP)
schema query-trends series posthog - Inspect query-trends.series (MCP)
schema query-trends breakdownFilter.breakdowns posthog - Inspect query-trends.breakdownFilter.breakdowns (MCP)
call execute-sql {…} posthog - execute-sql (MCP) {…}

The call verb is collapsed (it's the default action and pure dispatcher noise); other verbs stay in the label since they describe the action. For schema, the field path is folded into a dotted locator (query-trends.series) instead of being split across two visual chunks. Plugin-namespaced tools (mcp__plugin_posthog_posthog__exec) match too and the server label is normalized back to posthog. The expanded row still shows the full original rawInput JSON.

If the agent ever emits an explicit input field on the tool call ({ command: "call execute-sql", input: { … } }), it wins over command-embedded args.

How did you test this code?

  • Added 22 unit tests in apps/code/src/renderer/features/mcp-apps/utils/posthog-exec-display.test.ts covering all five verbs, plugin-prefixed tool names, explicit input override, malformed inputs, and unknown verbs.
  • Manually exercised info, call, and tools against the live PostHog MCP in PostHog Code; confirmed the new labels render and unknown verbs fall back to the generic display.

Publish to changelog?

no

@skoob13 skoob13 requested a review from a team May 4, 2026 11:27
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 4, 2026

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/code/src/renderer/features/mcp-apps/utils/posthog-exec-display.test.ts:26-57
**Prefer parameterised tests**

The test groups for each verb use individual `it` blocks where `it.each` would eliminate the duplication. For example, the `call verb` describe could be:

```ts
it.each([
  ["collapses bare sub-tool", "call experiment-list", { label: "experiment-list", input: undefined }],
  ["uses JSON args as input", 'call execute-sql {"query":"SELECT 1"}', { label: "execute-sql", input: '{"query":"SELECT 1"}' }],
  ["handles --json flag", 'call --json experiment-update {"id":1}', { label: "experiment-update", input: '{"id":1}' }],
])("%s", (_desc, command, expected) => {
  expect(getPostHogExecDisplay({ command })).toEqual(expected);
});
```

The same pattern applies to `info`, `schema`, `search`, and the malformed/null cases. This pattern also applies to `isPostHogExecTool`, where the matching and rejection cases are separate `it` blocks with multiple assertions each.

Reviews (1): Last reviewed commit: "wip" | Re-trigger Greptile

- tools → "List tools" (was "Read all tools" — `tools` returns names, not full schemas)
- info <tool> → "Read <tool>" (was "Read <tool>"); bare info → "Read tool"
- schema <tool> [path] → "Inspect <tool> fields" / "Inspect <tool>.<path>"
  (folds path into a dotted locator so it reads as one path)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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