Skip to main content
Glama

CodeGraph CLI MCP Server

by Jakedismo
test_complex_schema.rs1.52 kB
use rmcp::{ ErrorData as McpError, handler::server::wrapper::Parameters, model::*, schemars, tool, tool_router, }; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)] pub enum ChatRole { System, User, Assistant, Tool, } #[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)] pub struct ChatMessage { pub role: ChatRole, pub content: String, } #[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)] pub struct ChatRequest { pub system: Option<String>, pub messages: Vec<ChatMessage>, } #[derive(Clone, Default)] pub struct Demo; #[tool_router] impl Demo { pub fn new() -> Self { Self } #[tool(description = "LLM")] async fn chat( &self, chat_request: Parameters<ChatRequest>, ) -> Result<CallToolResult, McpError> { let content = Content::json(chat_request.0)?; Ok(CallToolResult::success(vec![content])) } } #[test] fn test_complex_schema() { let attr = Demo::chat_tool_attr(); let input_schema = attr.input_schema; let enum_number = input_schema .get("definitions") .unwrap() .as_object() .unwrap() .get("ChatRole") .unwrap() .as_object() .unwrap() .get("enum") .unwrap() .as_array() .unwrap() .len(); assert_eq!(enum_number, 4); println!("{}", serde_json::to_string_pretty(&input_schema).unwrap()); }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Jakedismo/codegraph-rust'

If you have feedback or need assistance with the MCP directory API, please join our Discord server