Skip to content

fix(mcp): type edit_frontmatter operations for OpenAI schema compatibility#38

Open
brndnblck wants to merge 1 commit into
devwhodevs:mainfrom
brndnblck:fix/edit-frontmatter-schema
Open

fix(mcp): type edit_frontmatter operations for OpenAI schema compatibility#38
brndnblck wants to merge 1 commit into
devwhodevs:mainfrom
brndnblck:fix/edit-frontmatter-schema

Conversation

@brndnblck
Copy link
Copy Markdown

Summary

Fixes #32.

OpenAI's function-calling API rejects edit_frontmatter at tool registration because the operations parameter schema has "items": true instead of a proper object schema. This happens because operations was typed as Vec<serde_json::Value>, and schemars maps serde_json::Value to the JSON Schema true (any value).

Changes

  • Add FrontmatterOpKind enum with #[serde(rename_all = "snake_case")] and Deserialize + JsonSchema derives
  • Add FrontmatterOpInput struct with typed op, key, value fields
  • Update EditFrontmatterParams (MCP) and EditFrontmatterBody (HTTP) to use Vec<FrontmatterOpInput>
  • Simplify parse_frontmatter_ops in both serve.rs and http.rs to match on the typed enum
  • Add regression test asserting operations.items is an object schema (not true)
  • Add deserialization round-trip test for all 6 variants
  • Add test confirming unknown op variants are rejected at deserialization

Generated schema (after fix)

"operations": {
  "type": "array",
  "items": {
    "$ref": "#/$defs/FrontmatterOpInput"
  }
}

Where FrontmatterOpInput defines op as an enum with the 6 allowed values.

Wire format

Unchanged. {"op": "set", "key": "status", "value": "done"} works identically.

Testing

  • cargo fmt --check -- clean
  • cargo clippy -- -D warnings -- clean
  • cargo test --lib -- 461 passed (458 existing + 3 new)

@brndnblck brndnblck force-pushed the fix/edit-frontmatter-schema branch from 34616a6 to 30f70aa Compare May 17, 2026 04:06
Replace `Vec<serde_json::Value>` with typed `FrontmatterOpInput` struct
and `FrontmatterOpKind` enum for the `edit_frontmatter` tool's
`operations` parameter. This causes schemars to emit a proper object
schema instead of `"items": true`, which OpenAI's function-calling API
rejects at tool registration time.

Changes:
- Add `FrontmatterOpKind` enum with serde rename_all = snake_case
- Add `FrontmatterOpInput` struct with typed op/key/value fields
- Update `EditFrontmatterParams` and `EditFrontmatterBody` to use the
  new types
- Simplify `parse_frontmatter_ops` in both serve.rs and http.rs to match
  on the enum instead of raw JSON strings
- Add regression test asserting operations.items is an object schema
- Add deserialization round-trip and unknown-variant rejection tests

Fixes devwhodevs#32
@brndnblck brndnblck force-pushed the fix/edit-frontmatter-schema branch from 30f70aa to 1bdd8be Compare May 17, 2026 04:07
@brndnblck brndnblck changed the title fix: type edit_frontmatter operations for OpenAI schema compatibility fix(mcp): type edit_frontmatter operations for OpenAI schema compatibility May 17, 2026
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.

Compatibility with OpenAI Codex (rejects mcp_engraph_edit_frontmatter due to invalid JSON schema)

1 participant