Skip to main content
Glama

Convex MCP server

Official
by get-convex
tests.rs2.41 kB
use std::str::FromStr; use cmd_util::env::env_config; use proptest::prelude::*; use serde_json::{ json, Value as JsonValue, }; use value::ConvexValue; use super::expression::JsonExpression; use crate::{ paths::FieldPath, query::{ Expression, Query, }, testing::assert_roundtrips, }; #[test] fn test_parse_expr() -> anyhow::Result<()> { fn test_case(v: serde_json::Value, expected: Expression) -> anyhow::Result<()> { assert_eq!( Expression::try_from(serde_json::from_str::<JsonExpression>(&v.to_string())?)?, expected ); Ok(()) } test_case( json!({ "$literal": "foo" }), Expression::Literal(ConvexValue::try_from("foo")?.into()), )?; test_case( json!({ "$field": "email" }), Expression::Field(FieldPath::from_str("email")?), )?; test_case( json!({ "$eq": [ { "$field": "email" }, { "$literal": "bw@convex.dev" }, ], }), Expression::Eq( Box::new(Expression::Field(FieldPath::from_str("email")?)), Box::new(Expression::Literal( ConvexValue::try_from("bw@convex.dev")?.into(), )), ), )?; test_case( json!({ "$and": [ { "$literal": true }, { "$literal": false }, { "$literal": true }, ], }), Expression::And(vec![ Expression::Literal(ConvexValue::from(true).into()), Expression::Literal(ConvexValue::from(false).into()), Expression::Literal(ConvexValue::from(true).into()), ]), )?; Ok(()) } #[test] fn test_parse_query() -> anyhow::Result<()> { Query::try_from(json!({ "source": { "type": "FullTableScan", "tableName": "users", "order": "asc" }, "operators": [ { "filter": { "$eq": [ {"$field": "email"}, { "$literal": "bw@convex.dev" } ] } }, ], }))?; Ok(()) } proptest! { #![proptest_config( ProptestConfig { cases: 256 * env_config("CONVEX_PROPTEST_MULTIPLIER", 1), failure_persistence: None, ..ProptestConfig::default() } )] #[test] fn test_query_roundtrips_to_json(query in any::<Query>()) { assert_roundtrips::<Query, JsonValue>(query); } }

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/get-convex/convex-backend'

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