Allow configuring additionalProperties on generated tool schemas

オープン
#892 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
go
領域
api

調査の方向性

まず、issue で説明されている mcp.AddTool と jsonschema.ForType の呼び出しから始め、次に adcp/addtool.go の allowAdditionalProperties() workaround を調べます。提案されている jsonschema-go、SchemaOptions、Tool override のアプローチを比較し、参照されている adcp-go pull request の要件を確認します。型付きハンドラーが手動でスキーマにパッチを適用せずに、設定可能な追加プロパティを受け入れられれば完了です。

索引モデルが issue の本文から書いたものです。

説明

blocked

Problem

mcp.AddTool generates JSON schemas from Go structs via jsonschema-go, which sets additionalProperties: false on all object types. This means tool inputs that include extra fields (common in protocol envelopes) are rejected at schema validation before reaching the handler.

Use case

The Ad Context Protocol (AdCP) sends protocol-level fields like adcp_major_version alongside tool arguments. These fields are not part of any individual tool's schema but are part of the protocol envelope. The strict additionalProperties: false rejects these requests.

Current workaround

We use the low-level server.AddTool with a manually-patched schema:

schema, _ := jsonschema.ForType(reflect.TypeFor[MyInput](), &jsonschema.ForOptions{})
// Walk schema tree and set AdditionalProperties = nil on all objects
server.AddTool(&mcp.Tool{InputSchema: schema, ...}, rawHandler)

This works but loses the typed handler benefits of mcp.AddTool.

Proposed solution

Either:

  1. Add AllowAdditionalProperties bool to jsonschema.ForOptions (upstream in google/jsonschema-go)
  2. Add a SchemaOptions parameter to mcp.AddTool that allows configuring schema generation
  3. Allow overriding the generated schema on the Tool struct even when using the generic AddTool

Option 1 is the cleanest since it fixes the root cause.

Context

主要言語
Go
スター
5.4k
フォーク
623
平均マージ
22時間 10分
マージ済み PR(30日)
30

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/go-sdk のほかの issue

modelcontextprotocol/go-sdk の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。