Add MCP Analytics support (PostHog\MCP helpers, plus a laravel/mcp integration)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 18/100
調査の方向性
This is a design proposal for a new PostHog\MCP namespace in the PHP SDK, not a scoped change. Start from the existing capture client in the package and the proposed MCP::captureToolCall signature, then decide the sessionId and redaction rules against the other SDKs. Done would need agreement from maintainers on the API surface and a first version covering only $mcp_tool_call.
索引モデルが issue の本文から書いたものです。
説明
Problem Statement
We run TryPost, an open-source social media scheduler built on Laravel. It exposes an MCP server with about 100 tools through the official laravel/mcp package, used daily from ChatGPT, Claude and Codex. We'd like to use MCP Analytics, but there is no PHP SDK for it: the install guide lists TypeScript, Python, Go, Ruby and Rust, and PHP only appears on the other languages page as "send the events yourself".
The product works the same whatever sends the events (it reads the event name and $mcp_source), so a manual capture('$mcp_tool_call', [...]) does work. What's missing is the part the other SDKs handle for you, and where mistakes are easy and silent:
- Building the
$mcp_*properties on every call ($mcp_source,$mcp_tool_name,$mcp_is_error,$mcp_error_type,$mcp_duration_ms,$mcp_server_name, client name and version, protocol version, …). A typo inposthog_mcp_analyticsmakes the calls invisible with no error. - Deriving
$session_idthe same way the other SDKs do (ses_+ the first 32 hex characters of a SHA-256), consistent across replicas. - Redacting and truncating
$mcp_parameters,$mcp_response,$mcp_intentand error messages with the same rules the other SDKs apply. An agent can paste a credential into a tool argument. - The
contextintent argument: adding it to each advertised tool schema and stripping it before the tool runs. - Sending
$process_person_profile: falsefor anonymous calls.
PHP is a big share of MCP servers today (Laravel ships laravel/mcp officially, and there's the official modelcontextprotocol/php-sdk for Symfony and plain PHP), so we probably aren't the only ones who read the install page and assumed the product isn't for them.
Solution Brainstorm
A PostHog\MCP namespace in this package (no new dependencies), with framework-agnostic per-call helpers, since PHP MCP servers don't share one server object to wrap. Roughly:
use PostHog\MCP;
// tools/list: optionally add the `context` intent argument (and get_more_tools)
$tools = MCP::prepareToolList($tools, context: true, reportMissing: false);
// tools/call: strip the injected argument before the tool runs
$prepared = MCP::prepareToolCall($name, $arguments);
MCP::captureToolCall(
distinctId: $userId,
tool: $name,
durationMs: $durationMs,
isError: $isError,
errorType: 'validation',
sessionId: MCP::sessionId($transportSessionId),
intent: $prepared->intent,
client: ['name' => 'claude-ai', 'version' => '1.0', 'user_agent' => $ua],
server: ['name' => 'TryPost', 'version' => '1.0.0'],
parameters: null, // opt-in, sanitised like the other SDKs
groups: ['account' => $accountId],
);
Then, as follow-ups:
- A
laravel/mcpintegration inposthog/posthog-laravel(aCallToolmethod subclass or a middleware), so a Laravel server opts in with one line of config.laravel/mcplets a server replace itstools/callhandler ($this->addMethod('tools/call', ...)), which is the natural hook. - A session strategy for stateless servers.
laravel/mcpruns over stateless HTTP with noMcp-Session-Id, which is the gap described in PostHog/posthog#119784. A helper that groups calls by an inactivity window keyed ondistinct_id+ client, without changing tool schemas or results, would cover it (the ChatGPT and Claude directories discourage telemetry ids in tool results).
A first version with $mcp_tool_call only would already unlock the dashboards, tool quality and sessions views; $mcp_tools_list, $mcp_initialize and $mcp_missing_capability could follow.
Related: PostHog/posthog-elixir#209 asks for the same helper in Elixir, and PostHog/posthog#119784 covers stateless sessions.
Happy to test a pre-release against our server.
- 主要言語
- PHP
- スター
- 32
- フォーク
- 36
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 44
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PostHog/posthog-php のほかの issue
-
Symfony SDK supportオープンenhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
PostHog/posthog-php#323 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement team/logs
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
PostHog/posthog-php#179 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
PostHog/posthog-php#172 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
PostHog/posthog-php#170 ·
メンテナーはふだん 1 日以内に返信
-
SDK referencesオープンdocumentation
難易度 2/5 1〜3時間 初心者へのやさしさ 55/100
PostHog/posthog-php#145 ·
メンテナーはふだん 1 日以内に返信
PostHog/posthog-php の issue をすべて見る
似ている issue
-
15.0
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
-
bug needs-triage
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
camunda/orchestration-cluster-api-php#162 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
TYPO3-Solr/ext-solr#4850 ·
メンテナーはふだん 2 日以内に返信
-
Hex viewer drops ASCII '0' after a complete row対応中かも @palashranka が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 3 日以内に返信