Skip to content

memories/mcp: generate tool schemas with schemars#21012

Merged
jif-oai merged 2 commits into
mainfrom
jif/use-schemars
May 4, 2026
Merged

memories/mcp: generate tool schemas with schemars#21012
jif-oai merged 2 commits into
mainfrom
jif/use-schemars

Conversation

@jif-oai

@jif-oai jif-oai commented May 4, 2026

Copy link
Copy Markdown
Collaborator

Why

The memories MCP server currently keeps handwritten JSON Schema beside the Rust types that actually serialize and deserialize the tool payloads: schema.rs, server.rs, and backend.rs. That duplicates the tool contract and makes schema drift easier as the API evolves.

What changed

  • derive JsonSchema for the memories tool arguments, responses, and nested response types
  • replace the handwritten schema builders with shared schemars generation
  • preserve the existing wire shape while generating schemas, including nullable output Option fields and non-nullable optional input fields
  • wire the list, read, and search tools to the generated schemas

Verification

  • CI pending

@jif-oai jif-oai changed the title feat: rely on schemars to unify schema memories/mcp: generate tool schemas with schemars May 4, 2026
@jif-oai

jif-oai commented May 4, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1353ca3a97

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/memories/mcp/src/backend.rs Outdated
Comment thread codex-rs/memories/mcp/src/backend.rs Outdated
@jif-oai

jif-oai commented May 4, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 613f90fc64

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +14 to +18
let schema = SchemaSettings::draft2019_09()
.with(|settings| {
settings.inline_subschemas = true;
settings.option_add_null_type = option_add_null_type;
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Generate output schemas with serialize contract

Switching to SchemaSettings::draft2019_09() keeps the default Deserialize contract. output_schema_for reuses this path, so output Option fields (e.g. ListMemoriesResponse.path/next_cursor, SearchMemoriesResponse.path/next_cursor) become optional-in-object instead of required-but-nullable. That changes the published tool contract and conflicts with the stated intent to preserve existing output wire shape.

Useful? React with 👍 / 👎.

@jif-oai jif-oai merged commit f20f8a7 into main May 4, 2026
26 checks passed
@jif-oai jif-oai deleted the jif/use-schemars branch May 4, 2026 16:40
@github-actions github-actions Bot locked and limited conversation to collaborators May 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant