MCPcopy Create free account
hub / github.com/dexwritescode/rust-mcp / generate_struct

Method generate_struct

src/server/handler.rs:345–379  ·  view source on GitHub ↗
(
        &self,
        Parameters(GenerateStructParams {
            struct_name,
            fields,
            derives,
            file_path,
        }): Parameters<GenerateStructParams>,
    )

Source from the content-addressed store, hash-verified

343
344 #[tool(description = "Generate a struct with specified fields and derives")]
345 async fn generate_struct(
346 &self,
347 Parameters(GenerateStructParams {
348 struct_name,
349 fields,
350 derives,
351 file_path,
352 }): Parameters<GenerateStructParams>,
353 ) -> Result<CallToolResult, McpError> {
354 let args = serde_json::json!({
355 "struct_name": struct_name,
356 "fields": fields,
357 "derives": derives,
358 "file_path": file_path
359 });
360
361 let mut analyzer = self.analyzer.lock().await;
362 match execute_tool("generate_struct", args, &mut analyzer).await {
363 Ok(result) => {
364 if let Some(content) = result.content.first() {
365 if let Some(text) = content.get("text") {
366 return Ok(CallToolResult::success(vec![Content::text(
367 text.as_str().unwrap_or("No result"),
368 )]));
369 }
370 }
371 Ok(CallToolResult::success(vec![Content::text(
372 "Struct generated successfully",
373 )]))
374 }
375 Err(e) => Ok(CallToolResult::success(vec![Content::text(format!(
376 "Error: {e}"
377 ))])),
378 }
379 }
380
381 #[tool(description = "Generate an enum with specified variants and derives")]
382 async fn generate_enum(

Callers

nothing calls this directly

Calls 1

execute_toolFunction · 0.85

Tested by

no test coverage detected