@@ -83,39 +83,6 @@ pip install -r requirements.txt
8383uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
8484```
8585
86- ### Using the MCP Server with cmcp Client
87-
88- The MCP server can be accessed using the [ cmcp command-line client] ( https://github.com/RussellLuo/cmcp ) . Follow these steps:
89-
90- 1 . Install cmcp:
91- ``` bash
92- pip install cmcp
93- ```
94-
95- 2 . Connect to the MCP server and call methods:
96- ``` # Compile Rust code
97- echo '{
98- "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}"
99- }' | cmcp call http://localhost:3000 rust-compiler compile
100-
101- # Compile and fix code
102- echo '{
103- "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}",
104- "description": "A simple hello world program",
105- "max_attempts": 3
106- }' | cmcp call http://localhost:3000 rust-compiler compileAndFix
107-
108- # Vector search
109- echo '{
110- "query": "how to implement a web server in Rust",
111- "collection": "project_examples",
112- "limit": 3
113- }' | cmcp call http://localhost:3000 rust-compiler vectorSearch
114- ```
115- 3 . Available MCP methods:
116- - rust-compiler.compile: Compiles Rust code
117- - rust-compiler.compileAndFix: Automatically fixes and compiles Rust code
118- - rust-compiler.vectorSearch: Searches vector database for similar examples
11986---
12087
12188## 🔥 Usage
@@ -178,56 +145,104 @@ curl http://localhost:8000/project/123e4567-e89b-12d3-a456-426614174000
178145
179146---
180147
181- ## 🔧 MCP (Model-Compiler-Processor) Endpoints
148+ ## 🔧 MCP (Model-Compiler-Processor) tools
182149
183- These endpoints provide direct compilation and error fixing for Rust code:
150+ The MCP server is available via the HTTP SSE transport via the ` http://localhost:3000/sse ` URL. The MCP server can be accessed using the [ cmcp command-line client] ( https://github.com/RussellLuo/cmcp ) . To install the ` cmcp ` tool,
151+
152+ ``` bash
153+ pip install cmcp
154+ ```
184155
185156### 🛠 Compile Rust Code
186157
187- ** Endpoint :** ` POST /mcp/ compile`
158+ ** tool :** ` compile `
188159
189- #### 📥 Request Body :
160+ #### 📥 Request example :
190161
191- ``` json
192- {
193- "code" : " [filename: Cargo.toml]\n [package]\n name = \" hello_world\"\n version = \" 0.1.0\"\n edition = \" 2021\"\n\n [dependencies]\n\n [filename: src/main.rs]\n fn main() {\n println!(\" Hello, World!\" );\n }"
194- }
162+ ``` 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+ }'
195169```
196170
197171#### 📤 Response:
198172
199173``` json
200174{
201- "success" : true ,
202- "files" : [" Cargo.toml" , " src/main.rs" ],
203- "build_output" : " Build successful" ,
204- "run_output" : " Hello, World!"
175+ "meta" : null ,
176+ "content" : [
177+ {
178+ "type" : " text" ,
179+ "text" : " success" ,
180+ "annotations" : null
181+ }
182+ ],
183+ "isError" : false
205184}
206185```
207186
208187### 🩹 Compile and Fix Rust Code
209188
210- ** Endpoint :** ` POST /mcp/compile-and-fix `
189+ ** tool :** ` compileAndFix `
211190
212- ### 📥 Request Body:
191+ ### 📥 Request example:
192+
193+ ``` 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+ }'
200+ ```
201+
202+ ### 📤 Response:
213203
214204``` json
215205{
216- "code" : " [filename: Cargo.toml]\n [package]\n name = \" hello_world\"\n version = \" 0.1.0\"\n edition = \" 2021\"\n\n [dependencies]\n\n [filename: src/main.rs]\n fn main() {\n println!(\" Hello, World!\" // Missing closing parenthesis\n }" ,
217- "description" : " A simple hello world program" ,
218- "max_attempts" : 3
206+ "meta" : null ,
207+ "content" : [
208+ {
209+ "type" : " text" ,
210+ "text" : " [filename: Cargo.toml]\n [package]\n name = \" hello_world\"\n version = \" 0.1.0\"\n edition = \" 2021\"\n\n [dependencies]\n\n [filename: src/main.rs]\n fn main() {\n println!(\" Hello, World!\" ); \n }" ,
211+ "annotations" : null
212+ }
213+ ],
214+ "isError" : false
219215}
220216```
221217
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+
222233### 📤 Response:
223234
224235``` json
225236{
226- "success" : true ,
227- "attempts" : [... ],
228- "final_files" : {... },
229- "build_output" : " Build successful" ,
230- "run_output" : " Hello, World!"
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
231246}
232247```
233248
0 commit comments