Skip to main content
Glama

Convex MCP server

Official
by get-convex
testing.rs2.39 kB
use std::sync::LazyLock; use chrono::{ Duration, Utc, }; use openidconnect::{ core::{ CoreIdTokenVerifier, CoreJwsSigningAlgorithm, CoreRsaPrivateSigningKey, }, Audience, EndUserEmail, EndUserName, IdTokenClaims, IssuerUrl, JsonWebKeyId, StandardClaims, SubjectIdentifier, }; use rsa::pkcs1::EncodeRsaPrivateKey; use sync_types::UserIdentityAttributes; use crate::{ broker::{ CoreIdTokenWithCustomClaims, CustomClaims, }, UserIdentity, }; pub static TEST_SIGNING_KEY: LazyLock<CoreRsaPrivateSigningKey> = LazyLock::new(|| { let key = rsa::RsaPrivateKey::new(&mut rsa::rand_core::OsRng, 2048).unwrap(); let pem = key.to_pkcs1_pem(rsa::pkcs8::LineEnding::LF).unwrap(); CoreRsaPrivateSigningKey::from_pem(&pem, Some(JsonWebKeyId::new("key1".to_string()))).unwrap() }); pub trait TestUserIdentity { fn test() -> Self; } impl TestUserIdentity for UserIdentity { fn test() -> Self { let subject = "testauth|123".to_owned(); let issuer = "https://testauth.fake.domain".to_owned(); let audience = Audience::new("client-id-123".to_string()); let token = CoreIdTokenWithCustomClaims::new( IdTokenClaims::new( IssuerUrl::new(issuer).unwrap(), vec![audience], Utc::now() + Duration::seconds(600), Utc::now(), StandardClaims::new(SubjectIdentifier::new(subject)) .set_email(Some(EndUserEmail::new("foo@bar.com".to_string()))) .set_name(Some(EndUserName::new("Al Pastor".to_string()).into())), CustomClaims::default(), ), &*TEST_SIGNING_KEY, CoreJwsSigningAlgorithm::RsaSsaPkcs1V15Sha256, None, None, ) .unwrap(); let verifier = CoreIdTokenVerifier::new_insecure_without_verification(); UserIdentity::from_token(token, verifier).unwrap() } } impl TestUserIdentity for UserIdentityAttributes { fn test() -> Self { UserIdentityAttributes { subject: Some("fake_user".to_string()), issuer: Some("convex".to_string()), name: Some("bozo".to_string()), email: Some("bozo@convex.dev".to_string()), ..Default::default() } } }

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