Skip to content

fix(worker): dedupe MCP SDK + fix agent.ts type errors, add CI tsc gate#239

Merged
liplus-lin-lay merged 1 commit into
mainfrom
238-fixworker-dedupe-mcp-sdk-+-fix-agentts-type-errors-add-tsc-gate-to-ci
Jun 25, 2026
Merged

fix(worker): dedupe MCP SDK + fix agent.ts type errors, add CI tsc gate#239
liplus-lin-lay merged 1 commit into
mainfrom
238-fixworker-dedupe-mcp-sdk-+-fix-agentts-type-errors-add-tsc-gate-to-ci

Conversation

@liplus-lin-lay

Copy link
Copy Markdown
Member

概要

worker の型チェック (tsc --noEmit) が CI で走っておらず, agent.ts に型エラー 2 件が静かに蓄積していた (PR #237 のセルフレビュー中に発見). 2 件を修正し, 再発防止に tsc 型ゲートを CI に追加する.

影響スコープ = worker (型/ビルド健全性のみ, runtime 挙動・MCP ツール意味論は不変).

変更内容

  • (1) MCP SDK の dedupe (TS2416 解消): @modelcontextprotocol/sdk が依存ツリーに 2 コピー (worker 直下 1.27.1 / agents@0.8.2 nested 1.26.0) 存在し, 別コピーのため McpServer の private フィールド _serverInfo が非互換になっていた. 版差ではなく「2 コピーある」こと自体が原因. worker/package.jsonoverrides@modelcontextprotocol/sdk を追加し, agents@0.8.2 が要求する 1.26.0 (より制約の強い consumer, 安全側) に単一版へ寄せた. 既存の @cloudflare/workers-types override と同じ self-reference 形式を踏襲.
  • (2) TenantProps の type 化 (TS2344 解消): TypeScript の interface は暗黙の index signature を持たず Record<string, unknown> 制約に不適合だったため, interface TenantPropstype TenantProps = に変更.
  • (3) CI 型ゲート追加: worker に typecheck script (tsc --noEmit) を追加し, .github/workflows/ci.yml の worker job で npm ci 直後に npm run typecheck を実行. 型エラーで CI が fail するゲートにした.

順序遵守

(1) dedupe + (2) type 化を先に適用し tsc --noEmit を完全クリア (エラーゼロ) にしてから (3) のゲートを有効化した. ゲートを先に入れると既存エラーで CI が赤くなるため.

検証

  • cd worker && npx tsc --noEmit → エラーゼロ (exit 0).
  • dedupe 確認: ディスク上の @modelcontextprotocol/sdk は単一コピー (1.26.0) のみ, nested コピーは消失. npm lsagents 側が 1.26.0 deduped 表示.
  • ゲート動作確認: 故意に型エラーを 1 件入れると npm run typecheck が exit 2 (CI 赤), revert で exit 0 に復帰.
  • 全テスト green: tsx 54 件 + vitest (workers) 35 件, fail 0.
  • Workers build (wrangler deploy --dry-run) green.

対象ファイル

  • worker/package.json (overrides + typecheck script)
  • worker/package-lock.json (dedupe 反映)
  • worker/src/agent.ts
  • .github/workflows/ci.yml

Closes #238

… add tsc gate to CI

worker の tsc 型エラー 2 件を解消し, 再発防止に CI へ型ゲートを追加する (#238).

- agent.ts:31 TS2344: `interface TenantProps` を `type TenantProps =` に変更.
  interface は暗黙の index signature を持たず `Record<string, unknown>` 制約に不適合だったため.
- agent.ts:32 TS2416: `@modelcontextprotocol/sdk` が依存ツリーに 2 コピー (worker 直下
  1.27.1 / agents@0.8.2 nested 1.26.0) 存在し, 別コピーの McpServer private `_serverInfo`
  が非互換だった. worker/package.json の overrides に `@modelcontextprotocol/sdk` を追加し,
  agents が要求する 1.26.0 (より制約の強い consumer) に単一版へ寄せた. 既存の
  `@cloudflare/workers-types` override と同じ self-reference 形式を使う.
- 再発防止: worker に `typecheck` script (`tsc --noEmit`) を追加し, ci.yml の worker job で
  `npm ci` の直後に実行. 型エラーで CI が fail するゲートにした.

順序遵守: (1) dedupe + (2) type 化を先に適用し tsc を完全クリア (エラーゼロ) にしてから
(3) のゲートを有効化した. dedupe 後に nested コピーが消えたこと, 全テスト (tsx 54 + vitest 35)
+ Workers build (dry-run deploy) が green であることを確認済み. runtime 挙動は不変 (型/ビルド
健全性のみ).

Closes #238

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@liplus-lin-lay liplus-lin-lay self-assigned this Jun 25, 2026
@liplus-lin-lay liplus-lin-lay linked an issue Jun 25, 2026 that may be closed by this pull request
5 tasks

@liplus-lin-lay liplus-lin-lay left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liplus-lin-lay liplus-lin-lay left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI セルフレビュー (auto mode / 親)

差分確認、完了条件すべて達成。

  • dedupe (error 2): package.json overrides に @modelcontextprotocol/sdk: $ref 追加 + dep を 1.26.0 に固定。package-lock から nested agents/node_modules/@modelcontextprotocol/sdk が消え単一コピー化を確認。agents@0.8.2 要求版 (1.26.0) に合わせる安全側。
  • type 化 (error 1): interface TenantProps -> type TenantProps。
  • CI 型ゲート: worker に typecheck script 追加、ci.yml で npm ci の後・dry-run deploy の前に npm run typecheck を実行。run 28189413249 step 6 で実走 success = ゲート稼働 + tsc クリアを確認。
  • 順序: 既存 2 エラー解消 -> ゲート追加が同一 PR で成立、CI green が tsc ゼロを証明。
  • Workers Builds は本 PR 未付与 (型/依存のみの変更) だが mergeStateStatus=CLEAN かつ CI 内 wrangler deploy --dry-run でビルド検証済み。マージ後 main push で通常実行。
  • runtime 挙動不変、PR/commit title ASCII。

判定: PASS。auto mode につき squash merge。

@liplus-lin-lay liplus-lin-lay merged commit 97a071b into main Jun 25, 2026
2 of 3 checks passed
@liplus-lin-lay liplus-lin-lay deleted the 238-fixworker-dedupe-mcp-sdk-+-fix-agentts-type-errors-add-tsc-gate-to-ci branch June 25, 2026 17:53
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.

fix(worker): dedupe MCP SDK + fix agent.ts type errors, add tsc gate to CI

1 participant