1- # Rust Project Generator API
1+ # Rust Coder
22
3- An API service that generates fully functional Rust projects from natural language descriptions. This service leverages LLMs to create Rust code, compiles it , and automatically fixes any errors.
3+ API and MCP services that generate fully functional Rust projects from natural language descriptions. These services leverage LLMs to create complete Rust cargo projects, compile Rust source code , and automatically fix compiler errors.
44
55---
66
@@ -91,6 +91,113 @@ The API provides the following endpoints:
9191
9292### 🎯 Generate a Project
9393
94+ ** Endpoint:** ` POST /generate-sync `
95+
96+ ** Example:**
97+
98+ ``` bash
99+ curl -X POST http://localhost:8000/generate-sync \
100+ -H " Content-Type: application/json" \
101+ -d ' {"description": "A command-line calculator in Rust", "requirements": "Should support addition, subtraction, multiplication, and division"}'
102+ ```
103+
104+ #### 📥 Request Body:
105+
106+ ```
107+ {
108+ "description": "A command-line calculator in Rust",
109+ "requirements": "Should support addition, subtraction, multiplication, and division"
110+ }
111+ ```
112+
113+ #### 📤 Response:
114+
115+ ```
116+ [filename: Cargo.toml]
117+ ... ...
118+
119+ [filename: src/main.rs]
120+ ... ...
121+ ```
122+
123+ ### 🛠 Compile a Project
124+
125+ ** Endpoint:** ` POST /compile `
126+
127+ ** Example:**
128+
129+ ``` bash
130+ curl -X POST http://localhost:8000/compile \
131+ -H " Content-Type: application/json" \
132+ -d ' {
133+ "code": "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\");\n}"
134+ }'
135+ ```
136+
137+ #### 📥 Request Body:
138+
139+ ```
140+ {
141+ "code": "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\");\n}"
142+ }
143+ ```
144+
145+ #### 📤 Response:
146+
147+ ```
148+ {
149+ "success":true,
150+ "files":["Cargo.toml","src/main.rs"],
151+ "build_output":"Build successful",
152+ "run_output":"Hello, World!\n"
153+ }
154+ ```
155+
156+ ### 🩹 Compile and fix errors
157+
158+ ** Endpoint:** ` POST /compile-and-fix `
159+
160+ ** Example:**
161+
162+ ``` bash
163+ curl -X POST http://localhost:8000/compile-and-fix \
164+ -H " Content-Type: application/json" \
165+ -d ' {
166+ "code": "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\" // Missing closing parenthesis\n}",
167+ "description": "A simple hello world program",
168+ "max_attempts": 3
169+ }'
170+ ```
171+
172+ #### 📥 Request Body:
173+
174+ ```
175+ {
176+ "code": "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\" // Missing closing parenthesis\n}",
177+ "description": "A simple hello world program",
178+ "max_attempts": 3
179+ }
180+ ```
181+
182+ #### 📤 Response:
183+
184+ ```
185+ [filename: Cargo.toml]
186+ [package]
187+ name = "hello_world"
188+ version = "0.1.0"
189+ edition = "2021"
190+
191+ [dependencies]
192+
193+ [filename: src/main.rs]
194+ fn main() {
195+ println!("Hello, World!"); // Missing closing parenthesis
196+ }
197+ ```
198+
199+ ### 🎯 Generate a Project Async
200+
94201** Endpoint:** ` POST /generate `
95202
96203** Example:**
@@ -143,6 +250,24 @@ curl http://localhost:8000/project/123e4567-e89b-12d3-a456-426614174000
143250}
144251```
145252
253+ ### 📌 Get Generated Files
254+
255+ ** Endpoint:** ` GET /project/{project_id}/files/path_to_file `
256+
257+ ** Example:**
258+
259+ ``` bash
260+ curl http://localhost:8000/project/123e4567-e89b-12d3-a456-426614174000/files/src/main.rs
261+ ```
262+
263+ #### 📤 Response:
264+
265+ ```
266+ fn main() {
267+ ... ...
268+ }
269+ ```
270+
146271---
147272
148273## 🔧 MCP (Model-Compiler-Processor) tools
@@ -153,19 +278,14 @@ The MCP server is available via the HTTP SSE transport via the `http://localhost
153278pip install cmcp
154279```
155280
156- ### 🛠 Compile Rust Code
281+ ### 🎯 Generate a new project
157282
158- ** tool:** ` compile `
283+ ** tool:** ` generate `
159284
160285#### 📥 Request example:
161286
162287``` bash
163- cmcp http://localhost:3000 tools/call -d ' { \
164- "name": "compile", \
165- "arguments": { \
166- "code: "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\");\n}" \
167- } \
168- }'
288+ cmcp http://localhost:3000 tools/call name=generate arguments:=' {"description": "A command-line calculator in Rust", "requirements": "Should support addition, subtraction, multiplication, and division"}'
169289```
170290
171291#### 📤 Response:
@@ -176,30 +296,24 @@ cmcp http://localhost:3000 tools/call -d '{ \
176296 "content" : [
177297 {
178298 "type" : " text" ,
179- "text" : " success " ,
299+ "text" : " [filename: Cargo.toml] ... [filename: src/main.rs] ... " ,
180300 "annotations" : null
181301 }
182302 ],
183303 "isError" : false
184304}
185305```
186-
187306### 🩹 Compile and Fix Rust Code
188307
189- ** tool:** ` compileAndFix `
308+ ** tool:** ` compile_and_fix `
190309
191- ### 📥 Request example:
310+ #### 📥 Request example:
192311
193312``` bash
194- cmcp http://localhost:3000 tools/call -d ' { \
195- "name": "compileAndFix", \
196- "arguments": { \
197- "code: "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\" // Missing closing parenthesis \n}" \
198- } \
199- }'
313+ cmcp http://localhost:3000 tools/call name=compile_and_fix arguments:=' {"code": "[filename: Cargo.toml]\n[package]\nname = \"hello_world\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\n\n[filename: src/main.rs]\nfn main() {\n println!(\"Hello, World!\" // Missing closing parenthesis \n}" }'
200314```
201315
202- ### 📤 Response:
316+ #### 📤 Response:
203317
204318``` json
205319{
@@ -215,37 +329,6 @@ cmcp http://localhost:3000 tools/call -d '{ \
215329}
216330```
217331
218- ### 🎯 Generate a new project
219-
220- ** tool:** ` generate `
221-
222- ### 📥 Request example:
223-
224- ``` bash
225- cmcp http://localhost:3000 tools/call -d ' { \
226- "name": "generate", \
227- "arguments": { \
228- "description": "A command-line calculator in Rust", "requirements": "Should support addition, subtraction, multiplication, and division" \
229- } \
230- }'
231- ```
232-
233- ### 📤 Response:
234-
235- ``` json
236- {
237- "meta" : null ,
238- "content" : [
239- {
240- "type" : " text" ,
241- "text" : " [filename: Cargo.toml] ... [filename: src/main.rs] ... " ,
242- "annotations" : null
243- }
244- ],
245- "isError" : false
246- }
247- ```
248-
249332---
250333
251334## 📂 Project Structure
@@ -295,4 +378,4 @@ Contributions are welcome! Feel free to submit a Pull Request. 🚀
295378---
296379
297380## 📜 License
298- Licensed under [ No license ]] ( LICENSE ) .
381+ Licensed under [ GPLv3 ] ( https://www.gnu.org/licenses/gpl-3.0.en.html ) .
0 commit comments