feat(code): rich formatting for posthog mcp exec tool calls#1992
Open
feat(code): rich formatting for posthog mcp exec tool calls#1992
Conversation
Contributor
Prompt To Fix All With AIFix 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The PostHog MCP exposes a single
execdispatcher whosecommandparameter carries the actual action:tools,search <regex>,info <tool>,schema <tool> [path], orcall <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.Changes
McpToolViewnow branches on PostHogexectools and renders a per-verb display. Labels were chosen to match what each verb actually does (e.g.toolsreturns names only — "List", not "Read all";schemais the drill-down verb — "Inspect", not generic "Read"):toolsposthog - List tools (MCP)search query-posthog - Search tools (MCP) query-info execute-sqlposthog - Read execute-sql (MCP)info(bare)posthog - Read tool (MCP)schema query-trendsposthog - Inspect query-trends fields (MCP)schema query-trends seriesposthog - Inspect query-trends.series (MCP)schema query-trends breakdownFilter.breakdownsposthog - Inspect query-trends.breakdownFilter.breakdowns (MCP)call execute-sql {…}posthog - execute-sql (MCP) {…}The
callverb is collapsed (it's the default action and pure dispatcher noise); other verbs stay in the label since they describe the action. Forschema, 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 toposthog. The expanded row still shows the full originalrawInputJSON.If the agent ever emits an explicit
inputfield on the tool call ({ command: "call execute-sql", input: { … } }), it wins over command-embedded args.How did you test this code?
apps/code/src/renderer/features/mcp-apps/utils/posthog-exec-display.test.tscovering all five verbs, plugin-prefixed tool names, explicitinputoverride, malformed inputs, and unknown verbs.info,call, andtoolsagainst 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