Skip to main content
Glama

Convex MCP server

Official
by get-convex
labels.rs2.37 kB
use std::borrow::Cow; /// Type alias for when you need to make a `MetricLabel` from an unowned string, /// and you'd rather just make it owned than propagate lifetimes. pub type StaticMetricLabel = MetricLabel<'static>; pub type Labels<'a> = Vec<MetricLabel<'a>>; #[derive(PartialOrd, Ord, PartialEq, Eq, Clone, Debug)] pub struct MetricLabel<'a> { pub key: &'static str, // Allows passing in an owned `String` or an `&'a str` -- the latter is useful if you have a // `&str` and need to create the `MetricLabel` to immediately report a metric, such that the // label doesn't need to outlive the current scope. pub value: Cow<'a, str>, } impl<'a> MetricLabel<'a> { pub const STATUS_CANCELED: StaticMetricLabel = MetricLabel { key: "status", value: Cow::Borrowed("canceled"), }; pub const STATUS_DEVELOPER_ERROR: StaticMetricLabel = MetricLabel { key: "status", value: Cow::Borrowed("developer_error"), }; pub const STATUS_ERROR: StaticMetricLabel = MetricLabel { key: "status", value: Cow::Borrowed("error"), }; pub const STATUS_SUCCESS: StaticMetricLabel = MetricLabel { key: "status", value: Cow::Borrowed("success"), }; pub fn new(key: &'static str, value: impl Into<Cow<'a, str>>) -> Self { Self { key, value: value.into(), } } pub const fn new_const(key: &'static str, value: &'static str) -> StaticMetricLabel { MetricLabel { key, value: Cow::Borrowed(value), } } /// Common labels. Use these instead of custom defined ones when possible. pub fn status(is_ok: bool) -> MetricLabel<'static> { if is_ok { Self::STATUS_SUCCESS } else { Self::STATUS_ERROR } } pub fn split_key_value(&self) -> (&str, &str) { (self.key, &self.value) } } pub const STATUS_LABEL: [&str; 1] = ["status"]; pub trait IntoLabel { fn as_label(&self) -> &'static str; } impl IntoLabel for bool { fn as_label(&self) -> &'static str { if *self { "true" } else { "false" } } } pub const CLUSTER_LABEL: &str = "cluster"; pub fn cluster_label(cluster: &'static str) -> StaticMetricLabel { StaticMetricLabel::new(CLUSTER_LABEL, cluster) }

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