λx.1
λx.12mo ago

convex-schema-parser

convex-schema-parser A simple dev tool which generates typed Python and Rust api clients. It is intended to run alongside convex dev. E.g. you might have to work on multiple other frontends/backends which use your convex deployment and are not TypeScript. You would then point convex-schema-parser via a .yaml to your local convex repo and where to write the generated clients. E.g.:
# Configuration for the Convex Client Generator.

# (Required) The absolute path to the root of your Convex project.
# This is the directory that contains the `convex/` folder and `package.json`.
# ABSOLUTE: SO no `~`/`$HOME`, etc.
project_path: /path/to/your/convex/project

# (Required) The absolute path to the generated TypeScript declarations, relative to `project_path`.
declarations_dir: /path/to/your/tmp/declarations

# (Required) A list of generation targets. You can have one or more.
targets:
# Example 1: Generate a Rust client for a backend service.
- lang: Rust
# A list of one or more output files for this target.
output:
- ../my-rust-app/src/convex_api.rs
- ../my-other-app/src/convex_api.rs

# Example 2: Generate a Python client for data scripts.
- lang: Python
output:
- ../scripts/lib/convex_client.py
# Configuration for the Convex Client Generator.

# (Required) The absolute path to the root of your Convex project.
# This is the directory that contains the `convex/` folder and `package.json`.
# ABSOLUTE: SO no `~`/`$HOME`, etc.
project_path: /path/to/your/convex/project

# (Required) The absolute path to the generated TypeScript declarations, relative to `project_path`.
declarations_dir: /path/to/your/tmp/declarations

# (Required) A list of generation targets. You can have one or more.
targets:
# Example 1: Generate a Rust client for a backend service.
- lang: Rust
# A list of one or more output files for this target.
output:
- ../my-rust-app/src/convex_api.rs
- ../my-other-app/src/convex_api.rs

# Example 2: Generate a Python client for data scripts.
- lang: Python
output:
- ../scripts/lib/convex_client.py
convex-schema-parser dev uses this file and watches for changes in your convex repo. If the public convex interface changes it will update your generated clients. Rust will catch any potential errors and in Python with something like basedpyright you can follow the type-hints. For any language holds: you decide what the module name is and include it directly in your source-tree. This way you limit the possibility to forget to change/update some other backend of yours whilst making changes to your convex repo. The generate cmd can be used for CI. More is explained in detail in the repos README itself. Hope others might give feedback/make use of it (:
GitHub
GitHub - ParsonosAI/convex-schema-parser: Parses your schema.ts a...
Parses your schema.ts and generates types for Python/Rust - ParsonosAI/convex-schema-parser
4 Replies
Tan
Tan2mo ago
This goes much appreciated! Is MCP-related parsing part of the scope of this project? I would be down to contribute some patterns I’ve found helpful in automating the Convex function-spec -> MCP server written in Python: https://github.com/TanGentleman/YouTwo/blob/main/scripts/run_mcp.py https://github.com/TanGentleman/YouTwo/blob/main/src/youtwo/server/server.py The result is tools defined using convex functions that are exposed more intuitively to the end user If it doesn’t make sense for the schema parser, please let me know and I’ll remove the above ^^
Tan
Tan2mo ago
No description
λx.1
λx.1OP2mo ago
Sorry, I am not that often online here + I was sick this week. You can always open Issues on the GitHub repo itself, more likely to get a quick response. Integrating MCP related parsing should be easy and I guess your provided resources for run_mcp.py and server.py are meant as a guidance for the generated code? IF that is the case, I can take a look and come up with a way for integrating this. (: What I am interested in for this is to gauge the feasibility: How do the .d.ts files for MCP related functionality look like. If you could provide me some examples or tell me how to set up a simple convex project where I could test it, I would be very happy. We could also do this in tandem if you are up for it.
λx.1
λx.1OP4w ago
In case anyone comes across this, we did some updates and I ghetto'ed a quick overview video to show how we use this. https://www.youtube.com/watch?v=4kzkhacJYvk
LambdaX.1
YouTube
Convex - Generate typed APIs for Rust and Python
The convex-schema-parser repository can be found at github.com/ParsonosAI/convex-schema-parser The convex-schema-parser dev command is meant to run continuously. #convex #rust #python #codegeneration #development #devtools #software

Did you find this page helpful?