Skip to main content
Glama

Convex MCP server

Official
by get-convex
storage.rs2.65 kB
use common::{ components::ComponentId, testing::TestPersistence, }; use keybroker::Identity; use model::file_storage::FileStorageId; use must_let::must_let; use runtime::testing::TestRuntime; use value::{ assert_obj, ConvexValue, }; use crate::{ test_helpers::UdfTest, tests::action::action_udf_test, ActionCallbacks, }; #[convex_macro::test_runtime] async fn test_storage_store_get(rt: TestRuntime) -> anyhow::Result<()> { let t = action_udf_test(rt).await?; let data = ConvexValue::Bytes("data".as_bytes().to_vec().try_into()?); let id = t .action("storage:storeFile", assert_obj!("data" => data.clone())) .await?; let retrieved = t.action("storage:getFile", assert_obj!("id" => id)).await?; assert_eq!(data, retrieved); Ok(()) } async fn check_storage_url( t: &UdfTest<TestRuntime, TestPersistence>, url: &ConvexValue, id: &ConvexValue, ) -> anyhow::Result<()> { must_let!(let ConvexValue::String(url_str) = url); must_let!(let ConvexValue::String(id_str) = id); must_let!(let Some(internal_id) = url_str.strip_prefix("http://127.0.0.1:8000/api/storage/")); must_let!( let Some((_, storage_entry)) = t.storage_get_file_entry( Identity::system(), ComponentId::test_user(), FileStorageId::DocumentId(id_str.parse()?) ).await? ); assert_eq!(storage_entry.storage_id, internal_id.parse()?); Ok(()) } #[convex_macro::test_runtime] async fn test_storage_get_url(rt: TestRuntime) -> anyhow::Result<()> { let t = action_udf_test(rt).await?; let data = ConvexValue::Bytes("data".as_bytes().to_vec().try_into()?); let id = t .action("storage:storeFile", assert_obj!("data" => data.clone())) .await?; let url = t .query("storage:getFileUrl", assert_obj!("id" => id.clone())) .await?; check_storage_url(&t, &url, &id).await?; Ok(()) } #[convex_macro::test_runtime] async fn test_storage_get_url_parallel(rt: TestRuntime) -> anyhow::Result<()> { let t = action_udf_test(rt).await?; let data = ConvexValue::Bytes("data".as_bytes().to_vec().try_into()?); let mut ids = Vec::new(); // Default parallel chunk size is 16. for _ in 0..20 { ids.push( t.action("storage:storeFile", assert_obj!("data" => data.clone())) .await?, ); } let urls = t .query("storage:getFileUrls", assert_obj!("ids" => ids.clone())) .await?; must_let!(let ConvexValue::Array(urls) = urls); for idx in 0..20 { check_storage_url(&t, &urls[idx], &ids[idx]).await?; } Ok(()) }

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