Skip to content

fix(mcp): normalize no-arg tool schemas for OpenAI compatibility#112

Merged
sara-dini merged 2 commits into
mainfrom
sara/fix-noarg-schema-106
May 15, 2026
Merged

fix(mcp): normalize no-arg tool schemas for OpenAI compatibility#112
sara-dini merged 2 commits into
mainfrom
sara/fix-noarg-schema-106

Conversation

@sara-dini
Copy link
Copy Markdown
Collaborator

Summary

Fixes #106 by normalizing MCP tool inputSchema objects in CLI proxy tools/list rewrite so no-arg tools are always emitted with explicit OpenAI-compatible object fields.

What changed

  • In rewrite_tools_list, for any inputSchema where type == "object", ensure defaults:
    • properties: {}
    • required: []
    • additionalProperties: false
  • Added regression tests for:
    • bare no-arg schema { "type": "object" } normalization
    • preserving pre-existing additionalProperties

Why

OpenAI/Codex rejects object schemas lacking properties. Some zero-arg tools (for example help) can currently pass through as { "type": "object" }, which breaks tool ingestion.

Validation

  • Added focused tests in src/main.rs.
  • Could not execute tests in this environment because toolchain linker is unavailable: linker 'cc' not found.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the rewrite_tools_list function in src/main.rs to normalize tool input schemas by ensuring that object-type schemas include explicit properties, required, and additionalProperties fields. Corresponding unit tests were added to validate this normalization and confirm that existing properties are not overwritten. The review feedback correctly identifies that the new test assertions lack descriptive messages, which is a violation of the repository's coding standards.

Comment thread src/main.rs Outdated
Comment on lines +7566 to +7569
assert_eq!(input["type"], "object");
assert_eq!(input["properties"], json!({}));
assert_eq!(input["required"], json!([]));
assert_eq!(input["additionalProperties"], false);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository's style guide (line 74), all assertions should include descriptive messages. This helps clarify the test's intent when it fails. Please add messages to these assertions.

assert_eq!(input["type"], "object", "Schema type should remain 'object'");
assert_eq!(input["properties"], json!({}), "A default empty 'properties' object should be added");
assert_eq!(input["required"], json!([]), "A default empty 'required' array should be added");
assert_eq!(input["additionalProperties"], false, "A default 'additionalProperties: false' should be added");
References
  1. All assertions must include descriptive messages to clarify their purpose, especially upon failure. (link)

Comment thread src/main.rs
Comment on lines +7593 to +7596
assert_eq!(
parsed["result"]["tools"][0]["inputSchema"]["additionalProperties"],
true
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Per the repository style guide (line 74), assertions should include descriptive messages. Please add a message to this assertion to clarify what is being tested.

assert_eq!(
    parsed["result"]["tools"][0]["inputSchema"]["additionalProperties"],
    true,
    "An existing 'additionalProperties' value should be preserved and not overwritten by the default"
);
References
  1. All assertions must include descriptive messages to clarify their purpose, especially upon failure. (link)

@sara-dini
Copy link
Copy Markdown
Collaborator Author

Applied requested review fix on-head: added descriptive assertion messages to the new no-arg schema normalization tests in (commit c58431e).\n\nValidation status in this runtime:\n- Unable to run / / / locally because linker is missing ().\n\nNext concrete step:\n- Re-run CI and reviewer pass on latest head; if green, this PR is ready to merge.

@sara-dini
Copy link
Copy Markdown
Collaborator Author

Superseding prior comment (shell interpolation issue).

Applied requested review fix on-head: added descriptive assertion messages to the new no-arg schema normalization tests in src/main.rs (commit c58431e).

Validation status in this runtime:

  • Unable to run cargo fmt / cargo clippy -- -D warnings / cargo test / cargo build locally because linker cc is missing (error: linker cc not found).

Next concrete step:

  • Re-run CI and reviewer pass on latest head; if green, this PR is ready to merge.

Copy link
Copy Markdown
Collaborator

@vish-dini vish-dini left a comment

Choose a reason for hiding this comment

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

Reviewed on-head. Diff is surgical, CI is green, and the schema normalization aligns with current OpenAI function-calling requirements for object parameters. Approve and merge once branch protections are satisfied.

@sara-dini sara-dini merged commit 5689f33 into main May 15, 2026
2 checks passed
@sara-dini sara-dini deleted the sara/fix-noarg-schema-106 branch May 15, 2026 23:06
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.

No-arg MCP tool schemas omit properties, causing OpenAI/Codex rejection

2 participants