modelcontextprotocol / modelcontextprotocol/go-sdk
Allow configuring additionalProperties on generated tool schemas
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 5.1k
- Forks
- 543
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 37
Description
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:
- Add
AllowAdditionalProperties booltojsonschema.ForOptions(upstream ingoogle/jsonschema-go) - Add a
SchemaOptionsparameter tomcp.AddToolthat allows configuring schema generation - Allow overriding the generated schema on the
Toolstruct even when using the genericAddTool
Option 1 is the cleanest since it fixes the root cause.
Context
- AdCP Go SDK: https://github.com/adcontextprotocol/adcp-go/pull/27
- The workaround is in
adcp/addtool.go—allowAdditionalProperties()function
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with mcp.AddTool and the jsonschema.ForType call described in the issue, then inspect the allowAdditionalProperties() workaround in adcp/addtool.go. Compare the proposed jsonschema-go, SchemaOptions, and Tool override approaches, and check the referenced adcp-go pull request for requirements. Done means typed handlers can accept configurable additional properties without manual schema patching.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100