From 0b0439a80754384406636d2565f39636d5927c0d Mon Sep 17 00:00:00 2001 From: Michael Yuan Date: Wed, 21 May 2025 14:49:00 -0500 Subject: [PATCH 1/2] Update MCP docs --- README.md | 125 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 70 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index e57ec82..303396c 100644 --- a/README.md +++ b/README.md @@ -83,39 +83,6 @@ pip install -r requirements.txt uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload ``` -### Using the MCP Server with cmcp Client - -The MCP server can be accessed using the [cmcp command-line client](https://github.com/RussellLuo/cmcp). Follow these steps: - -1. Install cmcp: - ```bash - pip install cmcp - ``` - -2. Connect to the MCP server and call methods: - ```# Compile Rust code - echo '{ - "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}" - }' | cmcp call http://localhost:3000 rust-compiler compile - - # Compile and fix code - echo '{ - "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}", - "description": "A simple hello world program", - "max_attempts": 3 - }' | cmcp call http://localhost:3000 rust-compiler compileAndFix - - # Vector search - echo '{ - "query": "how to implement a web server in Rust", - "collection": "project_examples", - "limit": 3 - }' | cmcp call http://localhost:3000 rust-compiler vectorSearch - ``` -3. Available MCP methods: - - rust-compiler.compile: Compiles Rust code - - rust-compiler.compileAndFix: Automatically fixes and compiles Rust code - - rust-compiler.vectorSearch: Searches vector database for similar examples --- ## 🔥 Usage @@ -178,56 +145,104 @@ curl http://localhost:8000/project/123e4567-e89b-12d3-a456-426614174000 --- -## 🔧 MCP (Model-Compiler-Processor) Endpoints +## 🔧 MCP (Model-Compiler-Processor) tools -These endpoints provide direct compilation and error fixing for Rust code: +The MCP server is available via the HTTP SSE transport via the `http://localhost:8000/sse` URL. The MCP server can be accessed using the [cmcp command-line client](https://github.com/RussellLuo/cmcp). To install the `cmcp` tool, + +```bash +pip install cmcp +``` ### 🛠 Compile Rust Code -**Endpoint:** `POST /mcp/compile` +**tool:** `compile` -#### 📥 Request Body: +#### 📥 Request example: -```json -{ - "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}" -} +```bash +cmcp http://localhost:8000 tools/call -d '{ \ + "name": "compile", \ + "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!\");\n}" \ + } \ +}' ``` #### 📤 Response: ```json { - "success": true, - "files": ["Cargo.toml", "src/main.rs"], - "build_output": "Build successful", - "run_output": "Hello, World!" + "meta": null, + "content": [ + { + "type": "text", + "text": "success", + "annotations": null + } + ], + "isError": false } ``` ### 🩹 Compile and Fix Rust Code -**Endpoint:** `POST /mcp/compile-and-fix` +**tool:** `compileAndFix` -### 📥 Request Body: +### 📥 Request example: + +```bash +cmcp http://localhost:8000 tools/call -d '{ \ + "name": "compileAndFix", \ + "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}" \ + } \ +}' +``` + +### 📤 Response: ```json { - "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}", - "description": "A simple hello world program", - "max_attempts": 3 + "meta": null, + "content": [ + { + "type": "text", + "text": "[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}", + "annotations": null + } + ], + "isError": false } ``` +### 🎯 Generate a new project + +**tool:** `generate` + +### 📥 Request example: + +```bash +cmcp http://localhost:8000 tools/call -d '{ \ + "name": "generate", \ + "arguments": { \ + "description": "A command-line calculator in Rust", "requirements": "Should support addition, subtraction, multiplication, and division" \ + } \ +}' +``` + ### 📤 Response: ```json { - "success": true, - "attempts": [...], - "final_files": {...}, - "build_output": "Build successful", - "run_output": "Hello, World!" + "meta": null, + "content": [ + { + "type": "text", + "text": "[filename: Cargo.toml] ... [filename: src/main.rs] ... ", + "annotations": null + } + ], + "isError": false } ``` From 782326b58098b78626dede7f632dbf1dbc3810f2 Mon Sep 17 00:00:00 2001 From: Michael Yuan Date: Wed, 21 May 2025 15:00:24 -0500 Subject: [PATCH 2/2] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 303396c..800dc43 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ curl http://localhost:8000/project/123e4567-e89b-12d3-a456-426614174000 ## 🔧 MCP (Model-Compiler-Processor) tools -The MCP server is available via the HTTP SSE transport via the `http://localhost:8000/sse` URL. The MCP server can be accessed using the [cmcp command-line client](https://github.com/RussellLuo/cmcp). To install the `cmcp` tool, +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, ```bash pip install cmcp @@ -160,7 +160,7 @@ pip install cmcp #### 📥 Request example: ```bash -cmcp http://localhost:8000 tools/call -d '{ \ +cmcp http://localhost:3000 tools/call -d '{ \ "name": "compile", \ "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!\");\n}" \ @@ -191,7 +191,7 @@ cmcp http://localhost:8000 tools/call -d '{ \ ### 📥 Request example: ```bash -cmcp http://localhost:8000 tools/call -d '{ \ +cmcp http://localhost:3000 tools/call -d '{ \ "name": "compileAndFix", \ "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}" \ @@ -222,7 +222,7 @@ cmcp http://localhost:8000 tools/call -d '{ \ ### 📥 Request example: ```bash -cmcp http://localhost:8000 tools/call -d '{ \ +cmcp http://localhost:3000 tools/call -d '{ \ "name": "generate", \ "arguments": { \ "description": "A command-line calculator in Rust", "requirements": "Should support addition, subtraction, multiplication, and division" \