Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Server logs full JSON-RPC payloads, tool arguments included, at info level

已關閉
#524 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@aton-of-data 已經在處理了。

開始於 2026年10月2日。

  • #525 來自 @aton-of-data —— 未關閉

評估

難度
3/5
預估耗時
1-2 天
新手友好度
74/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
php

研究方向

Start in src/Server/Protocol.php and inspect the four info-level logging paths for received messages, requests, responses, and notifications. Compare them with CallToolHandler's debug logging and the Logger example in docs/run/server-builder.md. Done means info logs retain method/ID-level details without payloads, full payloads are available at debug, and the relevant logging tests pass.

由索引模型根據 Issue 內容生成。

描述

Server

Protocol passes every incoming message to the PSR-3 logger as context at info level:

// src/Server/Protocol.php (main @ 3175614b)
$this->logger->info('Received message to process.', ['message' => $input]);          // raw JSON input
$this->logger->info('Handling request.', ['request' => $request]);                   // whole request object
$this->logger->info('Handling response from client.', ['response' => $response]);    // sampling/elicitation replies
$this->logger->info('Handling notification.', ['notification' => $notification]);

For a tools/call, that's the tool arguments twice, at the level most production setups keep. A sampling or elicitation reply puts what the user typed in the log the same way.

The builder docs (docs/run/server-builder.md, "Logger") show:

$logger = new Logger('mcp-server');
$logger->pushHandler(new StreamHandler('mcp.log', Logger::INFO));

Monolog's default LineFormatter writes the full context with each record. So a server set up as documented stores every tool argument in mcp.log. Tool calls can carry content an application wouldn't otherwise log, such as personal data, document text, or credentials a user pastes into a prompt.

CallToolHandler already keeps payloads at debug (Executing tool with arguments, Tool executed successfully with structured_content). That seems like the right split, and Protocol doesn't follow it.

Proposal: at info, log the method and ID only, and move the full payload to debug. For example:

$this->logger->info('Handling request.', ['method' => $request::getMethod(), 'id' => $request->getId()]);
$this->logger->debug('Request payload.', ['request' => $request]);

"Received message to process." could drop the raw input at info entirely, since the per-message lines that follow already name the method.

Downstream, the Drupal integration filters payloads out of the context in its logger decorator, because its database log is readable by site administrators: https://git.drupalcode.org/project/mcp_server/-/work_items/3585937. Fixing the levels in the SDK would let every integration control this with a normal log level.

主要語言
PHP
星號
1.6k
分支
180
平均合併
2 天 3 小時
30 天內合併 PR
70

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

modelcontextprotocol/php-sdk 的其他 Issue

查看 modelcontextprotocol/php-sdk 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。